Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: ash/wm/workspace/workspace_manager2.h

Issue 10830365: Initial crack at new workspace behavior. Each workspace now has its (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/workspace/workspace2.cc ('k') | ash/wm/workspace/workspace_manager2.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ASH_WM_WORKSPACE_WORKSPACE_MANAGER2_H_
6 #define ASH_WM_WORKSPACE_WORKSPACE_MANAGER2_H_
7
8 #include <set>
9 #include <string>
10 #include <vector>
11
12 #include "ash/ash_export.h"
13 #include "ash/wm/workspace/base_workspace_manager.h"
14 #include "base/basictypes.h"
15 #include "base/compiler_specific.h"
16 #include "ui/base/ui_base_types.h"
17
18 namespace aura {
19 class Window;
20 }
21
22 namespace gfx {
23 class Point;
24 class Rect;
25 }
26
27 namespace ash {
28 namespace internal {
29
30 class ShelfLayoutManager;
31 class WorkspaceManagerTest2;
32 class Workspace2;
33
34 // WorkspaceManager manages multiple workspaces in the desktop. Workspaces are
35 // implicitly created as windows are maximized (or made fullscreen), and
36 // destroyed when maximized windows are closed or restored. There is always one
37 // workspace for the desktop.
38 // Internally WorkspaceManager2 creates a Window for each Workspace. As windows
39 // are maximized and restored they are reparented to the right Window.
40 class ASH_EXPORT WorkspaceManager2 : public BaseWorkspaceManager {
41 public:
42 explicit WorkspaceManager2(aura::Window* viewport);
43 virtual ~WorkspaceManager2();
44
45 // Returns true if |window| is considered maximized and should exist in its
46 // own workspace.
47 static bool IsMaximized(aura::Window* window);
48
49 // Returns true if |window| is minimized and will restore to a maximized
50 // window.
51 static bool WillRestoreMaximized(aura::Window* window);
52
53 // BaseWorkspaceManager2 overrides:
54 virtual bool IsInMaximizedMode() const OVERRIDE;
55 virtual void SetGridSize(int size) OVERRIDE;
56 virtual int GetGridSize() const OVERRIDE;
57 virtual WorkspaceWindowState GetWindowState() const OVERRIDE;
58 virtual void SetShelf(ShelfLayoutManager* shelf) OVERRIDE;
59 virtual void SetActiveWorkspaceByWindow(aura::Window* window) OVERRIDE;
60 virtual aura::Window* GetParentForNewWindow(aura::Window* window) OVERRIDE;
61
62 private:
63 friend class WorkspaceManager2Test;
64
65 class LayoutManager;
66 class WorkspaceLayoutManager;
67
68 typedef std::vector<Workspace2*> Workspaces;
69
70 // Updates the visibility and whether any windows overlap the shelf.
71 void UpdateShelfVisibility();
72
73 // Returns the workspace that contains |window|.
74 Workspace2* FindBy(aura::Window* window) const;
75
76 // Sets the active workspace.
77 void SetActiveWorkspace(Workspace2* workspace);
78
79 // Returns the bounds of the work area.
80 gfx::Rect GetWorkAreaBounds() const;
81
82 // Returns an iterator into |workspaces_| for |workspace|.
83 Workspaces::iterator FindWorkspace(Workspace2* workspace);
84
85 Workspace2* desktop_workspace() { return workspaces_[0]; }
86 const Workspace2* desktop_workspace() const { return workspaces_[0]; }
87
88 // Creates a new workspace. The Workspace is not added to anything and is
89 // owned by the caller.
90 Workspace2* CreateWorkspace(bool maximized);
91
92 // Moves all the non-maximized child windows of |workspace| to the desktop
93 // stacked beneath |stack_beneath| (if non-NULL). After moving child windows
94 // if |workspace| contains no children it is deleted, otherwise it it moved to
95 // |pending_workspaces_|.
96 void MoveWorkspaceToPendingOrDelete(Workspace2* workspace,
97 aura::Window* stack_beneath);
98
99 // Selects the next workspace.
100 void SelectNextWorkspace();
101
102 // These methods are forwarded from the LayoutManager installed on the
103 // Workspace's window.
104 void OnWindowAddedToWorkspace(Workspace2* workspace, aura::Window* child);
105 void OnWindowRemovedFromWorkspace(Workspace2* workspace, aura::Window* child);
106 void OnWorkspaceChildWindowVisibilityChanged(Workspace2* workspace,
107 aura::Window* child);
108 void OnWorkspaceWindowChildBoundsChanged(Workspace2* workspace,
109 aura::Window* child);
110 void OnWorkspaceWindowShowStateChanged(Workspace2* workspace,
111 aura::Window* child,
112 ui::WindowShowState last_show_state);
113
114 aura::Window* contents_view_;
115
116 Workspace2* active_workspace_;
117
118 // The set of active workspaces. There is always at least one in this stack,
119 // which identifies the desktop.
120 Workspaces workspaces_;
121
122 // The set of workspaces not currently active. Workspaces ended up here in
123 // two scenarios:
124 // . Prior to adding a window a new worskpace is created for it. The
125 // Workspace is added to this set.
126 // . When the maximized window is minimized the workspace is added here.
127 // Once any window in the workspace is activated the workspace is moved to
128 // |workspaces_|.
129 std::set<Workspace2*> pending_workspaces_;
130
131 // See description above setter.
132 int grid_size_;
133
134 // Owned by the Shell. May be NULL.
135 ShelfLayoutManager* shelf_;
136
137 // Whether or not we're in MoveWorkspaceToPendingOrDelete(). As
138 // MoveWorkspaceToPendingOrDelete() may trigger another call to
139 // MoveWorkspaceToPendingOrDelete() we use this to avoid doing anything if
140 // already in MoveWorkspaceToPendingOrDelete().
141 bool in_move_;
142
143 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager2);
144 };
145
146 } // namespace internal
147 } // namespace ash
148
149 #endif // ASH_WM_WORKSPACE_WORKSPACE_MANAGER2_H_
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace2.cc ('k') | ash/wm/workspace/workspace_manager2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698