OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_COMMON_WM_ROOT_WINDOW_CONTROLLER_H_ | 5 #ifndef ASH_COMMON_WM_ROOT_WINDOW_CONTROLLER_H_ |
6 #define ASH_COMMON_WM_ROOT_WINDOW_CONTROLLER_H_ | 6 #define ASH_COMMON_WM_ROOT_WINDOW_CONTROLLER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/common/wm/workspace/workspace_types.h" | 9 #include "ash/common/wm/workspace/workspace_types.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 class MenuModelAdapter; | 23 class MenuModelAdapter; |
24 class MenuRunner; | 24 class MenuRunner; |
25 } | 25 } |
26 | 26 |
27 namespace ash { | 27 namespace ash { |
28 | 28 |
29 class AlwaysOnTopController; | 29 class AlwaysOnTopController; |
30 class AnimatingWallpaperWidgetController; | 30 class AnimatingWallpaperWidgetController; |
31 class DockedWindowLayoutManager; | 31 class DockedWindowLayoutManager; |
32 class PanelLayoutManager; | 32 class PanelLayoutManager; |
| 33 class RootWindowController; |
33 class SystemModalContainerLayoutManager; | 34 class SystemModalContainerLayoutManager; |
34 class SystemTray; | 35 class SystemTray; |
35 class WallpaperWidgetController; | 36 class WallpaperWidgetController; |
36 class WmShelf; | 37 class WmShelf; |
37 class WmWindow; | 38 class WmWindow; |
38 class WorkspaceController; | 39 class WorkspaceController; |
39 | 40 |
40 enum class LoginStatus; | 41 enum class LoginStatus; |
41 | 42 |
42 namespace wm { | 43 namespace wm { |
43 class RootWindowLayoutManager; | 44 class RootWindowLayoutManager; |
44 } | 45 } |
45 | 46 |
46 // Provides state associated with a root of a window hierarchy. | 47 // Provides state associated with a root of a window hierarchy. |
47 class ASH_EXPORT WmRootWindowController { | 48 class ASH_EXPORT WmRootWindowController { |
48 public: | 49 public: |
49 explicit WmRootWindowController(WmWindow* window); | 50 WmRootWindowController(RootWindowController* root_window_controller, |
50 virtual ~WmRootWindowController(); | 51 WmWindow* window); |
| 52 ~WmRootWindowController(); |
51 | 53 |
52 DockedWindowLayoutManager* docked_window_layout_manager() { | 54 DockedWindowLayoutManager* docked_window_layout_manager() { |
53 return docked_window_layout_manager_; | 55 return docked_window_layout_manager_; |
54 } | 56 } |
55 | 57 |
56 PanelLayoutManager* panel_layout_manager() { return panel_layout_manager_; } | 58 PanelLayoutManager* panel_layout_manager() { return panel_layout_manager_; } |
57 | 59 |
58 wm::RootWindowLayoutManager* root_window_layout_manager() { | 60 wm::RootWindowLayoutManager* root_window_layout_manager() { |
59 return root_window_layout_manager_; | 61 return root_window_layout_manager_; |
60 } | 62 } |
(...skipping 22 matching lines...) Expand all Loading... |
83 // Returns the layout manager for the appropriate modal-container. If the | 85 // Returns the layout manager for the appropriate modal-container. If the |
84 // window is inside the lockscreen modal container, then the layout manager | 86 // window is inside the lockscreen modal container, then the layout manager |
85 // for that is returned. Otherwise the layout manager for the default modal | 87 // for that is returned. Otherwise the layout manager for the default modal |
86 // container is returned. | 88 // container is returned. |
87 // If no window is specified (i.e. |window| is null), then the lockscreen | 89 // If no window is specified (i.e. |window| is null), then the lockscreen |
88 // modal container is used if the screen is currently locked. Otherwise, the | 90 // modal container is used if the screen is currently locked. Otherwise, the |
89 // default modal container is used. | 91 // default modal container is used. |
90 SystemModalContainerLayoutManager* GetSystemModalLayoutManager( | 92 SystemModalContainerLayoutManager* GetSystemModalLayoutManager( |
91 WmWindow* window); | 93 WmWindow* window); |
92 | 94 |
93 virtual bool HasShelf() = 0; | 95 bool HasShelf(); |
94 | 96 |
95 virtual WmShelf* GetShelf() = 0; | 97 WmShelf* GetShelf(); |
96 | 98 |
97 // Creates the shelf for this root window and notifies observers. | 99 // Creates the shelf for this root window and notifies observers. |
98 void CreateShelf(); | 100 void CreateShelf(); |
99 | 101 |
100 // Show shelf view if it was created hidden (before session has started). | 102 // Show shelf view if it was created hidden (before session has started). |
101 // TODO(jamescook): Eliminate this and handle show via Shelf. | 103 // TODO(jamescook): Eliminate this and handle show via Shelf. |
102 void ShowShelf(); | 104 void ShowShelf(); |
103 | 105 |
104 // Returns the system tray controller. May be null for external displays. | 106 // Returns the system tray controller. May be null for external displays. |
105 SystemTray* GetSystemTray(); | 107 SystemTray* GetSystemTray(); |
106 | 108 |
107 // Returns the window associated with this WmRootWindowController. | 109 // Returns the window associated with this WmRootWindowController. |
108 virtual WmWindow* GetWindow() = 0; | 110 WmWindow* GetWindow(); |
109 | 111 |
110 // Gets the WmWindow whose shell window id is |container_id|. | 112 // Gets the WmWindow whose shell window id is |container_id|. |
111 WmWindow* GetContainer(int container_id); | 113 WmWindow* GetContainer(int container_id); |
112 const WmWindow* GetContainer(int container_id) const; | 114 const WmWindow* GetContainer(int container_id) const; |
113 | 115 |
114 // Configures |init_params| prior to initializing |widget|. | 116 // Configures |init_params| prior to initializing |widget|. |
115 // |shell_container_id| is the id of the container to parent |widget| to. | 117 // |shell_container_id| is the id of the container to parent |widget| to. |
116 void ConfigureWidgetInitParamsForContainer( | 118 void ConfigureWidgetInitParamsForContainer( |
117 views::Widget* widget, | 119 views::Widget* widget, |
118 int shell_container_id, | 120 int shell_container_id, |
119 views::Widget::InitParams* init_params); | 121 views::Widget::InitParams* init_params); |
120 | 122 |
121 // Returns the window events will be targeted at for the specified location | 123 // Returns the window events will be targeted at for the specified location |
122 // (in screen coordinates). | 124 // (in screen coordinates). |
123 // | 125 // |
124 // NOTE: the returned window may not contain the location as resize handles | 126 // NOTE: the returned window may not contain the location as resize handles |
125 // may extend outside the bounds of the window. | 127 // may extend outside the bounds of the window. |
126 WmWindow* FindEventTarget(const gfx::Point& location_in_screen); | 128 WmWindow* FindEventTarget(const gfx::Point& location_in_screen); |
127 | 129 |
128 // Gets the last location seen in a mouse event in this root window's | 130 // Gets the last location seen in a mouse event in this root window's |
129 // coordinates. This may return a point outside the root window's bounds. | 131 // coordinates. This may return a point outside the root window's bounds. |
130 gfx::Point GetLastMouseLocationInRoot(); | 132 gfx::Point GetLastMouseLocationInRoot(); |
131 | 133 |
132 // Shows a context menu at the |location_in_screen|. | 134 // Shows a context menu at the |location_in_screen|. |
133 void ShowContextMenu(const gfx::Point& location_in_screen, | 135 void ShowContextMenu(const gfx::Point& location_in_screen, |
134 ui::MenuSourceType source_type); | 136 ui::MenuSourceType source_type); |
135 | 137 |
136 // Called when the wallpaper animation has started or finished. | 138 // Called when the wallpaper animation has started or finished. |
137 // TODO: port remaining classic ash wallpaper functionality here. | 139 // TODO: port remaining classic ash wallpaper functionality here. |
138 virtual void OnInitialWallpaperAnimationStarted(); | 140 void OnInitialWallpaperAnimationStarted(); |
139 virtual void OnWallpaperAnimationFinished(views::Widget* widget); | 141 void OnWallpaperAnimationFinished(views::Widget* widget); |
140 | 142 |
141 // Called when the login status changes after login (such as lock/unlock). | 143 // Called when the login status changes after login (such as lock/unlock). |
142 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|. | 144 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|. |
143 virtual void UpdateAfterLoginStatusChange(LoginStatus status); | 145 virtual void UpdateAfterLoginStatusChange(LoginStatus status); |
144 | 146 |
145 protected: | 147 protected: |
146 // Moves child windows to |dest|. | 148 // Moves child windows to |dest|. |
147 void MoveWindowsTo(WmWindow* dest); | 149 void MoveWindowsTo(WmWindow* dest); |
148 | 150 |
149 // Creates the containers (WmWindows) used by the shell. | 151 // Creates the containers (WmWindows) used by the shell. |
150 void CreateContainers(); | 152 void CreateContainers(); |
151 | 153 |
152 // Creates the LayoutManagers for the windows created by CreateContainers(). | 154 // Creates the LayoutManagers for the windows created by CreateContainers(). |
153 void CreateLayoutManagers(); | 155 void CreateLayoutManagers(); |
154 | 156 |
155 // Resets WmShell::GetRootWindowForNewWindows() if appropriate. This is called | 157 // Resets WmShell::GetRootWindowForNewWindows() if appropriate. This is called |
156 // during shutdown to make sure GetRootWindowForNewWindows() isn't referencing | 158 // during shutdown to make sure GetRootWindowForNewWindows() isn't referencing |
157 // this. | 159 // this. |
158 void ResetRootForNewWindowsIfNecessary(); | 160 void ResetRootForNewWindowsIfNecessary(); |
159 | 161 |
160 // Called during shutdown to destroy state such as windows and LayoutManagers. | 162 // Called during shutdown to destroy state such as windows and LayoutManagers. |
161 void CloseChildWindows(); | 163 void CloseChildWindows(); |
162 | 164 |
| 165 private: |
| 166 friend class RootWindowController; |
| 167 |
163 // Called from CloseChildWindows() to determine if the specified window should | 168 // Called from CloseChildWindows() to determine if the specified window should |
164 // be destroyed. | 169 // be destroyed. |
165 virtual bool ShouldDestroyWindowInCloseChildWindows(WmWindow* window) = 0; | 170 bool ShouldDestroyWindowInCloseChildWindows(WmWindow* window); |
166 | 171 |
167 private: | |
168 // Callback for MenuModelAdapter. | 172 // Callback for MenuModelAdapter. |
169 void OnMenuClosed(); | 173 void OnMenuClosed(); |
170 | 174 |
| 175 // TODO(sky): remove this, needed until merge two classes. |
| 176 RootWindowController* root_window_controller_; |
| 177 |
171 WmWindow* root_; | 178 WmWindow* root_; |
172 | 179 |
173 // LayoutManagers are owned by the window they are installed on. | 180 // LayoutManagers are owned by the window they are installed on. |
174 DockedWindowLayoutManager* docked_window_layout_manager_ = nullptr; | 181 DockedWindowLayoutManager* docked_window_layout_manager_ = nullptr; |
175 PanelLayoutManager* panel_layout_manager_ = nullptr; | 182 PanelLayoutManager* panel_layout_manager_ = nullptr; |
176 wm::RootWindowLayoutManager* root_window_layout_manager_ = nullptr; | 183 wm::RootWindowLayoutManager* root_window_layout_manager_ = nullptr; |
177 | 184 |
178 std::unique_ptr<WallpaperWidgetController> wallpaper_widget_controller_; | 185 std::unique_ptr<WallpaperWidgetController> wallpaper_widget_controller_; |
179 std::unique_ptr<AnimatingWallpaperWidgetController> | 186 std::unique_ptr<AnimatingWallpaperWidgetController> |
180 animating_wallpaper_widget_controller_; | 187 animating_wallpaper_widget_controller_; |
181 std::unique_ptr<WorkspaceController> workspace_controller_; | 188 std::unique_ptr<WorkspaceController> workspace_controller_; |
182 | 189 |
183 std::unique_ptr<AlwaysOnTopController> always_on_top_controller_; | 190 std::unique_ptr<AlwaysOnTopController> always_on_top_controller_; |
184 | 191 |
185 // Manages the context menu. | 192 // Manages the context menu. |
186 std::unique_ptr<ui::MenuModel> menu_model_; | 193 std::unique_ptr<ui::MenuModel> menu_model_; |
187 std::unique_ptr<views::MenuModelAdapter> menu_model_adapter_; | 194 std::unique_ptr<views::MenuModelAdapter> menu_model_adapter_; |
188 std::unique_ptr<views::MenuRunner> menu_runner_; | 195 std::unique_ptr<views::MenuRunner> menu_runner_; |
189 | 196 |
190 DISALLOW_COPY_AND_ASSIGN(WmRootWindowController); | 197 DISALLOW_COPY_AND_ASSIGN(WmRootWindowController); |
191 }; | 198 }; |
192 | 199 |
193 } // namespace ash | 200 } // namespace ash |
194 | 201 |
195 #endif // ASH_COMMON_WM_ROOT_WINDOW_CONTROLLER_H_ | 202 #endif // ASH_COMMON_WM_ROOT_WINDOW_CONTROLLER_H_ |
OLD | NEW |