Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_MANAGER_H_ | 5 #ifndef ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_ |
| 6 #define ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_ | 6 #define ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 class Workspace; | 46 class Workspace; |
| 47 | 47 |
| 48 // WorkspaceManager manages multiple workspaces in the desktop. Workspaces are | 48 // WorkspaceManager manages multiple workspaces in the desktop. Workspaces are |
| 49 // implicitly created as windows are maximized (or made fullscreen), and | 49 // implicitly created as windows are maximized (or made fullscreen), and |
| 50 // 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 |
| 51 // workspace for the desktop. | 51 // workspace for the desktop. |
| 52 // Internally WorkspaceManager creates a Window for each Workspace. As windows | 52 // Internally WorkspaceManager creates a Window for each Workspace. As windows |
| 53 // are maximized and restored they are reparented to the right Window. | 53 // are maximized and restored they are reparented to the right Window. |
| 54 class ASH_EXPORT WorkspaceManager : public ash::ShellObserver { | 54 class ASH_EXPORT WorkspaceManager : public ash::ShellObserver { |
| 55 public: | 55 public: |
| 56 | |
|
sky
2012/11/28 15:15:34
remove newline.
| |
| 57 enum Direction { | |
| 58 WORKSPACE_ABOVE, | |
|
sky
2012/11/28 15:15:34
Above and below are not clear in this content. How
| |
| 59 WORKSPACE_BELOW | |
| 60 }; | |
| 61 | |
| 56 explicit WorkspaceManager(aura::Window* viewport); | 62 explicit WorkspaceManager(aura::Window* viewport); |
| 57 virtual ~WorkspaceManager(); | 63 virtual ~WorkspaceManager(); |
| 58 | 64 |
| 59 // Returns true if |window| is considered maximized and should exist in its | 65 // Returns true if |window| is considered maximized and should exist in its |
| 60 // own workspace. | 66 // own workspace. |
| 61 static bool IsMaximized(aura::Window* window); | 67 static bool IsMaximized(aura::Window* window); |
| 62 static bool IsMaximizedState(ui::WindowShowState state); | 68 static bool IsMaximizedState(ui::WindowShowState state); |
| 63 | 69 |
| 64 // Returns true if |window| is minimized and will restore to a maximized | 70 // Returns true if |window| is minimized and will restore to a maximized |
| 65 // window. | 71 // window. |
| 66 static bool WillRestoreMaximized(aura::Window* window); | 72 static bool WillRestoreMaximized(aura::Window* window); |
| 67 | 73 |
| 68 // Returns the current window state. | 74 // Returns the current window state. |
| 69 WorkspaceWindowState GetWindowState() const; | 75 WorkspaceWindowState GetWindowState() const; |
| 70 | 76 |
| 71 void SetShelf(ShelfLayoutManager* shelf); | 77 void SetShelf(ShelfLayoutManager* shelf); |
| 72 | 78 |
| 73 // Activates the workspace containing |window|. Does nothing if |window| is | 79 // Activates the workspace containing |window|. Does nothing if |window| is |
| 74 // NULL or not contained in a workspace. | 80 // NULL or not contained in a workspace. |
| 75 void SetActiveWorkspaceByWindow(aura::Window* window); | 81 void SetActiveWorkspaceByWindow(aura::Window* window); |
| 76 | 82 |
| 77 // Returns the parent for |window|. This is invoked from StackingController | 83 // Returns the parent for |window|. This is invoked from StackingController |
| 78 // when a new Window is being added. | 84 // when a new Window is being added. |
| 79 aura::Window* GetParentForNewWindow(aura::Window* window); | 85 aura::Window* GetParentForNewWindow(aura::Window* window); |
| 80 | 86 |
| 87 // Called by the workspace cycler to activate the next workspace in | |
| 88 // |direction|. Returns false if there are no more workspaces to cycle | |
| 89 // to in |direction|. | |
| 90 bool CycleToWorkspace(Direction direction); | |
| 91 | |
| 81 // Starts the animation that occurs on first login. | 92 // Starts the animation that occurs on first login. |
| 82 void DoInitialAnimation(); | 93 void DoInitialAnimation(); |
| 83 | 94 |
| 95 // Returns the window of the currently active workspace. | |
| 96 aura::Window* GetActiveWorkspaceWindow() const; | |
|
sky
2012/11/28 15:15:34
Should either return const or not be const.
| |
| 97 | |
| 84 // ShellObserver overrides: | 98 // ShellObserver overrides: |
| 85 virtual void OnAppTerminating() OVERRIDE; | 99 virtual void OnAppTerminating() OVERRIDE; |
| 86 | 100 |
| 87 private: | 101 private: |
| 88 friend class WorkspaceLayoutManager; | 102 friend class WorkspaceLayoutManager; |
| 89 friend class WorkspaceManagerTest; | 103 friend class WorkspaceManagerTest; |
| 90 | 104 |
| 91 class LayoutManagerImpl; | 105 class LayoutManagerImpl; |
| 92 | 106 |
| 93 typedef std::vector<Workspace*> Workspaces; | 107 typedef std::vector<Workspace*> Workspaces; |
| 94 | 108 |
| 95 // Reason for the workspace switch. Used to determine the characterstics of | 109 // Reason for the workspace switch. Used to determine the characterstics of |
| 96 // the animation. | 110 // the animation. |
| 97 enum SwitchReason { | 111 enum SwitchReason { |
| 98 SWITCH_WINDOW_MADE_ACTIVE, | 112 SWITCH_WINDOW_MADE_ACTIVE, |
| 99 SWITCH_WINDOW_REMOVED, | 113 SWITCH_WINDOW_REMOVED, |
| 100 SWITCH_VISIBILITY_CHANGED, | 114 SWITCH_VISIBILITY_CHANGED, |
| 101 SWITCH_MINIMIZED, | 115 SWITCH_MINIMIZED, |
| 102 SWITCH_MAXIMIZED_OR_RESTORED, | 116 SWITCH_MAXIMIZED_OR_RESTORED, |
| 103 SWITCH_TRACKED_BY_WORKSPACE_CHANGED, | 117 SWITCH_TRACKED_BY_WORKSPACE_CHANGED, |
| 104 | 118 |
| 105 // Switch as the result of DoInitialAnimation(). This isn't a real switch, | 119 // Switch as the result of DoInitialAnimation(). This isn't a real switch, |
| 106 // rather we run the animations as if a switch occurred. | 120 // rather we run the animations as if a switch occurred. |
| 107 SWITCH_INITIAL, | 121 SWITCH_INITIAL, |
| 108 | 122 |
| 123 // Switch as the result of cycling through workspaces. | |
| 124 SWITCH_CYCLE_WORKSPACE, | |
| 125 | |
| 109 // Edge case. See comment in OnWorkspaceWindowShowStateChanged(). Don't | 126 // Edge case. See comment in OnWorkspaceWindowShowStateChanged(). Don't |
| 110 // make other types randomly use this! | 127 // make other types randomly use this! |
| 111 SWITCH_OTHER, | 128 SWITCH_OTHER, |
| 112 }; | 129 }; |
| 113 | 130 |
| 114 // Updates the visibility and whether any windows overlap the shelf. | 131 // Updates the visibility and whether any windows overlap the shelf. |
| 115 void UpdateShelfVisibility(); | 132 void UpdateShelfVisibility(); |
| 116 | 133 |
| 117 // Returns the workspace that contains |window|. | 134 // Returns the workspace that contains |window|. |
| 118 Workspace* FindBy(aura::Window* window) const; | 135 Workspace* FindBy(aura::Window* window) const; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 140 // if |workspace| contains no children it is deleted, otherwise it it moved to | 157 // if |workspace| contains no children it is deleted, otherwise it it moved to |
| 141 // |pending_workspaces_|. | 158 // |pending_workspaces_|. |
| 142 void MoveWorkspaceToPendingOrDelete(Workspace* workspace, | 159 void MoveWorkspaceToPendingOrDelete(Workspace* workspace, |
| 143 aura::Window* stack_beneath, | 160 aura::Window* stack_beneath, |
| 144 SwitchReason reason); | 161 SwitchReason reason); |
| 145 | 162 |
| 146 // Moves the children of |window| to the desktop. This excludes certain | 163 // 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. | 164 // windows. If |stack_beneath| is non-NULL the windows are stacked beneath it. |
| 148 void MoveChildrenToDesktop(aura::Window* window, aura::Window* stack_beneath); | 165 void MoveChildrenToDesktop(aura::Window* window, aura::Window* stack_beneath); |
| 149 | 166 |
| 150 // Selects the next workspace. | 167 // Selects the workspace below the active workspace if any. |
| 151 void SelectNextWorkspace(SwitchReason reason); | 168 void SelectWorkspaceBelow(SwitchReason reason); |
|
sky
2012/11/28 15:15:34
Keep the old name, its clearer since below doesn't
| |
| 152 | 169 |
| 153 // Schedules |workspace| for deletion when it no longer contains any layers. | 170 // Schedules |workspace| for deletion when it no longer contains any layers. |
| 154 // See comments above |to_delete_| as to why we do this. | 171 // See comments above |to_delete_| as to why we do this. |
| 155 void ScheduleDelete(Workspace* workspace); | 172 void ScheduleDelete(Workspace* workspace); |
| 156 | 173 |
| 157 // Deletes any workspaces scheduled via ScheduleDelete() that don't contain | 174 // Deletes any workspaces scheduled via ScheduleDelete() that don't contain |
| 158 // any layers. | 175 // any layers. |
| 159 void ProcessDeletion(); | 176 void ProcessDeletion(); |
| 160 | 177 |
| 161 // Sets |unminimizing_workspace_| to |workspace|. | 178 // Sets |unminimizing_workspace_| to |workspace|. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 // DesktopBackgroundFadeController. | 267 // DesktopBackgroundFadeController. |
| 251 bool creating_fade_; | 268 bool creating_fade_; |
| 252 | 269 |
| 253 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager); | 270 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager); |
| 254 }; | 271 }; |
| 255 | 272 |
| 256 } // namespace internal | 273 } // namespace internal |
| 257 } // namespace ash | 274 } // namespace ash |
| 258 | 275 |
| 259 #endif // ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_ | 276 #endif // ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_ |
| OLD | NEW |