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" | 12 #include "ash/shell_observer.h" |
13 #include "ash/wm/window_state_observer.h" | 13 #include "ash/wm/window_state_observer.h" |
14 #include "ash/wm/wm_types.h" | 14 #include "ash/wm/wm_types.h" |
15 #include "ash/wm_layout_manager.h" | |
16 #include "base/macros.h" | 15 #include "base/macros.h" |
17 #include "base/scoped_observer.h" | 16 #include "base/scoped_observer.h" |
| 17 #include "ui/aura/layout_manager.h" |
18 #include "ui/aura/window_observer.h" | 18 #include "ui/aura/window_observer.h" |
19 #include "ui/display/display_observer.h" | 19 #include "ui/display/display_observer.h" |
20 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
21 #include "ui/keyboard/keyboard_controller_observer.h" | 21 #include "ui/keyboard/keyboard_controller_observer.h" |
22 #include "ui/wm/public/activation_change_observer.h" | 22 #include "ui/wm/public/activation_change_observer.h" |
23 | 23 |
24 namespace keyboard { | 24 namespace keyboard { |
25 class KeyboardController; | 25 class KeyboardController; |
26 } | 26 } |
27 | 27 |
28 namespace ash { | 28 namespace ash { |
29 | 29 |
30 class RootWindowController; | 30 class RootWindowController; |
31 class WmWindow; | |
32 class WorkspaceLayoutManagerBackdropDelegate; | 31 class WorkspaceLayoutManagerBackdropDelegate; |
33 | 32 |
34 namespace wm { | 33 namespace wm { |
35 class WMEvent; | 34 class WMEvent; |
36 } | 35 } |
37 | 36 |
38 // LayoutManager used on the window created for a workspace. | 37 // LayoutManager used on the window created for a workspace. |
39 class ASH_EXPORT WorkspaceLayoutManager | 38 class ASH_EXPORT WorkspaceLayoutManager |
40 : public WmLayoutManager, | 39 : public aura::LayoutManager, |
41 public aura::WindowObserver, | 40 public aura::WindowObserver, |
42 public aura::client::ActivationChangeObserver, | 41 public aura::client::ActivationChangeObserver, |
43 public keyboard::KeyboardControllerObserver, | 42 public keyboard::KeyboardControllerObserver, |
44 public display::DisplayObserver, | 43 public display::DisplayObserver, |
45 public ShellObserver, | 44 public ShellObserver, |
46 public wm::WindowStateObserver { | 45 public wm::WindowStateObserver { |
47 public: | 46 public: |
48 // |window| is the container for this layout manager. | 47 // |window| is the container for this layout manager. |
49 explicit WorkspaceLayoutManager(WmWindow* window); | 48 explicit WorkspaceLayoutManager(aura::Window* window); |
50 ~WorkspaceLayoutManager() override; | 49 ~WorkspaceLayoutManager() override; |
51 | 50 |
52 // A delegate which can be set to add a backdrop behind the top most visible | 51 // A delegate which can be set to add a backdrop behind the top most visible |
53 // window. With the call the ownership of the delegate will be transferred to | 52 // window. With the call the ownership of the delegate will be transferred to |
54 // the WorkspaceLayoutManager. | 53 // the WorkspaceLayoutManager. |
55 void SetMaximizeBackdropDelegate( | 54 void SetMaximizeBackdropDelegate( |
56 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate); | 55 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate); |
57 | 56 |
58 // Overridden from WmLayoutManager: | 57 // Overridden from aura::LayoutManager: |
59 void OnWindowResized() override; | 58 void OnWindowResized() override; |
60 void OnWindowAddedToLayout(WmWindow* child) override; | 59 void OnWindowAddedToLayout(aura::Window* child) override; |
61 void OnWillRemoveWindowFromLayout(WmWindow* child) override; | 60 void OnWillRemoveWindowFromLayout(aura::Window* child) override; |
62 void OnWindowRemovedFromLayout(WmWindow* child) override; | 61 void OnWindowRemovedFromLayout(aura::Window* child) override; |
63 void OnChildWindowVisibilityChanged(WmWindow* child, bool visibile) override; | 62 void OnChildWindowVisibilityChanged(aura::Window* child, |
64 void SetChildBounds(WmWindow* child, | 63 bool visibile) override; |
| 64 void SetChildBounds(aura::Window* child, |
65 const gfx::Rect& requested_bounds) override; | 65 const gfx::Rect& requested_bounds) override; |
66 | 66 |
67 // Overriden from aura::WindowObserver: | 67 // Overriden from aura::WindowObserver: |
68 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; | 68 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; |
69 void OnWindowPropertyChanged(aura::Window* window, | 69 void OnWindowPropertyChanged(aura::Window* window, |
70 const void* key, | 70 const void* key, |
71 intptr_t old) override; | 71 intptr_t old) override; |
72 void OnWindowStackingChanged(aura::Window* window) override; | 72 void OnWindowStackingChanged(aura::Window* window) override; |
73 void OnWindowDestroying(aura::Window* window) override; | 73 void OnWindowDestroying(aura::Window* window) override; |
74 void OnWindowBoundsChanged(aura::Window* window, | 74 void OnWindowBoundsChanged(aura::Window* window, |
(...skipping 18 matching lines...) Expand all Loading... |
93 uint32_t changed_metrics) override; | 93 uint32_t changed_metrics) override; |
94 | 94 |
95 // ShellObserver overrides: | 95 // ShellObserver overrides: |
96 void OnFullscreenStateChanged(bool is_fullscreen, | 96 void OnFullscreenStateChanged(bool is_fullscreen, |
97 WmWindow* root_window) override; | 97 WmWindow* root_window) override; |
98 void OnPinnedStateChanged(WmWindow* pinned_window) override; | 98 void OnPinnedStateChanged(WmWindow* pinned_window) override; |
99 void OnVirtualKeyboardStateChanged(bool activated, | 99 void OnVirtualKeyboardStateChanged(bool activated, |
100 WmWindow* root_window) override; | 100 WmWindow* root_window) override; |
101 | 101 |
102 private: | 102 private: |
103 typedef std::set<WmWindow*> WindowSet; | 103 typedef std::set<aura::Window*> WindowSet; |
104 | 104 |
105 // Adjusts the bounds of all managed windows when the display area changes. | 105 // Adjusts the bounds of all managed windows when the display area changes. |
106 // This happens when the display size, work area insets has changed. | 106 // This happens when the display size, work area insets has changed. |
107 // If this is called for a display size change (i.e. |event| | 107 // If this is called for a display size change (i.e. |event| |
108 // is DISPLAY_RESIZED), the non-maximized/non-fullscreen | 108 // is DISPLAY_RESIZED), the non-maximized/non-fullscreen |
109 // windows are readjusted to make sure the window is completely within the | 109 // windows are readjusted to make sure the window is completely within the |
110 // display region. Otherwise, it makes sure at least some parts of the window | 110 // display region. Otherwise, it makes sure at least some parts of the window |
111 // is on display. | 111 // is on display. |
112 void AdjustAllWindowsBoundsForWorkAreaChange(const wm::WMEvent* event); | 112 void AdjustAllWindowsBoundsForWorkAreaChange(const wm::WMEvent* event); |
113 | 113 |
114 // Updates the visibility state of the shelf. | 114 // Updates the visibility state of the shelf. |
115 void UpdateShelfVisibility(); | 115 void UpdateShelfVisibility(); |
116 | 116 |
117 // Updates the fullscreen state of the workspace and notifies Shell if it | 117 // Updates the fullscreen state of the workspace and notifies Shell if it |
118 // has changed. | 118 // has changed. |
119 void UpdateFullscreenState(); | 119 void UpdateFullscreenState(); |
120 | 120 |
121 // Updates the always-on-top state for windows managed by this layout | 121 // Updates the always-on-top state for windows managed by this layout |
122 // manager. | 122 // manager. |
123 void UpdateAlwaysOnTop(WmWindow* window_on_top); | 123 void UpdateAlwaysOnTop(aura::Window* window_on_top); |
124 | 124 |
125 WmWindow* window_; | 125 aura::Window* window_; |
126 WmWindow* root_window_; | 126 aura::Window* root_window_; |
127 RootWindowController* root_window_controller_; | 127 RootWindowController* root_window_controller_; |
128 | 128 |
129 // Set of windows we're listening to. | 129 // Set of windows we're listening to. |
130 WindowSet windows_; | 130 WindowSet windows_; |
131 | 131 |
132 // The work area in the coordinates of |window_|. | 132 // The work area in the coordinates of |window_|. |
133 gfx::Rect work_area_in_parent_; | 133 gfx::Rect work_area_in_parent_; |
134 | 134 |
135 // True if this workspace is currently in fullscreen mode. | 135 // True if this workspace is currently in fullscreen mode. |
136 bool is_fullscreen_; | 136 bool is_fullscreen_; |
137 | 137 |
138 // A window which covers the full container and which gets inserted behind the | 138 // A window which covers the full container and which gets inserted behind the |
139 // topmost visible window. | 139 // topmost visible window. |
140 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop_delegate_; | 140 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop_delegate_; |
141 | 141 |
142 ScopedObserver<keyboard::KeyboardController, | 142 ScopedObserver<keyboard::KeyboardController, |
143 keyboard::KeyboardControllerObserver> | 143 keyboard::KeyboardControllerObserver> |
144 keyboard_observer_; | 144 keyboard_observer_; |
145 | 145 |
146 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager); | 146 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager); |
147 }; | 147 }; |
148 | 148 |
149 } // namespace ash | 149 } // namespace ash |
150 | 150 |
151 #endif // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ | 151 #endif // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ |
OLD | NEW |