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