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