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

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

Issue 11293014: Renames Workspace*2 -> Workspace*. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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/workspace_manager.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/shell_observer.h"
14 #include "ash/wm/workspace/workspace_types.h"
15 #include "base/basictypes.h"
16 #include "base/compiler_specific.h"
17 #include "base/memory/weak_ptr.h"
18 #include "base/time.h"
19 #include "base/timer.h"
20 #include "ui/base/ui_base_types.h"
21
22 namespace aura {
23 class Window;
24 }
25
26 namespace base {
27 class TimeDelta;
28 }
29
30 namespace gfx {
31 class Point;
32 class Rect;
33 }
34
35 namespace ui {
36 class Layer;
37 }
38
39 namespace ash {
40 namespace internal {
41
42 class DesktopBackgroundFadeController;
43 class ShelfLayoutManager;
44 class WorkspaceLayoutManager2;
45 class WorkspaceManagerTest2;
46 class Workspace2;
47
48 // WorkspaceManager manages multiple workspaces in the desktop. Workspaces are
49 // implicitly created as windows are maximized (or made fullscreen), and
50 // destroyed when maximized windows are closed or restored. There is always one
51 // workspace for the desktop.
52 // Internally WorkspaceManager2 creates a Window for each Workspace. As windows
53 // are maximized and restored they are reparented to the right Window.
54 class ASH_EXPORT WorkspaceManager2 : public ash::ShellObserver {
55 public:
56 explicit WorkspaceManager2(aura::Window* viewport);
57 virtual ~WorkspaceManager2();
58
59 // Returns true if |window| is considered maximized and should exist in its
60 // own workspace.
61 static bool IsMaximized(aura::Window* window);
62 static bool IsMaximizedState(ui::WindowShowState state);
63
64 // Returns true if |window| is minimized and will restore to a maximized
65 // window.
66 static bool WillRestoreMaximized(aura::Window* window);
67
68 // Returns the current window state.
69 WorkspaceWindowState GetWindowState() const;
70
71 void SetShelf(ShelfLayoutManager* shelf);
72
73 // Activates the workspace containing |window|. Does nothing if |window| is
74 // NULL or not contained in a workspace.
75 void SetActiveWorkspaceByWindow(aura::Window* window);
76
77 // Returns the parent for |window|. This is invoked from StackingController
78 // when a new Window is being added.
79 aura::Window* GetParentForNewWindow(aura::Window* window);
80
81 // Starts the animation that occurs on first login.
82 void DoInitialAnimation();
83
84 // ShellObserver overrides:
85 virtual void OnAppTerminating() OVERRIDE;
86
87 private:
88 friend class WorkspaceLayoutManager2;
89 friend class WorkspaceManager2Test;
90
91 class LayoutManagerImpl;
92
93 typedef std::vector<Workspace2*> Workspaces;
94
95 // Reason for the workspace switch. Used to determine the characterstics of
96 // the animation.
97 enum SwitchReason {
98 SWITCH_WINDOW_MADE_ACTIVE,
99 SWITCH_WINDOW_REMOVED,
100 SWITCH_VISIBILITY_CHANGED,
101 SWITCH_MINIMIZED,
102 SWITCH_MAXIMIZED_OR_RESTORED,
103 SWITCH_TRACKED_BY_WORKSPACE_CHANGED,
104
105 // Switch as the result of DoInitialAnimation(). This isn't a real switch,
106 // rather we run the animations as if a switch occurred.
107 SWITCH_INITIAL,
108
109 // Edge case. See comment in OnWorkspaceWindowShowStateChanged(). Don't
110 // make other types randomly use this!
111 SWITCH_OTHER,
112 };
113
114 // Updates the visibility and whether any windows overlap the shelf.
115 void UpdateShelfVisibility();
116
117 // Returns the workspace that contains |window|.
118 Workspace2* FindBy(aura::Window* window) const;
119
120 // Sets the active workspace.
121 void SetActiveWorkspace(Workspace2* workspace,
122 SwitchReason reason,
123 base::TimeDelta duration);
124
125 // Returns the bounds of the work area.
126 gfx::Rect GetWorkAreaBounds() const;
127
128 // Returns an iterator into |workspaces_| for |workspace|.
129 Workspaces::iterator FindWorkspace(Workspace2* workspace);
130
131 Workspace2* desktop_workspace() { return workspaces_[0]; }
132 const Workspace2* desktop_workspace() const { return workspaces_[0]; }
133
134 // Creates a new workspace. The Workspace is not added to anything and is
135 // owned by the caller.
136 Workspace2* CreateWorkspace(bool maximized);
137
138 // Moves all the non-maximized child windows of |workspace| to the desktop
139 // stacked beneath |stack_beneath| (if non-NULL). After moving child windows
140 // if |workspace| contains no children it is deleted, otherwise it it moved to
141 // |pending_workspaces_|.
142 void MoveWorkspaceToPendingOrDelete(Workspace2* workspace,
143 aura::Window* stack_beneath,
144 SwitchReason reason);
145
146 // Moves the children of |window| to the desktop. This excludes certain
147 // windows. If |stack_beneath| is non-NULL the windows are stacked beneath it.
148 void MoveChildrenToDesktop(aura::Window* window, aura::Window* stack_beneath);
149
150 // Selects the next workspace.
151 void SelectNextWorkspace(SwitchReason reason);
152
153 // Schedules |workspace| for deletion when it no longer contains any layers.
154 // See comments above |to_delete_| as to why we do this.
155 void ScheduleDelete(Workspace2* workspace);
156
157 // Deletes any workspaces scheduled via ScheduleDelete() that don't contain
158 // any layers.
159 void ProcessDeletion();
160
161 // Sets |unminimizing_workspace_| to |workspace|.
162 void SetUnminimizingWorkspace(Workspace2* workspace);
163
164 // Fades the desktop. This is only used when maximizing or restoring a
165 // window. The actual fade is handled by
166 // DesktopBackgroundFadeController. |window| is used when restoring and
167 // indicates the window to stack the DesktopBackgroundFadeController's window
168 // above.
169 void FadeDesktop(aura::Window* window, base::TimeDelta duration);
170
171 // Shows or hides the desktop Window |window|.
172 void ShowOrHideDesktopBackground(aura::Window* window,
173 SwitchReason reason,
174 base::TimeDelta duration,
175 bool show) const;
176
177 // Shows/hides |workspace| animating as necessary.
178 void ShowWorkspace(Workspace2* workspace,
179 Workspace2* last_active,
180 SwitchReason reason) const;
181 void HideWorkspace(Workspace2* workspace,
182 SwitchReason reason,
183 bool is_unminimizing_maximized_window) const;
184
185 // These methods are forwarded from the LayoutManager installed on the
186 // Workspace's window.
187 void OnWindowAddedToWorkspace(Workspace2* workspace, aura::Window* child);
188 void OnWillRemoveWindowFromWorkspace(Workspace2* workspace,
189 aura::Window* child);
190 void OnWindowRemovedFromWorkspace(Workspace2* workspace, aura::Window* child);
191 void OnWorkspaceChildWindowVisibilityChanged(Workspace2* workspace,
192 aura::Window* child);
193 void OnWorkspaceWindowChildBoundsChanged(Workspace2* workspace,
194 aura::Window* child);
195 void OnWorkspaceWindowShowStateChanged(Workspace2* workspace,
196 aura::Window* child,
197 ui::WindowShowState last_show_state,
198 ui::Layer* old_layer);
199 void OnTrackedByWorkspaceChanged(Workspace2* workspace,
200 aura::Window* window);
201
202 aura::Window* contents_view_;
203
204 Workspace2* active_workspace_;
205
206 // The set of active workspaces. There is always at least one in this stack,
207 // which identifies the desktop.
208 Workspaces workspaces_;
209
210 // The set of workspaces not currently active. Workspaces ended up here in
211 // two scenarios:
212 // . Prior to adding a window a new worskpace is created for it. The
213 // Workspace is added to this set.
214 // . When the maximized window is minimized the workspace is added here.
215 // Once any window in the workspace is activated the workspace is moved to
216 // |workspaces_|.
217 std::set<Workspace2*> pending_workspaces_;
218
219 // Owned by the Shell. May be NULL.
220 ShelfLayoutManager* shelf_;
221
222 // Whether or not we're in MoveWorkspaceToPendingOrDelete(). As
223 // MoveWorkspaceToPendingOrDelete() may trigger another call to
224 // MoveWorkspaceToPendingOrDelete() we use this to avoid doing anything if
225 // already in MoveWorkspaceToPendingOrDelete().
226 bool in_move_;
227
228 // Ideally we would delete workspaces when not needed. Unfortunately doing so
229 // would effectively cancel animations. Instead when a workspace is no longer
230 // needed we add it here and start a timer. When the timer fires any windows
231 // no longer contain layers are deleted.
232 std::set<Workspace2*> to_delete_;
233 base::OneShotTimer<WorkspaceManager2> delete_timer_;
234
235 // See comments in SetUnminimizingWorkspace() for details.
236 base::WeakPtrFactory<WorkspaceManager2> clear_unminimizing_workspace_factory_;
237
238 // See comments in SetUnminimizingWorkspace() for details.
239 Workspace2* unminimizing_workspace_;
240
241 // Set to true if the app is terminating. If true we don't animate the
242 // background, otherwise it can get stuck in the fading position when chrome
243 // exits (as the last frame we draw before exiting is a frame from the
244 // animation).
245 bool app_terminating_;
246
247 scoped_ptr<DesktopBackgroundFadeController> desktop_fade_controller_;
248
249 // Set to true while in the process of creating a
250 // DesktopBackgroundFadeController.
251 bool creating_fade_;
252
253 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager2);
254 };
255
256 } // namespace internal
257 } // namespace ash
258
259 #endif // ASH_WM_WORKSPACE_WORKSPACE_MANAGER2_H_
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_manager.cc ('k') | ash/wm/workspace/workspace_manager2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698