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