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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 void SetShelf(ShelfLayoutManager* shelf); | 71 void SetShelf(ShelfLayoutManager* shelf); |
| 72 | 72 |
| 73 // Activates the workspace containing |window|. Does nothing if |window| is | 73 // Activates the workspace containing |window|. Does nothing if |window| is |
| 74 // NULL or not contained in a workspace. | 74 // NULL or not contained in a workspace. |
| 75 void SetActiveWorkspaceByWindow(aura::Window* window); | 75 void SetActiveWorkspaceByWindow(aura::Window* window); |
| 76 | 76 |
| 77 // Returns the parent for |window|. This is invoked from StackingController | 77 // Returns the parent for |window|. This is invoked from StackingController |
| 78 // when a new Window is being added. | 78 // when a new Window is being added. |
| 79 aura::Window* GetParentForNewWindow(aura::Window* window); | 79 aura::Window* GetParentForNewWindow(aura::Window* window); |
| 80 | 80 |
| 81 // Called by the workspace cycler to hide the active workspace and activate | |
| 82 // the next visible workspace. The active workspace is moved to | |
| 83 // |hidden_workspaces_|. | |
| 84 // Returns false if the active workspace is the desktop workspace which | |
| 85 // cannot be hidden. | |
| 86 bool CycleToNextVisibleWorkspace(); | |
| 87 | |
| 88 // Called by the workspace cycler to activate the workspace in | |
| 89 // |hidden_workspaces_| which was most recently added. Activating the | |
| 90 // workspace moves it to |workspaces_|. | |
| 91 // Returns false if |hidden_workspaces| is empty. | |
| 92 bool CycleToNextHiddenWorkspace(); | |
| 93 | |
| 81 // Starts the animation that occurs on first login. | 94 // Starts the animation that occurs on first login. |
| 82 void DoInitialAnimation(); | 95 void DoInitialAnimation(); |
| 83 | 96 |
| 97 // Returns the window of the currently active workspace. | |
| 98 aura::Window* GetActiveWorkspaceWindow() const; | |
| 99 | |
| 84 // ShellObserver overrides: | 100 // ShellObserver overrides: |
| 85 virtual void OnAppTerminating() OVERRIDE; | 101 virtual void OnAppTerminating() OVERRIDE; |
| 86 | 102 |
| 87 private: | 103 private: |
| 88 friend class WorkspaceLayoutManager; | 104 friend class WorkspaceLayoutManager; |
| 89 friend class WorkspaceManagerTest; | 105 friend class WorkspaceManagerTest; |
| 90 | 106 |
| 91 class LayoutManagerImpl; | 107 class LayoutManagerImpl; |
| 92 | 108 |
| 93 typedef std::vector<Workspace*> Workspaces; | 109 typedef std::vector<Workspace*> Workspaces; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 | 146 |
| 131 Workspace* desktop_workspace() { return workspaces_[0]; } | 147 Workspace* desktop_workspace() { return workspaces_[0]; } |
| 132 const Workspace* desktop_workspace() const { return workspaces_[0]; } | 148 const Workspace* desktop_workspace() const { return workspaces_[0]; } |
| 133 | 149 |
| 134 // Creates a new workspace. The Workspace is not added to anything and is | 150 // Creates a new workspace. The Workspace is not added to anything and is |
| 135 // owned by the caller. | 151 // owned by the caller. |
| 136 Workspace* CreateWorkspace(bool maximized); | 152 Workspace* CreateWorkspace(bool maximized); |
| 137 | 153 |
| 138 // Moves all the non-maximized child windows of |workspace| to the desktop | 154 // Moves all the non-maximized child windows of |workspace| to the desktop |
| 139 // stacked beneath |stack_beneath| (if non-NULL). After moving child windows | 155 // 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 | 156 // if |workspace| contains no children it is deleted. Otherwise, it is moved |
| 141 // |pending_workspaces_|. | 157 // to |hidden_workspaces_|. |
| 142 void MoveWorkspaceToPendingOrDelete(Workspace* workspace, | 158 void MoveWorkspaceToHiddenOrDelete(Workspace* workspace, |
|
sky
2012/11/26 23:20:49
Since all but one of the windows in workspaces_ is
| |
| 143 aura::Window* stack_beneath, | 159 aura::Window* stack_beneath, |
| 144 SwitchReason reason); | 160 SwitchReason reason); |
| 145 | 161 |
| 146 // Moves the children of |window| to the desktop. This excludes certain | 162 // 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. | 163 // windows. If |stack_beneath| is non-NULL the windows are stacked beneath it. |
| 148 void MoveChildrenToDesktop(aura::Window* window, aura::Window* stack_beneath); | 164 void MoveChildrenToDesktop(aura::Window* window, aura::Window* stack_beneath); |
| 149 | 165 |
| 150 // Selects the next workspace. | 166 // Selects the next workspace. |
| 151 void SelectNextWorkspace(SwitchReason reason); | 167 void SelectNextWorkspace(SwitchReason reason); |
| 152 | 168 |
| 153 // Schedules |workspace| for deletion when it no longer contains any layers. | 169 // Schedules |workspace| for deletion when it no longer contains any layers. |
| 154 // See comments above |to_delete_| as to why we do this. | 170 // See comments above |to_delete_| as to why we do this. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 aura::Window* child, | 212 aura::Window* child, |
| 197 ui::WindowShowState last_show_state, | 213 ui::WindowShowState last_show_state, |
| 198 ui::Layer* old_layer); | 214 ui::Layer* old_layer); |
| 199 void OnTrackedByWorkspaceChanged(Workspace* workspace, | 215 void OnTrackedByWorkspaceChanged(Workspace* workspace, |
| 200 aura::Window* window); | 216 aura::Window* window); |
| 201 | 217 |
| 202 aura::Window* contents_view_; | 218 aura::Window* contents_view_; |
| 203 | 219 |
| 204 Workspace* active_workspace_; | 220 Workspace* active_workspace_; |
| 205 | 221 |
| 206 // The set of active workspaces. There is always at least one in this stack, | 222 // The set of visible workspaces. There is always at least one in this stack, |
| 207 // which identifies the desktop. | 223 // which identifies the desktop. |
| 208 Workspaces workspaces_; | 224 Workspaces workspaces_; |
| 209 | 225 |
| 210 // The set of workspaces not currently active. Workspaces ended up here in | 226 // List of inactive workspaces which were deactivated as a result of a user |
| 211 // two scenarios: | 227 // action. Workspaces are moved here from |workspaces_| when the workspace's |
| 212 // . Prior to adding a window a new worskpace is created for it. The | 228 // maximized window is minimized or hidden. The workspace is moved back to |
| 213 // Workspace is added to this set. | 229 // |workspaces_| when one of its windows is activated. |
| 214 // . When the maximized window is minimized the workspace is added here. | 230 Workspaces hidden_workspaces_; |
| 231 | |
| 232 // Set of workspaces that have never been activated. Workspaces for new | |
| 233 // windows prior to those windows being activated are added to this set. | |
| 215 // Once any window in the workspace is activated the workspace is moved to | 234 // Once any window in the workspace is activated the workspace is moved to |
| 216 // |workspaces_|. | 235 // |workspaces_|. |
| 217 std::set<Workspace*> pending_workspaces_; | 236 std::set<Workspace*> pending_workspaces_; |
| 218 | 237 |
| 219 // Owned by the Shell. May be NULL. | 238 // Owned by the Shell. May be NULL. |
| 220 ShelfLayoutManager* shelf_; | 239 ShelfLayoutManager* shelf_; |
| 221 | 240 |
| 222 // Whether or not we're in MoveWorkspaceToPendingOrDelete(). As | 241 // Whether or not we're in MoveWorkspaceToHiddenOrDelete(). As |
| 223 // MoveWorkspaceToPendingOrDelete() may trigger another call to | 242 // MoveWorkspaceToHiddenOrDelete() may trigger another call to |
| 224 // MoveWorkspaceToPendingOrDelete() we use this to avoid doing anything if | 243 // MoveWorkspaceToHiddenOrDelete() we use this to avoid doing anything if |
| 225 // already in MoveWorkspaceToPendingOrDelete(). | 244 // already in MoveWorkspaceToHiddenOrDelete(). |
| 226 bool in_move_; | 245 bool in_move_; |
| 227 | 246 |
| 228 // Ideally we would delete workspaces when not needed. Unfortunately doing so | 247 // Ideally we would delete workspaces when not needed. Unfortunately doing so |
| 229 // would effectively cancel animations. Instead when a workspace is no longer | 248 // 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 | 249 // needed we add it here and start a timer. When the timer fires any windows |
| 231 // no longer contain layers are deleted. | 250 // no longer contain layers are deleted. |
| 232 std::set<Workspace*> to_delete_; | 251 std::set<Workspace*> to_delete_; |
| 233 base::OneShotTimer<WorkspaceManager> delete_timer_; | 252 base::OneShotTimer<WorkspaceManager> delete_timer_; |
| 234 | 253 |
| 235 // See comments in SetUnminimizingWorkspace() for details. | 254 // See comments in SetUnminimizingWorkspace() for details. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 250 // DesktopBackgroundFadeController. | 269 // DesktopBackgroundFadeController. |
| 251 bool creating_fade_; | 270 bool creating_fade_; |
| 252 | 271 |
| 253 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager); | 272 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager); |
| 254 }; | 273 }; |
| 255 | 274 |
| 256 } // namespace internal | 275 } // namespace internal |
| 257 } // namespace ash | 276 } // namespace ash |
| 258 | 277 |
| 259 #endif // ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_ | 278 #endif // ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_ |
| OLD | NEW |