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_LAYOUT_MANAGER_H_ | 5 #ifndef ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ |
6 #define ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ | 6 #define ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "ash/shell_observer.h" | |
13 #include "ash/wm/common/window_state_observer.h" | 12 #include "ash/wm/common/window_state_observer.h" |
| 13 #include "ash/wm/common/wm_activation_observer.h" |
| 14 #include "ash/wm/common/wm_layout_manager.h" |
| 15 #include "ash/wm/common/wm_root_window_controller_observer.h" |
14 #include "ash/wm/common/wm_types.h" | 16 #include "ash/wm/common/wm_types.h" |
15 #include "base/compiler_specific.h" | 17 #include "ash/wm/common/wm_window_observer.h" |
16 #include "base/macros.h" | 18 #include "base/macros.h" |
17 #include "ui/aura/layout_manager.h" | |
18 #include "ui/aura/window_observer.h" | |
19 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
20 #include "ui/keyboard/keyboard_controller_observer.h" | 20 #include "ui/keyboard/keyboard_controller_observer.h" |
21 #include "ui/wm/public/activation_change_observer.h" | |
22 | |
23 namespace aura { | |
24 class RootWindow; | |
25 class Window; | |
26 } | |
27 | |
28 namespace ui { | |
29 class Layer; | |
30 } | |
31 | 21 |
32 namespace ash { | 22 namespace ash { |
33 class WorkspaceLayoutManagerBackdropDelegate; | 23 class WorkspaceLayoutManagerBackdropDelegate; |
34 | 24 |
35 namespace wm { | 25 namespace wm { |
36 class WindowState; | 26 class WmGlobals; |
| 27 class WmRootWindowController; |
37 class WorkspaceLayoutManagerDelegate; | 28 class WorkspaceLayoutManagerDelegate; |
38 class WMEvent; | 29 class WMEvent; |
39 } | 30 } |
40 | 31 |
41 // LayoutManager used on the window created for a workspace. | 32 // LayoutManager used on the window created for a workspace. |
42 class ASH_EXPORT WorkspaceLayoutManager | 33 class ASH_EXPORT WorkspaceLayoutManager |
43 : public aura::LayoutManager, | 34 : public wm::WmLayoutManager, |
44 public aura::WindowObserver, | 35 public wm::WmWindowObserver, |
45 public aura::client::ActivationChangeObserver, | 36 public wm::WmActivationObserver, |
46 public keyboard::KeyboardControllerObserver, | 37 public keyboard::KeyboardControllerObserver, |
47 public ShellObserver, | 38 public wm::WmRootWindowControllerObserver, |
48 public wm::WindowStateObserver { | 39 public wm::WindowStateObserver { |
49 public: | 40 public: |
50 WorkspaceLayoutManager( | 41 WorkspaceLayoutManager( |
51 aura::Window* window, | 42 wm::WmWindow* window, |
52 std::unique_ptr<wm::WorkspaceLayoutManagerDelegate> delegate); | 43 std::unique_ptr<wm::WorkspaceLayoutManagerDelegate> delegate); |
53 | 44 |
54 ~WorkspaceLayoutManager() override; | 45 ~WorkspaceLayoutManager() override; |
55 | 46 |
56 void DeleteDelegate(); | 47 void DeleteDelegate(); |
57 | 48 |
58 // A delegate which can be set to add a backdrop behind the top most visible | 49 // A delegate which can be set to add a backdrop behind the top most visible |
59 // window. With the call the ownership of the delegate will be transferred to | 50 // window. With the call the ownership of the delegate will be transferred to |
60 // the WorkspaceLayoutManager. | 51 // the WorkspaceLayoutManager. |
61 void SetMaximizeBackdropDelegate( | 52 void SetMaximizeBackdropDelegate( |
62 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate); | 53 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate); |
63 | 54 |
64 // Overridden from aura::LayoutManager: | 55 // Overridden from wm::WmLayoutManager: |
65 void OnWindowResized() override {} | 56 void OnWindowResized() override; |
66 void OnWindowAddedToLayout(aura::Window* child) override; | 57 void OnWindowAddedToLayout(wm::WmWindow* child) override; |
67 void OnWillRemoveWindowFromLayout(aura::Window* child) override; | 58 void OnWillRemoveWindowFromLayout(wm::WmWindow* child) override; |
68 void OnWindowRemovedFromLayout(aura::Window* child) override; | 59 void OnWindowRemovedFromLayout(wm::WmWindow* child) override; |
69 void OnChildWindowVisibilityChanged(aura::Window* child, | 60 void OnChildWindowVisibilityChanged(wm::WmWindow* child, |
70 bool visibile) override; | 61 bool visibile) override; |
71 void SetChildBounds(aura::Window* child, | 62 void SetChildBounds(wm::WmWindow* child, |
72 const gfx::Rect& requested_bounds) override; | 63 const gfx::Rect& requested_bounds) override; |
73 | 64 |
74 // ash::ShellObserver overrides: | 65 // wm::WmRootWindowControllerObserver overrides: |
75 void OnDisplayWorkAreaInsetsChanged() override; | 66 void OnWorkAreaChanged() override; |
76 void OnFullscreenStateChanged(bool is_fullscreen, | 67 void OnFullscreenStateChanged(bool is_fullscreen) override; |
77 aura::Window* root_window) override; | |
78 | 68 |
79 // Overriden from WindowObserver: | 69 // Overriden from wm::WmWindowObserver: |
80 void OnWindowHierarchyChanged( | 70 void OnWindowTreeChanged( |
81 const WindowObserver::HierarchyChangeParams& params) override; | 71 wm::WmWindow* window, |
82 void OnWindowPropertyChanged(aura::Window* window, | 72 const wm::WmWindowObserver::TreeChangeParams& params) override; |
83 const void* key, | 73 void OnWindowPropertyChanged(wm::WmWindow* window, |
| 74 wm::WmWindowProperty property, |
84 intptr_t old) override; | 75 intptr_t old) override; |
85 void OnWindowStackingChanged(aura::Window* window) override; | 76 void OnWindowStackingChanged(wm::WmWindow* window) override; |
86 void OnWindowDestroying(aura::Window* window) override; | 77 void OnWindowDestroying(wm::WmWindow* window) override; |
87 void OnWindowBoundsChanged(aura::Window* window, | 78 void OnWindowBoundsChanged(wm::WmWindow* window, |
88 const gfx::Rect& old_bounds, | 79 const gfx::Rect& old_bounds, |
89 const gfx::Rect& new_bounds) override; | 80 const gfx::Rect& new_bounds) override; |
90 | 81 |
91 // aura::client::ActivationChangeObserver overrides: | 82 // wm::WmActivationObserver overrides: |
92 void OnWindowActivated( | 83 void OnWindowActivated(wm::WmWindow* gained_active, |
93 aura::client::ActivationChangeObserver::ActivationReason reason, | 84 wm::WmWindow* lost_active) override; |
94 aura::Window* gained_active, | |
95 aura::Window* lost_active) override; | |
96 | 85 |
97 // keyboard::KeyboardControllerObserver overrides: | 86 // keyboard::KeyboardControllerObserver overrides: |
98 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; | 87 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; |
99 | 88 |
100 // WindowStateObserver overrides: | 89 // WindowStateObserver overrides: |
101 void OnPostWindowStateTypeChange(wm::WindowState* window_state, | 90 void OnPostWindowStateTypeChange(wm::WindowState* window_state, |
102 wm::WindowStateType old_type) override; | 91 wm::WindowStateType old_type) override; |
103 | 92 |
104 private: | 93 private: |
105 typedef std::set<aura::Window*> WindowSet; | 94 typedef std::set<wm::WmWindow*> WindowSet; |
106 | 95 |
107 // Adjusts the bounds of all managed windows when the display area changes. | 96 // Adjusts the bounds of all managed windows when the display area changes. |
108 // This happens when the display size, work area insets has changed. | 97 // This happens when the display size, work area insets has changed. |
109 // If this is called for a display size change (i.e. |event| | 98 // If this is called for a display size change (i.e. |event| |
110 // is DISPLAY_RESIZED), the non-maximized/non-fullscreen | 99 // is DISPLAY_RESIZED), the non-maximized/non-fullscreen |
111 // windows are readjusted to make sure the window is completely within the | 100 // windows are readjusted to make sure the window is completely within the |
112 // display region. Otherwise, it makes sure at least some parts of the window | 101 // display region. Otherwise, it makes sure at least some parts of the window |
113 // is on display. | 102 // is on display. |
114 void AdjustAllWindowsBoundsForWorkAreaChange(const wm::WMEvent* event); | 103 void AdjustAllWindowsBoundsForWorkAreaChange(const wm::WMEvent* event); |
115 | 104 |
116 // Updates the visibility state of the shelf. | 105 // Updates the visibility state of the shelf. |
117 void UpdateShelfVisibility(); | 106 void UpdateShelfVisibility(); |
118 | 107 |
119 // Updates the fullscreen state of the workspace and notifies Shell if it | 108 // Updates the fullscreen state of the workspace and notifies Shell if it |
120 // has changed. | 109 // has changed. |
121 void UpdateFullscreenState(); | 110 void UpdateFullscreenState(); |
122 | 111 |
123 // Updates the bounds of the window for a stte type change from | 112 // Updates the bounds of the window for a stte type change from |
124 // |old_show_type|. | 113 // |old_show_type|. |
125 void UpdateBoundsFromStateType(wm::WindowState* window_state, | 114 void UpdateBoundsFromStateType(wm::WindowState* window_state, |
126 wm::WindowStateType old_state_type); | 115 wm::WindowStateType old_state_type); |
127 | 116 |
128 // If |window_state| is maximized or fullscreen the bounds of the | 117 // If |window_state| is maximized or fullscreen the bounds of the |
129 // window are set and true is returned. Does nothing otherwise. | 118 // window are set and true is returned. Does nothing otherwise. |
130 bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state); | 119 bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state); |
131 | 120 |
132 // Animates the window bounds to |bounds|. | 121 // Animates the window bounds to |bounds|. |
133 void SetChildBoundsAnimated(aura::Window* child, const gfx::Rect& bounds); | 122 void SetChildBoundsAnimated(wm::WmWindow* child, const gfx::Rect& bounds); |
134 | 123 |
135 aura::Window* window_; | 124 wm::WmWindow* window_; |
136 aura::Window* root_window_; | 125 wm::WmWindow* root_window_; |
| 126 wm::WmRootWindowController* root_window_controller_; |
| 127 wm::WmGlobals* globals_; |
137 | 128 |
138 std::unique_ptr<wm::WorkspaceLayoutManagerDelegate> delegate_; | 129 std::unique_ptr<wm::WorkspaceLayoutManagerDelegate> delegate_; |
139 | 130 |
140 // Set of windows we're listening to. | 131 // Set of windows we're listening to. |
141 WindowSet windows_; | 132 WindowSet windows_; |
142 | 133 |
143 // The work area in the coordinates of |window_|. | 134 // The work area in the coordinates of |window_|. |
144 gfx::Rect work_area_in_parent_; | 135 gfx::Rect work_area_in_parent_; |
145 | 136 |
146 // True if this workspace is currently in fullscreen mode. | 137 // True if this workspace is currently in fullscreen mode. |
147 bool is_fullscreen_; | 138 bool is_fullscreen_; |
148 | 139 |
149 // A window which covers the full container and which gets inserted behind the | 140 // A window which covers the full container and which gets inserted behind the |
150 // topmost visible window. | 141 // topmost visible window. |
151 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop_delegate_; | 142 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop_delegate_; |
152 | 143 |
153 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager); | 144 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager); |
154 }; | 145 }; |
155 | 146 |
156 } // namespace ash | 147 } // namespace ash |
157 | 148 |
158 #endif // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ | 149 #endif // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ |
OLD | NEW |