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