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