| OLD | NEW |
| (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_MANAGER_H_ | |
| 6 #define ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "ash/ash_export.h" | |
| 11 #include "ash/wm/workspace/base_workspace_manager.h" | |
| 12 #include "ash/wm/workspace/workspace.h" | |
| 13 #include "ash/wm/workspace/workspace_types.h" | |
| 14 #include "base/basictypes.h" | |
| 15 #include "base/compiler_specific.h" | |
| 16 #include "ui/gfx/insets.h" | |
| 17 #include "ui/gfx/size.h" | |
| 18 | |
| 19 namespace aura { | |
| 20 class Window; | |
| 21 } | |
| 22 | |
| 23 namespace gfx { | |
| 24 class Point; | |
| 25 class Rect; | |
| 26 } | |
| 27 | |
| 28 namespace ash { | |
| 29 namespace internal { | |
| 30 | |
| 31 class ShelfLayoutManager; | |
| 32 class WorkspaceManagerTest; | |
| 33 | |
| 34 // WorkspaceManager manages multiple workspaces in the desktop. | |
| 35 class ASH_EXPORT WorkspaceManager : public BaseWorkspaceManager { | |
| 36 public: | |
| 37 explicit WorkspaceManager(aura::Window* viewport); | |
| 38 virtual ~WorkspaceManager(); | |
| 39 | |
| 40 // Returns true if |window| should be managed by the WorkspaceManager. Use | |
| 41 // Contains() to test if the Window is currently managed by WorkspaceManager. | |
| 42 static bool ShouldManageWindow(aura::Window* window); | |
| 43 | |
| 44 // Returns true if |window| has been added to this WorkspaceManager. | |
| 45 bool Contains(aura::Window* window) const; | |
| 46 | |
| 47 // Adds/removes a window creating/destroying workspace as necessary. | |
| 48 void AddWindow(aura::Window* window); | |
| 49 void RemoveWindow(aura::Window* window); | |
| 50 | |
| 51 // Returns the Window this WorkspaceManager controls. | |
| 52 aura::Window* contents_view() { return contents_view_; } | |
| 53 | |
| 54 // Updates the visibility and whether any windows overlap the shelf. | |
| 55 void UpdateShelfVisibility(); | |
| 56 | |
| 57 // Invoked when the show state of the specified window changes. | |
| 58 void ShowStateChanged(aura::Window* window); | |
| 59 | |
| 60 // BaseWorkspaceManager overrides: | |
| 61 virtual bool IsInMaximizedMode() const OVERRIDE; | |
| 62 virtual WorkspaceWindowState GetWindowState() const OVERRIDE; | |
| 63 virtual void SetShelf(ShelfLayoutManager* shelf) OVERRIDE; | |
| 64 virtual void SetActiveWorkspaceByWindow(aura::Window* window) OVERRIDE; | |
| 65 virtual aura::Window* GetParentForNewWindow(aura::Window* window) OVERRIDE; | |
| 66 virtual void DoInitialAnimation() OVERRIDE {} | |
| 67 | |
| 68 private: | |
| 69 // Enumeration of whether windows should animate or not. | |
| 70 enum AnimateChangeType { | |
| 71 ANIMATE, | |
| 72 DONT_ANIMATE | |
| 73 }; | |
| 74 | |
| 75 friend class Workspace; | |
| 76 friend class WorkspaceManagerTest; | |
| 77 | |
| 78 void AddWorkspace(Workspace* workspace); | |
| 79 void RemoveWorkspace(Workspace* workspace); | |
| 80 | |
| 81 // Sets the visibility of the windows in |workspace|. | |
| 82 void SetVisibilityOfWorkspaceWindows(Workspace* workspace, | |
| 83 AnimateChangeType change_type, | |
| 84 bool value); | |
| 85 | |
| 86 // Implementation of SetVisibilityOfWorkspaceWindows(). | |
| 87 void SetWindowLayerVisibility(const std::vector<aura::Window*>& windows, | |
| 88 AnimateChangeType change_type, | |
| 89 bool value); | |
| 90 | |
| 91 // Returns the active workspace. | |
| 92 Workspace* GetActiveWorkspace() const; | |
| 93 | |
| 94 // Returns the workspace that contanis the |window|. | |
| 95 Workspace* FindBy(aura::Window* window) const; | |
| 96 | |
| 97 // Sets the active workspace. | |
| 98 void SetActiveWorkspace(Workspace* workspace); | |
| 99 | |
| 100 // Returns the bounds of the work area. | |
| 101 gfx::Rect GetWorkAreaBounds() const; | |
| 102 | |
| 103 // Returns the index of the workspace that contains the |window|. | |
| 104 int GetWorkspaceIndexContaining(aura::Window* window) const; | |
| 105 | |
| 106 // Sets the bounds of |window|. This sets |ignored_window_| to |window| so | |
| 107 // that the bounds change is allowed through. | |
| 108 void SetWindowBounds(aura::Window* window, const gfx::Rect& bounds); | |
| 109 | |
| 110 // Invoked when the type of workspace needed for |window| changes. | |
| 111 void OnTypeOfWorkspacedNeededChanged(aura::Window* window); | |
| 112 | |
| 113 // Returns the Workspace whose type is TYPE_MANAGED, or NULL if there isn't | |
| 114 // one. | |
| 115 Workspace* GetManagedWorkspace(); | |
| 116 | |
| 117 // Creates a new workspace of the specified type. | |
| 118 Workspace* CreateWorkspace(Workspace::Type type); | |
| 119 | |
| 120 // Deletes workspaces of TYPE_MAXIMIZED when they become empty. | |
| 121 void CleanupWorkspace(Workspace* workspace); | |
| 122 | |
| 123 aura::Window* contents_view_; | |
| 124 | |
| 125 Workspace* active_workspace_; | |
| 126 | |
| 127 std::vector<Workspace*> workspaces_; | |
| 128 | |
| 129 // Window being maximized or restored during a workspace type change. | |
| 130 // It has its own animation and is ignored by workspace show/hide animations. | |
| 131 aura::Window* maximize_restore_window_; | |
| 132 | |
| 133 // See description above setter. | |
| 134 int grid_size_; | |
| 135 | |
| 136 // Owned by the Shell container window LauncherContainer. May be NULL. | |
| 137 ShelfLayoutManager* shelf_; | |
| 138 | |
| 139 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager); | |
| 140 }; | |
| 141 | |
| 142 } // namespace internal | |
| 143 } // namespace ash | |
| 144 | |
| 145 #endif // ASH_WM_WORKSPACE_WORKSPACE_MANAGER_H_ | |
| OLD | NEW |