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

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

Issue 11106003: Tweaks workspace animation code per latest from Nicholas. Additionally (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to trunk Created 8 years, 2 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/workspace_animations.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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_WM_WORKSPACE_WORKSPACE_MANAGER2_H_ 5 #ifndef ASH_WM_WORKSPACE_WORKSPACE_MANAGER2_H_
6 #define ASH_WM_WORKSPACE_WORKSPACE_MANAGER2_H_ 6 #define ASH_WM_WORKSPACE_WORKSPACE_MANAGER2_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "ash/ash_export.h" 12 #include "ash/ash_export.h"
13 #include "ash/shell_observer.h" 13 #include "ash/shell_observer.h"
14 #include "ash/wm/workspace/base_workspace_manager.h" 14 #include "ash/wm/workspace/base_workspace_manager.h"
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/time.h" 18 #include "base/time.h"
19 #include "base/timer.h" 19 #include "base/timer.h"
20 #include "ui/base/ui_base_types.h" 20 #include "ui/base/ui_base_types.h"
21 21
22 namespace aura { 22 namespace aura {
23 class Window; 23 class Window;
24 } 24 }
25 25
26 namespace base {
27 class TimeDelta;
28 }
29
26 namespace gfx { 30 namespace gfx {
27 class Point; 31 class Point;
28 class Rect; 32 class Rect;
29 } 33 }
30 34
31 namespace ui { 35 namespace ui {
32 class Layer; 36 class Layer;
33 } 37 }
34 38
35 namespace ash { 39 namespace ash {
36 namespace internal { 40 namespace internal {
37 41
42 class DesktopBackgroundFadeController;
38 class ShelfLayoutManager; 43 class ShelfLayoutManager;
39 class WorkspaceLayoutManager2; 44 class WorkspaceLayoutManager2;
40 class WorkspaceManagerTest2; 45 class WorkspaceManagerTest2;
41 class Workspace2; 46 class Workspace2;
42 47
43 // WorkspaceManager manages multiple workspaces in the desktop. Workspaces are 48 // WorkspaceManager manages multiple workspaces in the desktop. Workspaces are
44 // implicitly created as windows are maximized (or made fullscreen), and 49 // implicitly created as windows are maximized (or made fullscreen), and
45 // destroyed when maximized windows are closed or restored. There is always one 50 // destroyed when maximized windows are closed or restored. There is always one
46 // workspace for the desktop. 51 // workspace for the desktop.
47 // Internally WorkspaceManager2 creates a Window for each Workspace. As windows 52 // Internally WorkspaceManager2 creates a Window for each Workspace. As windows
(...skipping 22 matching lines...) Expand all
70 virtual aura::Window* GetParentForNewWindow(aura::Window* window) OVERRIDE; 75 virtual aura::Window* GetParentForNewWindow(aura::Window* window) OVERRIDE;
71 virtual void DoInitialAnimation() OVERRIDE; 76 virtual void DoInitialAnimation() OVERRIDE;
72 77
73 // ShellObserver overrides: 78 // ShellObserver overrides:
74 virtual void OnAppTerminating() OVERRIDE; 79 virtual void OnAppTerminating() OVERRIDE;
75 80
76 private: 81 private:
77 friend class WorkspaceLayoutManager2; 82 friend class WorkspaceLayoutManager2;
78 friend class WorkspaceManager2Test; 83 friend class WorkspaceManager2Test;
79 84
80 class LayoutManager; 85 class LayoutManagerImpl;
81 86
82 typedef std::vector<Workspace2*> Workspaces; 87 typedef std::vector<Workspace2*> Workspaces;
83 88
84 // Describes which, if any, of the workspaces should animate. NEW is the 89 // Reason for the workspace switch. Used to determine the characterstics of
85 // workspace that is becoming active, and OLD the workspace that was active. 90 // the animation.
86 enum AnimateType { 91 enum SwitchReason {
87 ANIMATE_NONE, 92 SWITCH_WINDOW_MADE_ACTIVE,
93 SWITCH_WINDOW_REMOVED,
94 SWITCH_VISIBILITY_CHANGED,
95 SWITCH_MINIMIZED,
96 SWITCH_MAXIMIZED_OR_RESTORED,
97 SWITCH_TRACKED_BY_WORKSPACE_CHANGED,
88 98
89 // Animates only the new workspace in. 99 // Switch as the result of DoInitialAnimation(). This isn't a real switch,
90 ANIMATE_NEW, 100 // rather we run the animations as if a switch occurred.
101 SWITCH_INITIAL,
91 102
92 // Animates both the old and new workspaces. 103 // Edge case. See comment in OnWorkspaceWindowShowStateChanged(). Don't
93 ANIMATE_OLD_AND_NEW, 104 // make other types randomly use this!
105 SWITCH_OTHER,
94 }; 106 };
95 107
96 // Updates the visibility and whether any windows overlap the shelf. 108 // Updates the visibility and whether any windows overlap the shelf.
97 void UpdateShelfVisibility(); 109 void UpdateShelfVisibility();
98 110
99 // Returns the workspace that contains |window|. 111 // Returns the workspace that contains |window|.
100 Workspace2* FindBy(aura::Window* window) const; 112 Workspace2* FindBy(aura::Window* window) const;
101 113
102 // Sets the active workspace. 114 // Sets the active workspace.
103 void SetActiveWorkspace(Workspace2* workspace, AnimateType animate_type); 115 void SetActiveWorkspace(Workspace2* workspace,
116 SwitchReason reason,
117 base::TimeDelta duration);
104 118
105 // Returns the bounds of the work area. 119 // Returns the bounds of the work area.
106 gfx::Rect GetWorkAreaBounds() const; 120 gfx::Rect GetWorkAreaBounds() const;
107 121
108 // Returns an iterator into |workspaces_| for |workspace|. 122 // Returns an iterator into |workspaces_| for |workspace|.
109 Workspaces::iterator FindWorkspace(Workspace2* workspace); 123 Workspaces::iterator FindWorkspace(Workspace2* workspace);
110 124
111 Workspace2* desktop_workspace() { return workspaces_[0]; } 125 Workspace2* desktop_workspace() { return workspaces_[0]; }
112 const Workspace2* desktop_workspace() const { return workspaces_[0]; } 126 const Workspace2* desktop_workspace() const { return workspaces_[0]; }
113 127
114 // Creates a new workspace. The Workspace is not added to anything and is 128 // Creates a new workspace. The Workspace is not added to anything and is
115 // owned by the caller. 129 // owned by the caller.
116 Workspace2* CreateWorkspace(bool maximized); 130 Workspace2* CreateWorkspace(bool maximized);
117 131
118 // Moves all the non-maximized child windows of |workspace| to the desktop 132 // Moves all the non-maximized child windows of |workspace| to the desktop
119 // stacked beneath |stack_beneath| (if non-NULL). After moving child windows 133 // stacked beneath |stack_beneath| (if non-NULL). After moving child windows
120 // if |workspace| contains no children it is deleted, otherwise it it moved to 134 // if |workspace| contains no children it is deleted, otherwise it it moved to
121 // |pending_workspaces_|. 135 // |pending_workspaces_|.
122 void MoveWorkspaceToPendingOrDelete(Workspace2* workspace, 136 void MoveWorkspaceToPendingOrDelete(Workspace2* workspace,
123 aura::Window* stack_beneath, 137 aura::Window* stack_beneath,
124 AnimateType animate_type); 138 SwitchReason reason);
125 139
126 // Moves the children of |window| to the desktop. This excludes certain 140 // Moves the children of |window| to the desktop. This excludes certain
127 // windows. If |stack_beneath| is non-NULL the windows are stacked beneath it. 141 // windows. If |stack_beneath| is non-NULL the windows are stacked beneath it.
128 void MoveChildrenToDesktop(aura::Window* window, aura::Window* stack_beneath); 142 void MoveChildrenToDesktop(aura::Window* window, aura::Window* stack_beneath);
129 143
130 // Selects the next workspace. 144 // Selects the next workspace.
131 void SelectNextWorkspace(AnimateType animate_type); 145 void SelectNextWorkspace(SwitchReason reason);
132 146
133 // Schedules |workspace| for deletion when it no longer contains any layers. 147 // Schedules |workspace| for deletion when it no longer contains any layers.
134 // See comments above |to_delete_| as to why we do this. 148 // See comments above |to_delete_| as to why we do this.
135 void ScheduleDelete(Workspace2* workspace); 149 void ScheduleDelete(Workspace2* workspace);
136 150
137 // Deletes any workspaces scheduled via ScheduleDelete() that don't contain 151 // Deletes any workspaces scheduled via ScheduleDelete() that don't contain
138 // any layers. 152 // any layers.
139 void ProcessDeletion(); 153 void ProcessDeletion();
140 154
141 // Sets |unminimizing_workspace_| to |workspace|. 155 // Sets |unminimizing_workspace_| to |workspace|.
142 void SetUnminimizingWorkspace(Workspace2* workspace); 156 void SetUnminimizingWorkspace(Workspace2* workspace);
143 157
158 // Fades the desktop. This is only used when maximizing or restoring a
159 // window. The actual fade is handled by
160 // DesktopBackgroundFadeController. |window| is used when restoring and
161 // indicates the window to stack the DesktopBackgroundFadeController's window
162 // above.
163 void FadeDesktop(aura::Window* window, base::TimeDelta duration);
164
165 // Shows or hides the desktop Window |window|.
166 void ShowOrHideDesktopBackground(aura::Window* window,
167 SwitchReason reason,
168 base::TimeDelta duration,
169 bool show) const;
170
171 // Shows/hides |workspace| animating as necessary.
172 void ShowWorkspace(Workspace2* workspace,
173 Workspace2* last_active,
174 SwitchReason reason) const;
175 void HideWorkspace(Workspace2* workspace,
176 SwitchReason reason,
177 bool is_unminimizing_maximized_window) const;
178
144 // These methods are forwarded from the LayoutManager installed on the 179 // These methods are forwarded from the LayoutManager installed on the
145 // Workspace's window. 180 // Workspace's window.
146 void OnWindowAddedToWorkspace(Workspace2* workspace, aura::Window* child); 181 void OnWindowAddedToWorkspace(Workspace2* workspace, aura::Window* child);
147 void OnWillRemoveWindowFromWorkspace(Workspace2* workspace, 182 void OnWillRemoveWindowFromWorkspace(Workspace2* workspace,
148 aura::Window* child); 183 aura::Window* child);
149 void OnWindowRemovedFromWorkspace(Workspace2* workspace, aura::Window* child); 184 void OnWindowRemovedFromWorkspace(Workspace2* workspace, aura::Window* child);
150 void OnWorkspaceChildWindowVisibilityChanged(Workspace2* workspace, 185 void OnWorkspaceChildWindowVisibilityChanged(Workspace2* workspace,
151 aura::Window* child); 186 aura::Window* child);
152 void OnWorkspaceWindowChildBoundsChanged(Workspace2* workspace, 187 void OnWorkspaceWindowChildBoundsChanged(Workspace2* workspace,
153 aura::Window* child); 188 aura::Window* child);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 231
197 // See comments in SetUnminimizingWorkspace() for details. 232 // See comments in SetUnminimizingWorkspace() for details.
198 Workspace2* unminimizing_workspace_; 233 Workspace2* unminimizing_workspace_;
199 234
200 // Set to true if the app is terminating. If true we don't animate the 235 // Set to true if the app is terminating. If true we don't animate the
201 // background, otherwise it can get stuck in the fading position when chrome 236 // background, otherwise it can get stuck in the fading position when chrome
202 // exits (as the last frame we draw before exiting is a frame from the 237 // exits (as the last frame we draw before exiting is a frame from the
203 // animation). 238 // animation).
204 bool app_terminating_; 239 bool app_terminating_;
205 240
206 // If non-empty this is the amount of time animating the desktop in/out. 241 scoped_ptr<DesktopBackgroundFadeController> desktop_fade_controller_;
207 base::TimeDelta switch_duration_; 242
243 // Set to true while in the process of creating a
244 // DesktopBackgroundFadeController.
245 bool creating_fade_;
208 246
209 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager2); 247 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager2);
210 }; 248 };
211 249
212 } // namespace internal 250 } // namespace internal
213 } // namespace ash 251 } // namespace ash
214 252
215 #endif // ASH_WM_WORKSPACE_WORKSPACE_MANAGER2_H_ 253 #endif // ASH_WM_WORKSPACE_WORKSPACE_MANAGER2_H_
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_animations.cc ('k') | ash/wm/workspace/workspace_manager2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698