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