[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 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 | #include "ash/root_window_controller.h" |
| 6 | |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 7 | #include <queue> |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
[email protected] | 44d444c | 2013-01-30 01:47:44 | [diff] [blame] | 10 | #include "ash/ash_constants.h" |
[email protected] | e6e41d2f | 2012-10-29 19:22:19 | [diff] [blame] | 11 | #include "ash/ash_switches.h" |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 12 | #include "ash/desktop_background/desktop_background_controller.h" |
[email protected] | b4ddc7a | 2012-08-07 04:17:32 | [diff] [blame] | 13 | #include "ash/desktop_background/desktop_background_widget_controller.h" |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 14 | #include "ash/desktop_background/user_wallpaper_delegate.h" |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 15 | #include "ash/display/display_manager.h" |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 16 | #include "ash/focus_cycler.h" |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 17 | #include "ash/high_contrast/high_contrast_controller.h" |
[email protected] | f8e6aad | 2013-08-30 21:49:11 | [diff] [blame] | 18 | #include "ash/root_window_settings.h" |
[email protected] | fcb123d | 2013-04-17 15:58:49 | [diff] [blame] | 19 | #include "ash/session_state_delegate.h" |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 20 | #include "ash/shelf/shelf_layout_manager.h" |
| 21 | #include "ash/shelf/shelf_types.h" |
| 22 | #include "ash/shelf/shelf_widget.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 23 | #include "ash/shell.h" |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 24 | #include "ash/shell_delegate.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 25 | #include "ash/shell_factory.h" |
| 26 | #include "ash/shell_window_ids.h" |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 27 | #include "ash/system/status_area_widget.h" |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 28 | #include "ash/system/tray/system_tray_delegate.h" |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 29 | #include "ash/touch/touch_hud_debug.h" |
| 30 | #include "ash/touch/touch_hud_projection.h" |
[email protected] | 80549c15 | 2013-07-02 01:42:47 | [diff] [blame] | 31 | #include "ash/touch/touch_observer_hud.h" |
| 32 | #include "ash/wm/always_on_top_controller.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 33 | #include "ash/wm/base_layout_manager.h" |
[email protected] | beb4e5c | 2013-06-18 15:37:07 | [diff] [blame] | 34 | #include "ash/wm/dock/docked_window_layout_manager.h" |
[email protected] | 7095a65 | 2013-03-07 19:41:49 | [diff] [blame] | 35 | #include "ash/wm/panels/panel_layout_manager.h" |
[email protected] | 10065941 | 2013-06-21 22:59:55 | [diff] [blame] | 36 | #include "ash/wm/panels/panel_window_event_handler.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 37 | #include "ash/wm/root_window_layout_manager.h" |
| 38 | #include "ash/wm/screen_dimmer.h" |
[email protected] | 2a2caa0 | 2013-01-22 20:50:36 | [diff] [blame] | 39 | #include "ash/wm/stacking_controller.h" |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 40 | #include "ash/wm/status_area_layout_manager.h" |
[email protected] | e6e41d2f | 2012-10-29 19:22:19 | [diff] [blame] | 41 | #include "ash/wm/system_background_controller.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 42 | #include "ash/wm/system_modal_container_layout_manager.h" |
[email protected] | 5dc51db8 | 2012-09-11 03:39:01 | [diff] [blame] | 43 | #include "ash/wm/toplevel_window_event_handler.h" |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 44 | #include "ash/wm/window_properties.h" |
[email protected] | a41b4e1 | 2013-09-20 04:36:34 | [diff] [blame] | 45 | #include "ash/wm/window_state.h" |
[email protected] | 700849f | 2013-04-30 17:49:20 | [diff] [blame] | 46 | #include "ash/wm/window_util.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 47 | #include "ash/wm/workspace_controller.h" |
[email protected] | e6e41d2f | 2012-10-29 19:22:19 | [diff] [blame] | 48 | #include "base/command_line.h" |
[email protected] | 1e84c63 | 2013-06-27 23:12:21 | [diff] [blame] | 49 | #include "base/time/time.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 50 | #include "ui/aura/client/aura_constants.h" |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 51 | #include "ui/aura/client/drag_drop_client.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 52 | #include "ui/aura/client/tooltip_client.h" |
| 53 | #include "ui/aura/root_window.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 54 | #include "ui/aura/window.h" |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 55 | #include "ui/aura/window_delegate.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 56 | #include "ui/aura/window_observer.h" |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 57 | #include "ui/aura/window_tracker.h" |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 58 | #include "ui/base/hit_test.h" |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 59 | #include "ui/base/models/menu_model.h" |
[email protected] | f8e6aad | 2013-08-30 21:49:11 | [diff] [blame] | 60 | #include "ui/gfx/display.h" |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 61 | #include "ui/gfx/screen.h" |
[email protected] | 86459e2c | 2013-04-10 13:39:24 | [diff] [blame] | 62 | #include "ui/keyboard/keyboard_controller.h" |
| 63 | #include "ui/keyboard/keyboard_util.h" |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 64 | #include "ui/views/controls/menu/menu_runner.h" |
[email protected] | 23a2dc8 | 2013-08-22 15:04:22 | [diff] [blame] | 65 | #include "ui/views/corewm/capture_controller.h" |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 66 | #include "ui/views/corewm/visibility_controller.h" |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 67 | #include "ui/views/view_model.h" |
| 68 | #include "ui/views/view_model_utils.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 69 | |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 70 | #if defined(OS_CHROMEOS) |
| 71 | #include "ash/wm/boot_splash_screen_chromeos.h" |
| 72 | #endif |
| 73 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 74 | namespace ash { |
| 75 | namespace { |
| 76 | |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 77 | #if defined(OS_CHROMEOS) |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 78 | // Duration for the animation that hides the boot splash screen, in |
| 79 | // milliseconds. This should be short enough in relation to |
| 80 | // wm/window_animation.cc's brightness/grayscale fade animation that the login |
| 81 | // background image animation isn't hidden by the splash screen animation. |
| 82 | const int kBootSplashScreenHideDurationMs = 500; |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 83 | #endif |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 84 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 85 | // Creates a new window for use as a container. |
| 86 | aura::Window* CreateContainer(int window_id, |
| 87 | const char* name, |
| 88 | aura::Window* parent) { |
| 89 | aura::Window* container = new aura::Window(NULL); |
| 90 | container->set_id(window_id); |
| 91 | container->SetName(name); |
| 92 | container->Init(ui::LAYER_NOT_DRAWN); |
| 93 | parent->AddChild(container); |
| 94 | if (window_id != internal::kShellWindowId_UnparentedControlContainer) |
| 95 | container->Show(); |
| 96 | return container; |
| 97 | } |
| 98 | |
[email protected] | 9505857 | 2012-08-20 14:57:29 | [diff] [blame] | 99 | // Reparents |window| to |new_parent|. |
| 100 | void ReparentWindow(aura::Window* window, aura::Window* new_parent) { |
| 101 | // Update the restore bounds to make it relative to the display. |
[email protected] | a41b4e1 | 2013-09-20 04:36:34 | [diff] [blame] | 102 | wm::WindowState* state = wm::GetWindowState(window); |
| 103 | gfx::Rect restore_bounds; |
| 104 | bool has_restore_bounds = state->HasRestoreBounds(); |
| 105 | if (has_restore_bounds) |
| 106 | restore_bounds = state->GetRestoreBoundsInParent(); |
[email protected] | 9505857 | 2012-08-20 14:57:29 | [diff] [blame] | 107 | new_parent->AddChild(window); |
[email protected] | a41b4e1 | 2013-09-20 04:36:34 | [diff] [blame] | 108 | if (has_restore_bounds) |
| 109 | state->SetRestoreBoundsInParent(restore_bounds); |
[email protected] | 9505857 | 2012-08-20 14:57:29 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | // Reparents the appropriate set of windows from |src| to |dst|. |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 113 | void ReparentAllWindows(aura::Window* src, aura::Window* dst) { |
[email protected] | 9505857 | 2012-08-20 14:57:29 | [diff] [blame] | 114 | // Set of windows to move. |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 115 | const int kContainerIdsToMove[] = { |
| 116 | internal::kShellWindowId_DefaultContainer, |
[email protected] | beb4e5c | 2013-06-18 15:37:07 | [diff] [blame] | 117 | internal::kShellWindowId_DockedContainer, |
[email protected] | 95db9c1 | 2013-01-31 11:47:44 | [diff] [blame] | 118 | internal::kShellWindowId_PanelContainer, |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 119 | internal::kShellWindowId_AlwaysOnTopContainer, |
| 120 | internal::kShellWindowId_SystemModalContainer, |
| 121 | internal::kShellWindowId_LockSystemModalContainer, |
[email protected] | 6274d31 | 2012-10-04 22:06:41 | [diff] [blame] | 122 | internal::kShellWindowId_InputMethodContainer, |
[email protected] | a975487 | 2013-01-25 07:44:00 | [diff] [blame] | 123 | internal::kShellWindowId_UnparentedControlContainer, |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 124 | }; |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 125 | for (size_t i = 0; i < arraysize(kContainerIdsToMove); i++) { |
| 126 | int id = kContainerIdsToMove[i]; |
| 127 | aura::Window* src_container = Shell::GetContainer(src, id); |
| 128 | aura::Window* dst_container = Shell::GetContainer(dst, id); |
[email protected] | 5b602190 | 2013-02-26 05:33:29 | [diff] [blame] | 129 | while (!src_container->children().empty()) { |
| 130 | // Restart iteration from the source container windows each time as they |
| 131 | // may change as a result of moving other windows. |
| 132 | aura::Window::Windows::const_iterator iter = |
| 133 | src_container->children().begin(); |
| 134 | while (iter != src_container->children().end() && |
| 135 | internal::SystemModalContainerLayoutManager::IsModalBackground( |
| 136 | *iter)) { |
| 137 | ++iter; |
| 138 | } |
| 139 | // If the entire window list is modal background windows then stop. |
| 140 | if (iter == src_container->children().end()) |
| 141 | break; |
| 142 | ReparentWindow(*iter, dst_container); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 147 | // Mark the container window so that a widget added to this container will |
| 148 | // use the virtual screeen coordinates instead of parent. |
| 149 | void SetUsesScreenCoordinates(aura::Window* container) { |
| 150 | container->SetProperty(internal::kUsesScreenCoordinatesKey, true); |
| 151 | } |
| 152 | |
[email protected] | e887c6c | 2013-07-08 19:35:53 | [diff] [blame] | 153 | // Mark the container window so that a widget added to this container will |
| 154 | // say in the same root window regardless of the bounds specified. |
| 155 | void DescendantShouldStayInSameRootWindow(aura::Window* container) { |
| 156 | container->SetProperty(internal::kStayInSameRootWindowKey, true); |
| 157 | } |
| 158 | |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 159 | // A window delegate which does nothing. Used to create a window that |
| 160 | // is a event target, but do nothing. |
| 161 | class EmptyWindowDelegate : public aura::WindowDelegate { |
| 162 | public: |
| 163 | EmptyWindowDelegate() {} |
| 164 | virtual ~EmptyWindowDelegate() {} |
| 165 | |
| 166 | // aura::WindowDelegate overrides: |
| 167 | virtual gfx::Size GetMinimumSize() const OVERRIDE { |
| 168 | return gfx::Size(); |
| 169 | } |
| 170 | virtual gfx::Size GetMaximumSize() const OVERRIDE { |
| 171 | return gfx::Size(); |
| 172 | } |
| 173 | virtual void OnBoundsChanged(const gfx::Rect& old_bounds, |
| 174 | const gfx::Rect& new_bounds) OVERRIDE { |
| 175 | } |
| 176 | virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE { |
| 177 | return gfx::kNullCursor; |
| 178 | } |
| 179 | virtual int GetNonClientComponent( |
| 180 | const gfx::Point& point) const OVERRIDE { |
| 181 | return HTNOWHERE; |
| 182 | } |
| 183 | virtual bool ShouldDescendIntoChildForEventHandling( |
| 184 | aura::Window* child, |
| 185 | const gfx::Point& location) OVERRIDE { |
| 186 | return false; |
| 187 | } |
| 188 | virtual bool CanFocus() OVERRIDE { |
| 189 | return false; |
| 190 | } |
| 191 | virtual void OnCaptureLost() OVERRIDE { |
| 192 | } |
| 193 | virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
| 194 | } |
| 195 | virtual void OnDeviceScaleFactorChanged( |
| 196 | float device_scale_factor) OVERRIDE { |
| 197 | } |
| 198 | virtual void OnWindowDestroying() OVERRIDE {} |
[email protected] | febe1fd6 | 2013-08-07 16:07:24 | [diff] [blame] | 199 | virtual void OnWindowDestroyed() OVERRIDE { |
| 200 | delete this; |
| 201 | } |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 202 | virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE { |
| 203 | } |
| 204 | virtual bool HasHitTestMask() const OVERRIDE { |
| 205 | return false; |
| 206 | } |
| 207 | virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {} |
[email protected] | 1ddbe93 | 2013-09-12 06:23:16 | [diff] [blame] | 208 | virtual void DidRecreateLayer(ui::Layer* old_layer, |
| 209 | ui::Layer* new_layer) OVERRIDE {} |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 210 | |
| 211 | private: |
| 212 | DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); |
| 213 | }; |
| 214 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 215 | } // namespace |
| 216 | |
| 217 | namespace internal { |
| 218 | |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 219 | void RootWindowController::CreateForPrimaryDisplay( |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 220 | aura::RootWindow* root) { |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 221 | RootWindowController* controller = new RootWindowController(root); |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 222 | controller->Init(RootWindowController::PRIMARY, |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 223 | Shell::GetInstance()->delegate()->IsFirstRunAfterBoot()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 224 | } |
| 225 | |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 226 | void RootWindowController::CreateForSecondaryDisplay(aura::RootWindow * root) { |
| 227 | RootWindowController* controller = new RootWindowController(root); |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 228 | controller->Init(RootWindowController::SECONDARY, false /* first run */); |
| 229 | } |
| 230 | |
| 231 | void RootWindowController::CreateForVirtualKeyboardDisplay( |
| 232 | aura::RootWindow * root) { |
| 233 | RootWindowController* controller = new RootWindowController(root); |
| 234 | controller->Init(RootWindowController::VIRTUAL_KEYBOARD, |
| 235 | false /* first run */); |
[email protected] | 6675e1c | 2012-09-11 09:15:45 | [diff] [blame] | 236 | } |
| 237 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 238 | // static |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 239 | RootWindowController* RootWindowController::ForLauncher(aura::Window* window) { |
[email protected] | 8c0ec43 | 2013-05-10 04:33:39 | [diff] [blame] | 240 | return GetRootWindowController(window->GetRootWindow()); |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 241 | } |
| 242 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 243 | // static |
[email protected] | ccff3d7 | 2013-02-06 04:26:28 | [diff] [blame] | 244 | RootWindowController* RootWindowController::ForWindow( |
| 245 | const aura::Window* window) { |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 246 | return GetRootWindowController(window->GetRootWindow()); |
| 247 | } |
| 248 | |
| 249 | // static |
[email protected] | d17642d | 2013-09-12 23:44:38 | [diff] [blame] | 250 | RootWindowController* RootWindowController::ForTargetRootWindow() { |
| 251 | return internal::GetRootWindowController(Shell::GetTargetRootWindow()); |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 252 | } |
| 253 | |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 254 | RootWindowController::~RootWindowController() { |
| 255 | Shutdown(); |
| 256 | root_window_.reset(); |
| 257 | // The CaptureClient needs to be around for as long as the RootWindow is |
| 258 | // valid. |
| 259 | capture_client_.reset(); |
| 260 | } |
| 261 | |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 262 | void RootWindowController::SetWallpaperController( |
| 263 | DesktopBackgroundWidgetController* controller) { |
| 264 | wallpaper_controller_.reset(controller); |
| 265 | } |
| 266 | |
| 267 | void RootWindowController::SetAnimatingWallpaperController( |
| 268 | AnimatingDesktopController* controller) { |
| 269 | if (animating_wallpaper_controller_.get()) |
| 270 | animating_wallpaper_controller_->StopAnimating(); |
| 271 | animating_wallpaper_controller_.reset(controller); |
| 272 | } |
| 273 | |
[email protected] | 6675e1c | 2012-09-11 09:15:45 | [diff] [blame] | 274 | void RootWindowController::Shutdown() { |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 275 | Shell::GetInstance()->RemoveShellObserver(this); |
| 276 | |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 277 | if (animating_wallpaper_controller_.get()) |
| 278 | animating_wallpaper_controller_->StopAnimating(); |
| 279 | wallpaper_controller_.reset(); |
| 280 | animating_wallpaper_controller_.reset(); |
| 281 | |
[email protected] | d17642d | 2013-09-12 23:44:38 | [diff] [blame] | 282 | // Change the target root window before closing child windows. If any child |
[email protected] | c98a492 | 2013-09-05 20:01:42 | [diff] [blame] | 283 | // being removed triggers a relayout of the shelf it will try to build a |
[email protected] | d17642d | 2013-09-12 23:44:38 | [diff] [blame] | 284 | // window list adding windows from the target root window's containers which |
[email protected] | c98a492 | 2013-09-05 20:01:42 | [diff] [blame] | 285 | // may have already gone away. |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 286 | if (Shell::GetTargetRootWindow() == root_window()) { |
[email protected] | d17642d | 2013-09-12 23:44:38 | [diff] [blame] | 287 | Shell::GetInstance()->set_target_root_window( |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 288 | Shell::GetPrimaryRootWindow() == root_window() ? |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 289 | NULL : Shell::GetPrimaryRootWindow()); |
| 290 | } |
[email protected] | c98a492 | 2013-09-05 20:01:42 | [diff] [blame] | 291 | |
| 292 | CloseChildWindows(); |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 293 | GetRootWindowSettings(root_window())->controller = NULL; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 294 | screen_dimmer_.reset(); |
| 295 | workspace_controller_.reset(); |
[email protected] | 6675e1c | 2012-09-11 09:15:45 | [diff] [blame] | 296 | // Forget with the display ID so that display lookup |
| 297 | // ends up with invalid display. |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 298 | internal::GetRootWindowSettings(root_window())->display_id = |
[email protected] | f8e6aad | 2013-08-30 21:49:11 | [diff] [blame] | 299 | gfx::Display::kInvalidDisplayID; |
[email protected] | 6675e1c | 2012-09-11 09:15:45 | [diff] [blame] | 300 | // And this root window should no longer process events. |
| 301 | root_window_->PrepareForShutdown(); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 302 | |
[email protected] | 956a6a4 | 2012-10-29 23:58:10 | [diff] [blame] | 303 | system_background_.reset(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 304 | } |
| 305 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 306 | SystemModalContainerLayoutManager* |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 307 | RootWindowController::GetSystemModalLayoutManager(aura::Window* window) { |
| 308 | aura::Window* container = NULL; |
| 309 | if (window) { |
[email protected] | 3b162e1 | 2012-11-09 11:52:35 | [diff] [blame] | 310 | if (window->parent() && |
| 311 | window->parent()->id() >= kShellWindowId_LockScreenContainer) { |
| 312 | container = GetContainer(kShellWindowId_LockSystemModalContainer); |
| 313 | } else { |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 314 | container = GetContainer(kShellWindowId_SystemModalContainer); |
[email protected] | 3b162e1 | 2012-11-09 11:52:35 | [diff] [blame] | 315 | } |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 316 | } else { |
[email protected] | a44afbbd | 2013-07-24 21:49:35 | [diff] [blame] | 317 | int modal_window_id = Shell::GetInstance()->session_state_delegate() |
| 318 | ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer : |
| 319 | kShellWindowId_SystemModalContainer; |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 320 | container = GetContainer(modal_window_id); |
| 321 | } |
[email protected] | bb0c7cd4 | 2013-05-20 23:39:45 | [diff] [blame] | 322 | return container ? static_cast<SystemModalContainerLayoutManager*>( |
| 323 | container->layout_manager()) : NULL; |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 324 | } |
| 325 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 326 | aura::Window* RootWindowController::GetContainer(int container_id) { |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 327 | return root_window()->GetChildById(container_id); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 328 | } |
| 329 | |
[email protected] | d8a2495 | 2013-08-05 20:05:05 | [diff] [blame] | 330 | const aura::Window* RootWindowController::GetContainer(int container_id) const { |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 331 | return root_window_->window()->GetChildById(container_id); |
[email protected] | d8a2495 | 2013-08-05 20:05:05 | [diff] [blame] | 332 | } |
| 333 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 334 | void RootWindowController::ShowLauncher() { |
[email protected] | 80549c15 | 2013-07-02 01:42:47 | [diff] [blame] | 335 | if (!shelf_->launcher()) |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 336 | return; |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 337 | shelf_->launcher()->SetVisible(true); |
| 338 | shelf_->status_area_widget()->Show(); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 339 | } |
| 340 | |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 341 | void RootWindowController::OnLauncherCreated() { |
| 342 | if (panel_layout_manager_) |
| 343 | panel_layout_manager_->SetLauncher(shelf_->launcher()); |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 344 | if (docked_layout_manager_) { |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 345 | docked_layout_manager_->SetLauncher(shelf_->launcher()); |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 346 | if (shelf_->shelf_layout_manager()) |
| 347 | docked_layout_manager_->AddObserver(shelf_->shelf_layout_manager()); |
| 348 | } |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 349 | } |
| 350 | |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 351 | void RootWindowController::UpdateAfterLoginStatusChange( |
| 352 | user::LoginStatus status) { |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 353 | if (status != user::LOGGED_IN_NONE) |
| 354 | mouse_event_target_.reset(); |
[email protected] | 80549c15 | 2013-07-02 01:42:47 | [diff] [blame] | 355 | if (shelf_->status_area_widget()) |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 356 | shelf_->status_area_widget()->UpdateAfterLoginStatusChange(status); |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 357 | } |
| 358 | |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 359 | void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() { |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 360 | #if defined(OS_CHROMEOS) |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 361 | if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 362 | switches::kAshAnimateFromBootSplashScreen) && |
| 363 | boot_splash_screen_.get()) { |
| 364 | // Make the splash screen fade out so it doesn't obscure the desktop |
| 365 | // wallpaper's brightness/grayscale animation. |
| 366 | boot_splash_screen_->StartHideAnimation( |
| 367 | base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs)); |
| 368 | } |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 369 | #endif |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 370 | } |
| 371 | |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 372 | void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) { |
| 373 | // Make sure the wallpaper is visible. |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 374 | system_background_->SetColor(SK_ColorBLACK); |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 375 | #if defined(OS_CHROMEOS) |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 376 | boot_splash_screen_.reset(); |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 377 | #endif |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 378 | |
| 379 | Shell::GetInstance()->user_wallpaper_delegate()-> |
| 380 | OnWallpaperAnimationFinished(); |
| 381 | // Only removes old component when wallpaper animation finished. If we |
| 382 | // remove the old one before the new wallpaper is done fading in there will |
| 383 | // be a white flash during the animation. |
| 384 | if (animating_wallpaper_controller()) { |
| 385 | DesktopBackgroundWidgetController* controller = |
| 386 | animating_wallpaper_controller()->GetController(true); |
| 387 | // |desktop_widget_| should be the same animating widget we try to move |
| 388 | // to |kDesktopController|. Otherwise, we may close |desktop_widget_| |
| 389 | // before move it to |kDesktopController|. |
| 390 | DCHECK_EQ(controller->widget(), widget); |
| 391 | // Release the old controller and close its background widget. |
| 392 | SetWallpaperController(controller); |
| 393 | } |
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 394 | } |
| 395 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 396 | void RootWindowController::CloseChildWindows() { |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 397 | mouse_event_target_.reset(); |
| 398 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 399 | // Deactivate keyboard container before closing child windows and shutting |
| 400 | // down associated layout managers. |
| 401 | DeactivateKeyboard(Shell::GetInstance()->keyboard_controller()); |
| 402 | |
[email protected] | 79a87b7e | 2013-01-25 05:08:22 | [diff] [blame] | 403 | // panel_layout_manager_ needs to be shut down before windows are destroyed. |
| 404 | if (panel_layout_manager_) { |
| 405 | panel_layout_manager_->Shutdown(); |
| 406 | panel_layout_manager_ = NULL; |
| 407 | } |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 408 | // docked_layout_manager_ needs to be shut down before windows are destroyed. |
| 409 | if (docked_layout_manager_) { |
[email protected] | bb42c93 | 2013-10-31 06:52:06 | [diff] [blame] | 410 | if (shelf_ && shelf_->shelf_layout_manager()) |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 411 | docked_layout_manager_->RemoveObserver(shelf_->shelf_layout_manager()); |
| 412 | docked_layout_manager_->Shutdown(); |
| 413 | docked_layout_manager_ = NULL; |
| 414 | } |
[email protected] | 79a87b7e | 2013-01-25 05:08:22 | [diff] [blame] | 415 | |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 416 | aura::client::SetDragDropClient(root_window(), NULL); |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 417 | |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 418 | // TODO(harrym): Remove when Status Area Widget is a child view. |
[email protected] | bb42c93 | 2013-10-31 06:52:06 | [diff] [blame] | 419 | if (shelf_) { |
| 420 | shelf_->ShutdownStatusAreaWidget(); |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 421 | |
[email protected] | bb42c93 | 2013-10-31 06:52:06 | [diff] [blame] | 422 | if (shelf_->shelf_layout_manager()) |
| 423 | shelf_->shelf_layout_manager()->PrepareForShutdown(); |
| 424 | } |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 425 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 426 | // Close background widget first as it depends on tooltip. |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 427 | wallpaper_controller_.reset(); |
| 428 | animating_wallpaper_controller_.reset(); |
[email protected] | b4ddc7a | 2012-08-07 04:17:32 | [diff] [blame] | 429 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 430 | workspace_controller_.reset(); |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 431 | aura::client::SetTooltipClient(root_window(), NULL); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 432 | |
[email protected] | 0fbfa97 | 2013-10-02 19:23:33 | [diff] [blame] | 433 | // Explicitly destroy top level windows. We do this as during part of |
| 434 | // destruction such windows may query the RootWindow for state. |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 435 | std::queue<aura::Window*> non_toplevel_windows; |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 436 | non_toplevel_windows.push(root_window()); |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 437 | while (!non_toplevel_windows.empty()) { |
| 438 | aura::Window* non_toplevel_window = non_toplevel_windows.front(); |
| 439 | non_toplevel_windows.pop(); |
| 440 | aura::WindowTracker toplevel_windows; |
| 441 | for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) { |
| 442 | aura::Window* child = non_toplevel_window->children()[i]; |
[email protected] | 0fbfa97 | 2013-10-02 19:23:33 | [diff] [blame] | 443 | if (!child->owned_by_parent()) |
| 444 | continue; |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 445 | if (child->delegate()) |
| 446 | toplevel_windows.Add(child); |
| 447 | else |
| 448 | non_toplevel_windows.push(child); |
| 449 | } |
| 450 | while (!toplevel_windows.windows().empty()) |
| 451 | delete *toplevel_windows.windows().begin(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 452 | } |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 453 | // And then remove the containers. |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 454 | while (!root_window()->children().empty()) { |
| 455 | aura::Window* window = root_window()->children()[0]; |
[email protected] | 0fbfa97 | 2013-10-02 19:23:33 | [diff] [blame] | 456 | if (window->owned_by_parent()) { |
| 457 | delete window; |
| 458 | } else { |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 459 | root_window()->RemoveChild(window); |
[email protected] | 0fbfa97 | 2013-10-02 19:23:33 | [diff] [blame] | 460 | } |
| 461 | } |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 462 | |
[email protected] | bb42c93 | 2013-10-31 06:52:06 | [diff] [blame] | 463 | shelf_.reset(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 464 | } |
| 465 | |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 466 | void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
[email protected] | 8039e06c | 2013-01-17 23:34:50 | [diff] [blame] | 467 | // Forget the shelf early so that shelf don't update itself using wrong |
| 468 | // display info. |
| 469 | workspace_controller_->SetShelf(NULL); |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 470 | ReparentAllWindows(root_window(), dst); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 471 | } |
| 472 | |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 473 | ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
[email protected] | 80549c15 | 2013-07-02 01:42:47 | [diff] [blame] | 474 | return shelf_->shelf_layout_manager(); |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 475 | } |
| 476 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 477 | SystemTray* RootWindowController::GetSystemTray() { |
| 478 | // We assume in throughout the code that this will not return NULL. If code |
| 479 | // triggers this for valid reasons, it should test status_area_widget first. |
[email protected] | 80549c15 | 2013-07-02 01:42:47 | [diff] [blame] | 480 | CHECK(shelf_->status_area_widget()); |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 481 | return shelf_->status_area_widget()->system_tray(); |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 482 | } |
| 483 | |
[email protected] | 940fb1c | 2013-06-18 16:54:28 | [diff] [blame] | 484 | void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen, |
| 485 | ui::MenuSourceType source_type) { |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 486 | DCHECK(Shell::GetInstance()->delegate()); |
| 487 | scoped_ptr<ui::MenuModel> menu_model( |
[email protected] | 8c0ec43 | 2013-05-10 04:33:39 | [diff] [blame] | 488 | Shell::GetInstance()->delegate()->CreateContextMenu(root_window())); |
[email protected] | 7f7f65c | 2013-04-17 16:47:13 | [diff] [blame] | 489 | if (!menu_model) |
[email protected] | 8e837ec | 2013-01-31 01:48:33 | [diff] [blame] | 490 | return; |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 491 | |
[email protected] | 6175fc4 | 2013-04-05 05:58:58 | [diff] [blame] | 492 | // Background controller may not be set yet if user clicked on status are |
| 493 | // before initial animation completion. See crbug.com/222218 |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 494 | if (!wallpaper_controller_.get()) |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 495 | return; |
| 496 | |
[email protected] | 6175fc4 | 2013-04-05 05:58:58 | [diff] [blame] | 497 | views::MenuRunner menu_runner(menu_model.get()); |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 498 | if (menu_runner.RunMenuAt(wallpaper_controller_->widget(), |
[email protected] | 6175fc4 | 2013-04-05 05:58:58 | [diff] [blame] | 499 | NULL, gfx::Rect(location_in_screen, gfx::Size()), |
[email protected] | 940fb1c | 2013-06-18 16:54:28 | [diff] [blame] | 500 | views::MenuItemView::TOPLEFT, source_type, |
| 501 | views::MenuRunner::CONTEXT_MENU) == |
[email protected] | 6175fc4 | 2013-04-05 05:58:58 | [diff] [blame] | 502 | views::MenuRunner::MENU_DELETED) { |
| 503 | return; |
| 504 | } |
| 505 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 506 | Shell::GetInstance()->UpdateShelfVisibility(); |
| 507 | } |
| 508 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 509 | void RootWindowController::UpdateShelfVisibility() { |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 510 | shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 511 | } |
| 512 | |
[email protected] | e3bc88e | 2013-09-06 06:22:06 | [diff] [blame] | 513 | const aura::Window* RootWindowController::GetTopmostFullscreenWindow() const { |
| 514 | const aura::Window::Windows& windows = |
| 515 | GetContainer(kShellWindowId_DefaultContainer)->children(); |
| 516 | for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); |
| 517 | iter != windows.rend(); ++iter) { |
[email protected] | a41b4e1 | 2013-09-20 04:36:34 | [diff] [blame] | 518 | if (wm::GetWindowState(*iter)->IsFullscreen()) |
[email protected] | e3bc88e | 2013-09-06 06:22:06 | [diff] [blame] | 519 | return *iter; |
[email protected] | 2ee2f5d | 2013-01-10 23:37:16 | [diff] [blame] | 520 | } |
[email protected] | 700849f | 2013-04-30 17:49:20 | [diff] [blame] | 521 | return NULL; |
[email protected] | 2ee2f5d | 2013-01-10 23:37:16 | [diff] [blame] | 522 | } |
| 523 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 524 | void RootWindowController::ActivateKeyboard( |
| 525 | keyboard::KeyboardController* keyboard_controller) { |
| 526 | if (!keyboard::IsKeyboardEnabled() || |
| 527 | GetContainer(kShellWindowId_VirtualKeyboardContainer)) { |
| 528 | return; |
| 529 | } |
| 530 | DCHECK(keyboard_controller); |
| 531 | keyboard_controller->AddObserver(shelf()->shelf_layout_manager()); |
| 532 | keyboard_controller->AddObserver(panel_layout_manager_); |
| 533 | keyboard_controller->AddObserver(docked_layout_manager_); |
| 534 | aura::Window* parent = root_window(); |
| 535 | aura::Window* keyboard_container = |
| 536 | keyboard_controller->GetContainerWindow(); |
| 537 | keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); |
| 538 | parent->AddChild(keyboard_container); |
| 539 | // TODO(oshima): Bounds of keyboard container should be handled by |
| 540 | // RootWindowLayoutManager. Remove this after fixed RootWindowLayoutManager. |
| 541 | keyboard_container->SetBounds(parent->bounds()); |
| 542 | } |
[email protected] | 86459e2c | 2013-04-10 13:39:24 | [diff] [blame] | 543 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 544 | void RootWindowController::DeactivateKeyboard( |
| 545 | keyboard::KeyboardController* keyboard_controller) { |
| 546 | if (!keyboard::IsKeyboardEnabled()) |
| 547 | return; |
[email protected] | 5416f28 | 2013-04-29 20:52:48 | [diff] [blame] | 548 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 549 | DCHECK(keyboard_controller); |
| 550 | aura::Window* keyboard_container = |
| 551 | keyboard_controller->GetContainerWindow(); |
| 552 | if (keyboard_container->GetRootWindow() == root_window()) { |
| 553 | root_window()->RemoveChild(keyboard_container); |
| 554 | keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager()); |
| 555 | keyboard_controller->RemoveObserver(panel_layout_manager_); |
| 556 | keyboard_controller->RemoveObserver(docked_layout_manager_); |
[email protected] | 86459e2c | 2013-04-10 13:39:24 | [diff] [blame] | 557 | } |
| 558 | } |
| 559 | |
| 560 | |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 561 | //////////////////////////////////////////////////////////////////////////////// |
| 562 | // RootWindowController, private: |
| 563 | |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 564 | RootWindowController::RootWindowController(aura::RootWindow* root_window) |
| 565 | : root_window_(root_window), |
| 566 | root_window_layout_(NULL), |
| 567 | docked_layout_manager_(NULL), |
| 568 | panel_layout_manager_(NULL), |
| 569 | touch_hud_debug_(NULL), |
| 570 | touch_hud_projection_(NULL) { |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 571 | GetRootWindowSettings(root_window_->window())->controller = this; |
| 572 | screen_dimmer_.reset(new ScreenDimmer(root_window_->window())); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 573 | |
| 574 | stacking_controller_.reset(new StackingController); |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 575 | aura::client::SetWindowTreeClient(root_window_->window(), |
| 576 | stacking_controller_.get()); |
| 577 | capture_client_.reset( |
| 578 | new views::corewm::ScopedCaptureClient(root_window_->window())); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 579 | } |
| 580 | |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 581 | void RootWindowController::Init(RootWindowType root_window_type, |
| 582 | bool first_run_after_boot) { |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 583 | Shell::GetInstance()->InitRootWindow(root_window()); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 584 | |
| 585 | root_window_->SetCursor(ui::kCursorPointer); |
| 586 | CreateContainersInRootWindow(root_window_.get()); |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 587 | |
| 588 | if (root_window_type == VIRTUAL_KEYBOARD) |
| 589 | return; |
| 590 | |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 591 | CreateSystemBackground(first_run_after_boot); |
| 592 | |
| 593 | InitLayoutManagers(); |
| 594 | InitTouchHuds(); |
| 595 | |
| 596 | if (Shell::GetPrimaryRootWindowController()-> |
| 597 | GetSystemModalLayoutManager(NULL)->has_modal_background()) { |
| 598 | GetSystemModalLayoutManager(NULL)->CreateModalBackground(); |
| 599 | } |
| 600 | |
| 601 | Shell* shell = Shell::GetInstance(); |
| 602 | shell->AddShellObserver(this); |
| 603 | |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 604 | if (root_window_type == PRIMARY) { |
[email protected] | a356579 | 2013-10-18 12:52:37 | [diff] [blame] | 605 | root_window_layout()->OnWindowResized(); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 606 | shell->InitKeyboard(this); |
| 607 | } else { |
| 608 | root_window_layout()->OnWindowResized(); |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 609 | shell->desktop_background_controller()->OnRootWindowAdded(root_window()); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 610 | shell->high_contrast_controller()->OnRootWindowAdded(root_window_.get()); |
| 611 | root_window_->ShowRootWindow(); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 612 | |
| 613 | // Create a launcher if a user is already logged. |
| 614 | if (shell->session_state_delegate()->NumberOfLoggedInUsers()) |
| 615 | shelf()->CreateLauncher(); |
| 616 | } |
| 617 | } |
| 618 | |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 619 | void RootWindowController::InitLayoutManagers() { |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 620 | root_window_layout_ = new RootWindowLayoutManager(root_window()); |
| 621 | root_window()->SetLayoutManager(root_window_layout_); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 622 | |
| 623 | aura::Window* default_container = |
| 624 | GetContainer(kShellWindowId_DefaultContainer); |
| 625 | // Workspace manager has its own layout managers. |
| 626 | workspace_controller_.reset( |
| 627 | new WorkspaceController(default_container)); |
| 628 | |
| 629 | aura::Window* always_on_top_container = |
| 630 | GetContainer(kShellWindowId_AlwaysOnTopContainer); |
| 631 | always_on_top_container->SetLayoutManager( |
| 632 | new BaseLayoutManager( |
| 633 | always_on_top_container->GetRootWindow())); |
| 634 | always_on_top_controller_.reset(new internal::AlwaysOnTopController); |
| 635 | always_on_top_controller_->SetAlwaysOnTopContainer(always_on_top_container); |
| 636 | |
| 637 | DCHECK(!shelf_.get()); |
| 638 | aura::Window* shelf_container = |
| 639 | GetContainer(internal::kShellWindowId_ShelfContainer); |
| 640 | // TODO(harrym): Remove when status area is view. |
| 641 | aura::Window* status_container = |
| 642 | GetContainer(internal::kShellWindowId_StatusContainer); |
| 643 | shelf_.reset(new ShelfWidget( |
| 644 | shelf_container, status_container, workspace_controller())); |
| 645 | |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 646 | if (!Shell::GetInstance()->session_state_delegate()-> |
| 647 | IsActiveUserSessionStarted()) { |
| 648 | // This window exists only to be a event target on login screen. |
| 649 | // It does not have to handle events, nor be visible. |
| 650 | mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); |
| 651 | mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); |
| 652 | |
| 653 | aura::Window* lock_background_container = |
| 654 | GetContainer(internal::kShellWindowId_LockScreenBackgroundContainer); |
| 655 | lock_background_container->AddChild(mouse_event_target_.get()); |
| 656 | mouse_event_target_->Show(); |
| 657 | } |
| 658 | |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 659 | // Create Docked windows layout manager |
| 660 | aura::Window* docked_container = GetContainer( |
| 661 | internal::kShellWindowId_DockedContainer); |
| 662 | docked_layout_manager_ = |
[email protected] | 375069e | 2013-10-04 13:54:31 | [diff] [blame] | 663 | new internal::DockedWindowLayoutManager(docked_container, |
| 664 | workspace_controller()); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 665 | docked_container_handler_.reset( |
| 666 | new ToplevelWindowEventHandler(docked_container)); |
| 667 | docked_container->SetLayoutManager(docked_layout_manager_); |
| 668 | |
| 669 | // Create Panel layout manager |
| 670 | aura::Window* panel_container = GetContainer( |
| 671 | internal::kShellWindowId_PanelContainer); |
| 672 | panel_layout_manager_ = |
| 673 | new internal::PanelLayoutManager(panel_container); |
| 674 | panel_container_handler_.reset( |
| 675 | new PanelWindowEventHandler(panel_container)); |
| 676 | panel_container->SetLayoutManager(panel_layout_manager_); |
| 677 | } |
| 678 | |
| 679 | void RootWindowController::InitTouchHuds() { |
| 680 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 681 | if (command_line->HasSwitch(switches::kAshTouchHud)) |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 682 | set_touch_hud_debug(new TouchHudDebug(root_window())); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 683 | if (Shell::GetInstance()->is_touch_hud_projection_enabled()) |
| 684 | EnableTouchHudProjection(); |
| 685 | } |
| 686 | |
| 687 | void RootWindowController::CreateSystemBackground( |
| 688 | bool is_first_run_after_boot) { |
| 689 | SkColor color = SK_ColorBLACK; |
| 690 | #if defined(OS_CHROMEOS) |
| 691 | if (is_first_run_after_boot) |
| 692 | color = kChromeOsBootColor; |
| 693 | #endif |
| 694 | system_background_.reset( |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 695 | new SystemBackgroundController(root_window(), color)); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 696 | |
| 697 | #if defined(OS_CHROMEOS) |
| 698 | // Make a copy of the system's boot splash screen so we can composite it |
| 699 | // onscreen until the desktop background is ready. |
| 700 | if (is_first_run_after_boot && |
| 701 | (CommandLine::ForCurrentProcess()->HasSwitch( |
| 702 | switches::kAshCopyHostBackgroundAtBoot) || |
| 703 | CommandLine::ForCurrentProcess()->HasSwitch( |
| 704 | switches::kAshAnimateFromBootSplashScreen))) |
| 705 | boot_splash_screen_.reset(new BootSplashScreen(root_window_.get())); |
| 706 | #endif |
| 707 | } |
| 708 | |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 709 | void RootWindowController::CreateContainersInRootWindow( |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 710 | aura::Window* root_window) { |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 711 | // These containers are just used by PowerButtonController to animate groups |
| 712 | // of containers simultaneously without messing up the current transformations |
| 713 | // on those containers. These are direct children of the root window; all of |
| 714 | // the other containers are their children. |
[email protected] | e6e41d2f | 2012-10-29 19:22:19 | [diff] [blame] | 715 | |
| 716 | // The desktop background container is not part of the lock animation, so it |
| 717 | // is not included in those animate groups. |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 718 | // When screen is locked desktop background is moved to lock screen background |
| 719 | // container (moved back on unlock). We want to make sure that there's an |
| 720 | // opaque layer occluding the non-lock-screen layers. |
[email protected] | e6e41d2f | 2012-10-29 19:22:19 | [diff] [blame] | 721 | aura::Window* desktop_background_container = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 722 | kShellWindowId_DesktopBackgroundContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 723 | "DesktopBackgroundContainer", |
| 724 | root_window); |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 725 | views::corewm::SetChildWindowVisibilityChangesAnimated( |
| 726 | desktop_background_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 727 | |
| 728 | aura::Window* non_lock_screen_containers = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 729 | kShellWindowId_NonLockScreenContainersContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 730 | "NonLockScreenContainersContainer", |
| 731 | root_window); |
| 732 | |
| 733 | aura::Window* lock_background_containers = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 734 | kShellWindowId_LockScreenBackgroundContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 735 | "LockScreenBackgroundContainer", |
| 736 | root_window); |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 737 | views::corewm::SetChildWindowVisibilityChangesAnimated( |
| 738 | lock_background_containers); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 739 | |
| 740 | aura::Window* lock_screen_containers = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 741 | kShellWindowId_LockScreenContainersContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 742 | "LockScreenContainersContainer", |
| 743 | root_window); |
| 744 | aura::Window* lock_screen_related_containers = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 745 | kShellWindowId_LockScreenRelatedContainersContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 746 | "LockScreenRelatedContainersContainer", |
| 747 | root_window); |
| 748 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 749 | CreateContainer(kShellWindowId_UnparentedControlContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 750 | "UnparentedControlContainer", |
| 751 | non_lock_screen_containers); |
| 752 | |
| 753 | aura::Window* default_container = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 754 | kShellWindowId_DefaultContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 755 | "DefaultContainer", |
| 756 | non_lock_screen_containers); |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 757 | views::corewm::SetChildWindowVisibilityChangesAnimated(default_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 758 | SetUsesScreenCoordinates(default_container); |
| 759 | |
| 760 | aura::Window* always_on_top_container = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 761 | kShellWindowId_AlwaysOnTopContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 762 | "AlwaysOnTopContainer", |
| 763 | non_lock_screen_containers); |
| 764 | always_on_top_container_handler_.reset( |
| 765 | new ToplevelWindowEventHandler(always_on_top_container)); |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 766 | views::corewm::SetChildWindowVisibilityChangesAnimated( |
| 767 | always_on_top_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 768 | SetUsesScreenCoordinates(always_on_top_container); |
| 769 | |
[email protected] | beb4e5c | 2013-06-18 15:37:07 | [diff] [blame] | 770 | aura::Window* docked_container = CreateContainer( |
| 771 | kShellWindowId_DockedContainer, |
| 772 | "DockedContainer", |
| 773 | non_lock_screen_containers); |
[email protected] | 5eab6e9 | 2013-09-19 19:09:27 | [diff] [blame] | 774 | views::corewm::SetChildWindowVisibilityChangesAnimated(docked_container); |
[email protected] | beb4e5c | 2013-06-18 15:37:07 | [diff] [blame] | 775 | SetUsesScreenCoordinates(docked_container); |
| 776 | |
[email protected] | 3f13cf1 | 2013-07-12 05:13:59 | [diff] [blame] | 777 | aura::Window* shelf_container = |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 778 | CreateContainer(kShellWindowId_ShelfContainer, |
[email protected] | 3f13cf1 | 2013-07-12 05:13:59 | [diff] [blame] | 779 | "ShelfContainer", |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 780 | non_lock_screen_containers); |
[email protected] | 3f13cf1 | 2013-07-12 05:13:59 | [diff] [blame] | 781 | SetUsesScreenCoordinates(shelf_container); |
| 782 | DescendantShouldStayInSameRootWindow(shelf_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 783 | |
[email protected] | f2026eb | 2013-10-22 14:28:56 | [diff] [blame] | 784 | aura::Window* panel_container = CreateContainer( |
| 785 | kShellWindowId_PanelContainer, |
| 786 | "PanelContainer", |
| 787 | non_lock_screen_containers); |
| 788 | SetUsesScreenCoordinates(panel_container); |
| 789 | |
| 790 | aura::Window* shelf_bubble_container = |
| 791 | CreateContainer(kShellWindowId_ShelfBubbleContainer, |
| 792 | "ShelfBubbleContainer", |
| 793 | non_lock_screen_containers); |
| 794 | SetUsesScreenCoordinates(shelf_bubble_container); |
| 795 | DescendantShouldStayInSameRootWindow(shelf_bubble_container); |
| 796 | |
[email protected] | dc851a4e5 | 2012-10-03 00:05:55 | [diff] [blame] | 797 | aura::Window* app_list_container = |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 798 | CreateContainer(kShellWindowId_AppListContainer, |
[email protected] | dc851a4e5 | 2012-10-03 00:05:55 | [diff] [blame] | 799 | "AppListContainer", |
| 800 | non_lock_screen_containers); |
| 801 | SetUsesScreenCoordinates(app_list_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 802 | |
| 803 | aura::Window* modal_container = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 804 | kShellWindowId_SystemModalContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 805 | "SystemModalContainer", |
| 806 | non_lock_screen_containers); |
| 807 | modal_container_handler_.reset( |
| 808 | new ToplevelWindowEventHandler(modal_container)); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 809 | modal_container->SetLayoutManager( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 810 | new SystemModalContainerLayoutManager(modal_container)); |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 811 | views::corewm::SetChildWindowVisibilityChangesAnimated(modal_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 812 | SetUsesScreenCoordinates(modal_container); |
| 813 | |
| 814 | aura::Window* input_method_container = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 815 | kShellWindowId_InputMethodContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 816 | "InputMethodContainer", |
| 817 | non_lock_screen_containers); |
[email protected] | 649eb746 | 2013-10-24 07:52:01 | [diff] [blame] | 818 | views::corewm::SetChildWindowVisibilityChangesAnimated( |
| 819 | input_method_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 820 | SetUsesScreenCoordinates(input_method_container); |
| 821 | |
| 822 | // TODO(beng): Figure out if we can make this use |
| 823 | // SystemModalContainerEventFilter instead of stops_event_propagation. |
| 824 | aura::Window* lock_container = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 825 | kShellWindowId_LockScreenContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 826 | "LockScreenContainer", |
| 827 | lock_screen_containers); |
| 828 | lock_container->SetLayoutManager( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 829 | new BaseLayoutManager(root_window)); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 830 | SetUsesScreenCoordinates(lock_container); |
| 831 | // TODO(beng): stopsevents |
| 832 | |
| 833 | aura::Window* lock_modal_container = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 834 | kShellWindowId_LockSystemModalContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 835 | "LockSystemModalContainer", |
| 836 | lock_screen_containers); |
| 837 | lock_modal_container_handler_.reset( |
| 838 | new ToplevelWindowEventHandler(lock_modal_container)); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 839 | lock_modal_container->SetLayoutManager( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 840 | new SystemModalContainerLayoutManager(lock_modal_container)); |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 841 | views::corewm::SetChildWindowVisibilityChangesAnimated(lock_modal_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 842 | SetUsesScreenCoordinates(lock_modal_container); |
| 843 | |
| 844 | aura::Window* status_container = |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 845 | CreateContainer(kShellWindowId_StatusContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 846 | "StatusContainer", |
| 847 | lock_screen_related_containers); |
| 848 | SetUsesScreenCoordinates(status_container); |
[email protected] | e887c6c | 2013-07-08 19:35:53 | [diff] [blame] | 849 | DescendantShouldStayInSameRootWindow(status_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 850 | |
| 851 | aura::Window* settings_bubble_container = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 852 | kShellWindowId_SettingBubbleContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 853 | "SettingBubbleContainer", |
| 854 | lock_screen_related_containers); |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 855 | views::corewm::SetChildWindowVisibilityChangesAnimated( |
| 856 | settings_bubble_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 857 | SetUsesScreenCoordinates(settings_bubble_container); |
[email protected] | e887c6c | 2013-07-08 19:35:53 | [diff] [blame] | 858 | DescendantShouldStayInSameRootWindow(settings_bubble_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 859 | |
| 860 | aura::Window* menu_container = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 861 | kShellWindowId_MenuContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 862 | "MenuContainer", |
| 863 | lock_screen_related_containers); |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 864 | views::corewm::SetChildWindowVisibilityChangesAnimated(menu_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 865 | SetUsesScreenCoordinates(menu_container); |
| 866 | |
| 867 | aura::Window* drag_drop_container = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 868 | kShellWindowId_DragImageAndTooltipContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 869 | "DragImageAndTooltipContainer", |
| 870 | lock_screen_related_containers); |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 871 | views::corewm::SetChildWindowVisibilityChangesAnimated(drag_drop_container); |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 872 | SetUsesScreenCoordinates(drag_drop_container); |
| 873 | |
| 874 | aura::Window* overlay_container = CreateContainer( |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 875 | kShellWindowId_OverlayContainer, |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 876 | "OverlayContainer", |
| 877 | lock_screen_related_containers); |
| 878 | SetUsesScreenCoordinates(overlay_container); |
[email protected] | a07615f | 2012-10-24 08:23:08 | [diff] [blame] | 879 | |
| 880 | CreateContainer(kShellWindowId_PowerButtonAnimationContainer, |
| 881 | "PowerButtonAnimationContainer", root_window) ; |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 882 | } |
| 883 | |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 884 | void RootWindowController::EnableTouchHudProjection() { |
| 885 | if (touch_hud_projection_) |
| 886 | return; |
[email protected] | 41baaed | 2013-11-09 04:18:26 | [diff] [blame^] | 887 | set_touch_hud_projection(new TouchHudProjection(root_window())); |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | void RootWindowController::DisableTouchHudProjection() { |
| 891 | if (!touch_hud_projection_) |
| 892 | return; |
| 893 | touch_hud_projection_->Remove(); |
| 894 | } |
| 895 | |
| 896 | void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { |
| 897 | shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| 898 | } |
| 899 | |
| 900 | void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
| 901 | if (enabled) |
| 902 | EnableTouchHudProjection(); |
| 903 | else |
| 904 | DisableTouchHudProjection(); |
| 905 | } |
| 906 | |
[email protected] | 6b2d4a0b | 2013-09-06 06:29:54 | [diff] [blame] | 907 | RootWindowController* GetRootWindowController( |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 908 | const aura::Window* root_window) { |
[email protected] | 6b2d4a0b | 2013-09-06 06:29:54 | [diff] [blame] | 909 | return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
| 910 | } |
| 911 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 912 | } // namespace internal |
| 913 | } // namespace ash |