[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 | |
sky | 0702b27 | 2016-06-03 22:10:41 | [diff] [blame] | 10 | #include "ash/aura/aura_layout_manager_adapter.h" |
sky | d053905c | 2016-08-30 22:37:35 | [diff] [blame] | 11 | #include "ash/aura/wm_root_window_controller_aura.h" |
sky | 0702b27 | 2016-06-03 22:10:41 | [diff] [blame] | 12 | #include "ash/aura/wm_shelf_aura.h" |
| 13 | #include "ash/aura/wm_window_aura.h" |
jamescook | e044e1c | 2016-06-13 20:56:18 | [diff] [blame] | 14 | #include "ash/common/ash_constants.h" |
msw | d9b1b34 | 2016-06-17 20:19:57 | [diff] [blame] | 15 | #include "ash/common/ash_switches.h" |
jamescook | 26f3209 | 2016-06-17 04:26:52 | [diff] [blame] | 16 | #include "ash/common/focus_cycler.h" |
msw | b241605 | 2016-06-24 21:23:45 | [diff] [blame] | 17 | #include "ash/common/login_status.h" |
jamescook | 2b624c5a | 2016-06-08 01:34:02 | [diff] [blame] | 18 | #include "ash/common/session/session_state_delegate.h" |
jamescook | 361185a2 | 2016-08-13 00:12:09 | [diff] [blame] | 19 | #include "ash/common/shelf/shelf_delegate.h" |
msw | df64c66b | 2016-08-23 18:56:37 | [diff] [blame] | 20 | #include "ash/common/shelf/shelf_layout_manager.h" |
jamescook | 1b474d6a | 2016-06-04 05:56:00 | [diff] [blame] | 21 | #include "ash/common/shelf/shelf_types.h" |
msw | df64c66b | 2016-08-23 18:56:37 | [diff] [blame] | 22 | #include "ash/common/shelf/shelf_widget.h" |
msw | 0414d412 | 2016-07-06 22:58:48 | [diff] [blame] | 23 | #include "ash/common/shell_delegate.h" |
sky | c096d9f | 2016-06-02 13:46:26 | [diff] [blame] | 24 | #include "ash/common/shell_window_ids.h" |
msw | df64c66b | 2016-08-23 18:56:37 | [diff] [blame] | 25 | #include "ash/common/system/status_area_layout_manager.h" |
jamescook | 625f791 | 2016-07-14 01:00:52 | [diff] [blame] | 26 | #include "ash/common/system/status_area_widget.h" |
jamescook | 2a4d1eb | 2016-06-09 20:10:07 | [diff] [blame] | 27 | #include "ash/common/system/tray/system_tray_delegate.h" |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 28 | #include "ash/common/wallpaper/wallpaper_delegate.h" |
msw | 3f439af | 2016-09-08 22:35:26 | [diff] [blame] | 29 | #include "ash/common/wallpaper/wallpaper_widget_controller.h" |
sky | d606377 | 2016-06-01 17:52:21 | [diff] [blame] | 30 | #include "ash/common/wm/always_on_top_controller.h" |
| 31 | #include "ash/common/wm/container_finder.h" |
| 32 | #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 33 | #include "ash/common/wm/fullscreen_window_finder.h" |
| 34 | #include "ash/common/wm/panels/panel_layout_manager.h" |
sky | c096d9f | 2016-06-02 13:46:26 | [diff] [blame] | 35 | #include "ash/common/wm/root_window_layout_manager.h" |
sky | d606377 | 2016-06-01 17:52:21 | [diff] [blame] | 36 | #include "ash/common/wm/switchable_windows.h" |
sky | ea4ca94 | 2016-09-12 21:56:19 | [diff] [blame] | 37 | #include "ash/common/wm/system_modal_container_layout_manager.h" |
sky | d606377 | 2016-06-01 17:52:21 | [diff] [blame] | 38 | #include "ash/common/wm/window_state.h" |
sky | d606377 | 2016-06-01 17:52:21 | [diff] [blame] | 39 | #include "ash/common/wm/workspace/workspace_layout_manager.h" |
sky | f71e6c9 | 2016-08-30 18:49:19 | [diff] [blame] | 40 | #include "ash/common/wm/workspace_controller.h" |
sky | 0702b27 | 2016-06-03 22:10:41 | [diff] [blame] | 41 | #include "ash/common/wm_shell.h" |
| 42 | #include "ash/common/wm_window.h" |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 43 | #include "ash/display/display_manager.h" |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 44 | #include "ash/high_contrast/high_contrast_controller.h" |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 45 | #include "ash/host/ash_window_tree_host.h" |
[email protected] | f8e6aad | 2013-08-30 21:49:11 | [diff] [blame] | 46 | #include "ash/root_window_settings.h" |
jamescook | 752e8df | 2016-08-09 19:54:39 | [diff] [blame] | 47 | #include "ash/shelf/shelf_window_targeter.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 48 | #include "ash/shell.h" |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 49 | #include "ash/touch/touch_hud_debug.h" |
| 50 | #include "ash/touch/touch_hud_projection.h" |
[email protected] | 80549c15 | 2013-07-02 01:42:47 | [diff] [blame] | 51 | #include "ash/touch/touch_observer_hud.h" |
[email protected] | 68d5133 | 2014-06-06 13:51:13 | [diff] [blame] | 52 | #include "ash/wm/lock_layout_manager.h" |
[email protected] | b8642ec | 2014-04-17 05:20:39 | [diff] [blame] | 53 | #include "ash/wm/panels/attached_panel_window_targeter.h" |
[email protected] | 10065941 | 2013-06-21 22:59:55 | [diff] [blame] | 54 | #include "ash/wm/panels/panel_window_event_handler.h" |
[email protected] | 2a2caa0 | 2013-01-22 20:50:36 | [diff] [blame] | 55 | #include "ash/wm/stacking_controller.h" |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 56 | #include "ash/wm/system_wallpaper_controller.h" |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 57 | #include "ash/wm/window_properties.h" |
sky | 8d5646fe | 2016-04-15 17:03:46 | [diff] [blame] | 58 | #include "ash/wm/window_state_aura.h" |
[email protected] | 700849f | 2013-04-30 17:49:20 | [diff] [blame] | 59 | #include "ash/wm/window_util.h" |
[email protected] | e6e41d2f | 2012-10-29 19:22:19 | [diff] [blame] | 60 | #include "base/command_line.h" |
jonross | a90d898 | 2016-05-16 18:14:25 | [diff] [blame] | 61 | #include "base/macros.h" |
sky | 1e30f06 | 2016-04-14 21:19:16 | [diff] [blame] | 62 | #include "base/memory/ptr_util.h" |
[email protected] | 1e84c63 | 2013-06-27 23:12:21 | [diff] [blame] | 63 | #include "base/time/time.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 64 | #include "ui/aura/client/aura_constants.h" |
[email protected] | 2374d181 | 2014-03-04 03:42:27 | [diff] [blame] | 65 | #include "ui/aura/client/screen_position_client.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 66 | #include "ui/aura/window.h" |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 67 | #include "ui/aura/window_delegate.h" |
[email protected] | fcc51c95 | 2014-02-21 21:31:26 | [diff] [blame] | 68 | #include "ui/aura/window_event_dispatcher.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 69 | #include "ui/aura/window_observer.h" |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 70 | #include "ui/aura/window_tracker.h" |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 71 | #include "ui/base/hit_test.h" |
oshima | f84b0da72 | 2016-04-27 19:47:19 | [diff] [blame] | 72 | #include "ui/display/display.h" |
| 73 | #include "ui/display/screen.h" |
[email protected] | 86459e2c | 2013-04-10 13:39:24 | [diff] [blame] | 74 | #include "ui/keyboard/keyboard_controller.h" |
| 75 | #include "ui/keyboard/keyboard_util.h" |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 76 | #include "ui/views/view_model.h" |
| 77 | #include "ui/views/view_model_utils.h" |
[email protected] | ee3ed1077 | 2014-03-11 22:02:01 | [diff] [blame] | 78 | #include "ui/wm/core/capture_controller.h" |
| 79 | #include "ui/wm/core/visibility_controller.h" |
| 80 | #include "ui/wm/core/window_util.h" |
[email protected] | af4552b2 | 2014-03-21 19:45:01 | [diff] [blame] | 81 | #include "ui/wm/public/drag_drop_client.h" |
| 82 | #include "ui/wm/public/tooltip_client.h" |
[email protected] | 5b251f1 | 2013-12-19 01:50:05 | [diff] [blame] | 83 | #include "ui/wm/public/window_types.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 84 | |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 85 | #if defined(OS_CHROMEOS) |
[email protected] | 7d48759 | 2014-07-24 03:54:50 | [diff] [blame] | 86 | #include "ash/ash_touch_exploration_manager_chromeos.h" |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 87 | #include "ash/wm/boot_splash_screen_chromeos.h" |
[email protected] | a825e831 | 2014-05-05 22:05:01 | [diff] [blame] | 88 | #include "ui/chromeos/touch_exploration_controller.h" |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 89 | #endif |
| 90 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 91 | namespace ash { |
| 92 | namespace { |
| 93 | |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 94 | #if defined(OS_CHROMEOS) |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 95 | // Duration for the animation that hides the boot splash screen, in |
| 96 | // milliseconds. This should be short enough in relation to |
| 97 | // wm/window_animation.cc's brightness/grayscale fade animation that the login |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 98 | // wallpaper image animation isn't hidden by the splash screen animation. |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 99 | const int kBootSplashScreenHideDurationMs = 500; |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 100 | #endif |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 101 | |
[email protected] | 2816c246 | 2013-12-17 02:22:25 | [diff] [blame] | 102 | float ToRelativeValue(int value, int src, int dst) { |
| 103 | return static_cast<float>(value) / static_cast<float>(src) * dst; |
| 104 | } |
| 105 | |
| 106 | void MoveOriginRelativeToSize(const gfx::Size& src_size, |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 107 | const gfx::Size& dst_size, |
| 108 | gfx::Rect* bounds_in_out) { |
[email protected] | 2816c246 | 2013-12-17 02:22:25 | [diff] [blame] | 109 | gfx::Point origin = bounds_in_out->origin(); |
| 110 | bounds_in_out->set_origin(gfx::Point( |
| 111 | ToRelativeValue(origin.x(), src_size.width(), dst_size.width()), |
| 112 | ToRelativeValue(origin.y(), src_size.height(), dst_size.height()))); |
| 113 | } |
| 114 | |
[email protected] | 9505857 | 2012-08-20 14:57:29 | [diff] [blame] | 115 | // Reparents |window| to |new_parent|. |
| 116 | void ReparentWindow(aura::Window* window, aura::Window* new_parent) { |
[email protected] | 2816c246 | 2013-12-17 02:22:25 | [diff] [blame] | 117 | const gfx::Size src_size = window->parent()->bounds().size(); |
| 118 | const gfx::Size dst_size = new_parent->bounds().size(); |
[email protected] | 9505857 | 2012-08-20 14:57:29 | [diff] [blame] | 119 | // Update the restore bounds to make it relative to the display. |
[email protected] | a41b4e1 | 2013-09-20 04:36:34 | [diff] [blame] | 120 | wm::WindowState* state = wm::GetWindowState(window); |
| 121 | gfx::Rect restore_bounds; |
| 122 | bool has_restore_bounds = state->HasRestoreBounds(); |
[email protected] | 2816c246 | 2013-12-17 02:22:25 | [diff] [blame] | 123 | |
[email protected] | 9cfd3d1 | 2014-02-25 15:33:45 | [diff] [blame] | 124 | bool update_bounds = (state->IsNormalOrSnapped() || state->IsMinimized()) && |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 125 | new_parent->id() != kShellWindowId_DockedContainer; |
[email protected] | 2816c246 | 2013-12-17 02:22:25 | [diff] [blame] | 126 | gfx::Rect local_bounds; |
| 127 | if (update_bounds) { |
sky | 0702b27 | 2016-06-03 22:10:41 | [diff] [blame] | 128 | local_bounds = WmWindowAura::GetAuraWindow(state->window())->bounds(); |
[email protected] | 2816c246 | 2013-12-17 02:22:25 | [diff] [blame] | 129 | MoveOriginRelativeToSize(src_size, dst_size, &local_bounds); |
| 130 | } |
| 131 | |
| 132 | if (has_restore_bounds) { |
[email protected] | a41b4e1 | 2013-09-20 04:36:34 | [diff] [blame] | 133 | restore_bounds = state->GetRestoreBoundsInParent(); |
[email protected] | 2816c246 | 2013-12-17 02:22:25 | [diff] [blame] | 134 | MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds); |
| 135 | } |
| 136 | |
[email protected] | 9505857 | 2012-08-20 14:57:29 | [diff] [blame] | 137 | new_parent->AddChild(window); |
[email protected] | 2816c246 | 2013-12-17 02:22:25 | [diff] [blame] | 138 | |
[email protected] | 8663b7a6 | 2014-01-18 01:24:21 | [diff] [blame] | 139 | // Docked windows have bounds handled by the layout manager in AddChild(). |
[email protected] | 2816c246 | 2013-12-17 02:22:25 | [diff] [blame] | 140 | if (update_bounds) |
| 141 | window->SetBounds(local_bounds); |
| 142 | |
[email protected] | a41b4e1 | 2013-09-20 04:36:34 | [diff] [blame] | 143 | if (has_restore_bounds) |
| 144 | state->SetRestoreBoundsInParent(restore_bounds); |
[email protected] | 9505857 | 2012-08-20 14:57:29 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | // Reparents the appropriate set of windows from |src| to |dst|. |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 148 | void ReparentAllWindows(aura::Window* src, aura::Window* dst) { |
[email protected] | 9505857 | 2012-08-20 14:57:29 | [diff] [blame] | 149 | // Set of windows to move. |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 150 | const int kContainerIdsToMove[] = { |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 151 | kShellWindowId_DefaultContainer, |
| 152 | kShellWindowId_DockedContainer, |
| 153 | kShellWindowId_PanelContainer, |
| 154 | kShellWindowId_AlwaysOnTopContainer, |
| 155 | kShellWindowId_SystemModalContainer, |
| 156 | kShellWindowId_LockSystemModalContainer, |
tengs | f98986c | 2014-12-06 01:42:21 | [diff] [blame] | 157 | kShellWindowId_UnparentedControlContainer, |
oshima | 022a954 | 2015-05-01 00:15:02 | [diff] [blame] | 158 | kShellWindowId_OverlayContainer, |
| 159 | }; |
| 160 | const int kExtraContainerIdsToMoveInUnifiedMode[] = { |
| 161 | kShellWindowId_LockScreenContainer, |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 162 | kShellWindowId_LockScreenWallpaperContainer, |
oshima | 022a954 | 2015-05-01 00:15:02 | [diff] [blame] | 163 | }; |
| 164 | std::vector<int> container_ids( |
| 165 | kContainerIdsToMove, |
| 166 | kContainerIdsToMove + arraysize(kContainerIdsToMove)); |
| 167 | // Check the default_multi_display_mode because this is also necessary |
| 168 | // in trasition between mirror <-> unified mode. |
oshima | 628a617 | 2015-08-01 01:33:14 | [diff] [blame] | 169 | if (Shell::GetInstance() |
| 170 | ->display_manager() |
| 171 | ->current_default_multi_display_mode() == DisplayManager::UNIFIED) { |
oshima | 022a954 | 2015-05-01 00:15:02 | [diff] [blame] | 172 | for (int id : kExtraContainerIdsToMoveInUnifiedMode) |
| 173 | container_ids.push_back(id); |
| 174 | } |
| 175 | |
| 176 | for (int id : container_ids) { |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 177 | aura::Window* src_container = Shell::GetContainer(src, id); |
| 178 | aura::Window* dst_container = Shell::GetContainer(dst, id); |
[email protected] | 5b602190 | 2013-02-26 05:33:29 | [diff] [blame] | 179 | while (!src_container->children().empty()) { |
| 180 | // Restart iteration from the source container windows each time as they |
| 181 | // may change as a result of moving other windows. |
| 182 | aura::Window::Windows::const_iterator iter = |
| 183 | src_container->children().begin(); |
| 184 | while (iter != src_container->children().end() && |
sky | ea4ca94 | 2016-09-12 21:56:19 | [diff] [blame] | 185 | SystemModalContainerLayoutManager::IsModalBackground( |
| 186 | WmWindowAura::Get(*iter))) { |
[email protected] | 5b602190 | 2013-02-26 05:33:29 | [diff] [blame] | 187 | ++iter; |
| 188 | } |
| 189 | // If the entire window list is modal background windows then stop. |
| 190 | if (iter == src_container->children().end()) |
| 191 | break; |
| 192 | ReparentWindow(*iter, dst_container); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
oshima | 9a61ecf | 2016-06-18 10:43:05 | [diff] [blame] | 197 | bool IsWindowAboveContainer(aura::Window* window, |
| 198 | aura::Window* blocking_container) { |
| 199 | std::vector<aura::Window*> target_path; |
| 200 | std::vector<aura::Window*> blocking_path; |
| 201 | |
| 202 | while (window) { |
| 203 | target_path.push_back(window); |
| 204 | window = window->parent(); |
| 205 | } |
| 206 | |
| 207 | while (blocking_container) { |
| 208 | blocking_path.push_back(blocking_container); |
| 209 | blocking_container = blocking_container->parent(); |
| 210 | } |
| 211 | |
| 212 | // The root window is put at the end so that we compare windows at |
| 213 | // the same depth. |
| 214 | while (!blocking_path.empty()) { |
| 215 | if (target_path.empty()) |
| 216 | return false; |
| 217 | |
| 218 | aura::Window* target = target_path.back(); |
| 219 | target_path.pop_back(); |
| 220 | aura::Window* blocking = blocking_path.back(); |
| 221 | blocking_path.pop_back(); |
| 222 | |
| 223 | // Still on the same path, continue. |
| 224 | if (target == blocking) |
| 225 | continue; |
| 226 | |
| 227 | // This can happen only if unparented window is passed because |
| 228 | // first element must be the same root. |
| 229 | if (!target->parent() || !blocking->parent()) |
| 230 | return false; |
| 231 | |
| 232 | aura::Window* common_parent = target->parent(); |
| 233 | DCHECK_EQ(common_parent, blocking->parent()); |
| 234 | aura::Window::Windows windows = common_parent->children(); |
| 235 | auto blocking_iter = std::find(windows.begin(), windows.end(), blocking); |
| 236 | // If the target window is above blocking window, the window can handle |
| 237 | // events. |
| 238 | return std::find(blocking_iter, windows.end(), target) != windows.end(); |
| 239 | } |
| 240 | |
| 241 | return true; |
| 242 | } |
| 243 | |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 244 | // A window delegate which does nothing. Used to create a window that |
| 245 | // is a event target, but do nothing. |
| 246 | class EmptyWindowDelegate : public aura::WindowDelegate { |
| 247 | public: |
| 248 | EmptyWindowDelegate() {} |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 249 | ~EmptyWindowDelegate() override {} |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 250 | |
| 251 | // aura::WindowDelegate overrides: |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 252 | gfx::Size GetMinimumSize() const override { return gfx::Size(); } |
| 253 | gfx::Size GetMaximumSize() const override { return gfx::Size(); } |
| 254 | void OnBoundsChanged(const gfx::Rect& old_bounds, |
| 255 | const gfx::Rect& new_bounds) override {} |
| 256 | gfx::NativeCursor GetCursor(const gfx::Point& point) override { |
[email protected] | 62c9f10 | 2014-03-27 06:07:04 | [diff] [blame] | 257 | return gfx::kNullCursor; |
| 258 | } |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 259 | int GetNonClientComponent(const gfx::Point& point) const override { |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 260 | return HTNOWHERE; |
| 261 | } |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 262 | bool ShouldDescendIntoChildForEventHandling( |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 263 | aura::Window* child, |
mostynb | 10d6b38 | 2014-10-03 16:23:45 | [diff] [blame] | 264 | const gfx::Point& location) override { |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 265 | return false; |
| 266 | } |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 267 | bool CanFocus() override { return false; } |
| 268 | void OnCaptureLost() override {} |
danakj | 85d970e | 2015-04-04 00:15:24 | [diff] [blame] | 269 | void OnPaint(const ui::PaintContext& context) override {} |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 270 | void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
| 271 | void OnWindowDestroying(aura::Window* window) override {} |
| 272 | void OnWindowDestroyed(aura::Window* window) override { delete this; } |
| 273 | void OnWindowTargetVisibilityChanged(bool visible) override {} |
| 274 | bool HasHitTestMask() const override { return false; } |
| 275 | void GetHitTestMask(gfx::Path* mask) const override {} |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 276 | |
| 277 | private: |
| 278 | DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); |
| 279 | }; |
| 280 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 281 | } // namespace |
| 282 | |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 283 | void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) { |
[email protected] | 2f262033 | 2014-02-28 10:07:38 | [diff] [blame] | 284 | RootWindowController* controller = new RootWindowController(host); |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 285 | controller->Init(RootWindowController::PRIMARY, |
msw | 0414d412 | 2016-07-06 22:58:48 | [diff] [blame] | 286 | WmShell::Get()->delegate()->IsFirstRunAfterBoot()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 287 | } |
| 288 | |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 289 | void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) { |
[email protected] | 2f262033 | 2014-02-28 10:07:38 | [diff] [blame] | 290 | RootWindowController* controller = new RootWindowController(host); |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 291 | controller->Init(RootWindowController::SECONDARY, false /* first run */); |
| 292 | } |
| 293 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 294 | // static |
[email protected] | ccff3d7 | 2013-02-06 04:26:28 | [diff] [blame] | 295 | RootWindowController* RootWindowController::ForWindow( |
| 296 | const aura::Window* window) { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 297 | CHECK(Shell::HasInstance()); |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 298 | return GetRootWindowController(window->GetRootWindow()); |
| 299 | } |
| 300 | |
| 301 | // static |
[email protected] | d17642d | 2013-09-12 23:44:38 | [diff] [blame] | 302 | RootWindowController* RootWindowController::ForTargetRootWindow() { |
oshima | 9eea82da | 2014-09-13 01:11:07 | [diff] [blame] | 303 | CHECK(Shell::HasInstance()); |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 304 | return GetRootWindowController(Shell::GetTargetRootWindow()); |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 305 | } |
| 306 | |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 307 | RootWindowController::~RootWindowController() { |
| 308 | Shutdown(); |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 309 | ash_host_.reset(); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 310 | // The CaptureClient needs to be around for as long as the RootWindow is |
| 311 | // valid. |
| 312 | capture_client_.reset(); |
| 313 | } |
| 314 | |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 315 | aura::WindowTreeHost* RootWindowController::GetHost() { |
| 316 | return ash_host_->AsWindowTreeHost(); |
| 317 | } |
| 318 | |
| 319 | const aura::WindowTreeHost* RootWindowController::GetHost() const { |
| 320 | return ash_host_->AsWindowTreeHost(); |
| 321 | } |
| 322 | |
| 323 | aura::Window* RootWindowController::GetRootWindow() { |
| 324 | return GetHost()->window(); |
| 325 | } |
| 326 | |
| 327 | const aura::Window* RootWindowController::GetRootWindow() const { |
| 328 | return GetHost()->window(); |
| 329 | } |
| 330 | |
sky | f71e6c9 | 2016-08-30 18:49:19 | [diff] [blame] | 331 | WorkspaceController* RootWindowController::workspace_controller() { |
sky | d053905c | 2016-08-30 22:37:35 | [diff] [blame] | 332 | return wm_root_window_controller_->workspace_controller(); |
sky | f71e6c9 | 2016-08-30 18:49:19 | [diff] [blame] | 333 | } |
| 334 | |
[email protected] | 6675e1c | 2012-09-11 09:15:45 | [diff] [blame] | 335 | void RootWindowController::Shutdown() { |
sky | 88bd4be6 | 2016-06-09 17:34:41 | [diff] [blame] | 336 | WmShell::Get()->RemoveShellObserver(this); |
[email protected] | a825e831 | 2014-05-05 22:05:01 | [diff] [blame] | 337 | |
| 338 | #if defined(OS_CHROMEOS) |
sky | 20686a4c5 | 2016-09-13 01:26:54 | [diff] [blame] | 339 | touch_exploration_manager_.reset(); |
[email protected] | a825e831 | 2014-05-05 22:05:01 | [diff] [blame] | 340 | #endif |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 341 | |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 342 | aura::Window* root_window = GetRootWindow(); |
jamescook | 4545062c | 2016-08-02 18:48:01 | [diff] [blame] | 343 | WmWindow* root_shutting_down = WmWindowAura::Get(root_window); |
| 344 | WmShell* shell = WmShell::Get(); |
[email protected] | d17642d | 2013-09-12 23:44:38 | [diff] [blame] | 345 | // Change the target root window before closing child windows. If any child |
[email protected] | c98a492 | 2013-09-05 20:01:42 | [diff] [blame] | 346 | // 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] | 347 | // window list adding windows from the target root window's containers which |
[email protected] | c98a492 | 2013-09-05 20:01:42 | [diff] [blame] | 348 | // may have already gone away. |
jamescook | 4545062c | 2016-08-02 18:48:01 | [diff] [blame] | 349 | if (shell->GetRootWindowForNewWindows() == root_shutting_down) { |
| 350 | // The root window for new windows is being destroyed. Switch to the primary |
| 351 | // root window if possible. |
| 352 | WmWindow* primary_root = shell->GetPrimaryRootWindow(); |
| 353 | shell->set_root_window_for_new_windows( |
| 354 | primary_root == root_shutting_down ? nullptr : primary_root); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 355 | } |
[email protected] | c98a492 | 2013-09-05 20:01:42 | [diff] [blame] | 356 | |
| 357 | CloseChildWindows(); |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 358 | GetRootWindowSettings(root_window)->controller = NULL; |
[email protected] | 6675e1c | 2012-09-11 09:15:45 | [diff] [blame] | 359 | // Forget with the display ID so that display lookup |
| 360 | // ends up with invalid display. |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 361 | GetRootWindowSettings(root_window)->display_id = |
oshima | f84b0da72 | 2016-04-27 19:47:19 | [diff] [blame] | 362 | display::Display::kInvalidDisplayID; |
[email protected] | 8f5209c | 2014-05-22 20:36:11 | [diff] [blame] | 363 | ash_host_->PrepareForShutdown(); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 364 | |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 365 | system_wallpaper_.reset(); |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 366 | aura::client::SetScreenPositionClient(root_window, NULL); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 367 | } |
| 368 | |
oshima | 9a61ecf | 2016-06-18 10:43:05 | [diff] [blame] | 369 | bool RootWindowController::CanWindowReceiveEvents(aura::Window* window) { |
| 370 | if (GetRootWindow() != window->GetRootWindow()) |
| 371 | return false; |
| 372 | |
| 373 | // Always allow events to fall through to the virtual keyboard even if |
| 374 | // displaying a system modal dialog. |
| 375 | if (IsVirtualKeyboardWindow(window)) |
| 376 | return true; |
| 377 | |
| 378 | aura::Window* blocking_container = nullptr; |
| 379 | |
| 380 | int modal_container_id = 0; |
msw | bc0a8b48 | 2016-06-30 02:21:14 | [diff] [blame] | 381 | if (WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()) { |
oshima | 9a61ecf | 2016-06-18 10:43:05 | [diff] [blame] | 382 | blocking_container = |
| 383 | GetContainer(kShellWindowId_LockScreenContainersContainer); |
| 384 | modal_container_id = kShellWindowId_LockSystemModalContainer; |
| 385 | } else { |
| 386 | modal_container_id = kShellWindowId_SystemModalContainer; |
| 387 | } |
| 388 | aura::Window* modal_container = GetContainer(modal_container_id); |
| 389 | SystemModalContainerLayoutManager* modal_layout_manager = nullptr; |
| 390 | modal_layout_manager = static_cast<SystemModalContainerLayoutManager*>( |
sky | ea4ca94 | 2016-09-12 21:56:19 | [diff] [blame] | 391 | WmWindowAura::Get(modal_container)->GetLayoutManager()); |
oshima | 9a61ecf | 2016-06-18 10:43:05 | [diff] [blame] | 392 | |
sky | b733d418 | 2016-09-09 23:18:38 | [diff] [blame] | 393 | if (modal_layout_manager->has_window_dimmer()) |
oshima | 9a61ecf | 2016-06-18 10:43:05 | [diff] [blame] | 394 | blocking_container = modal_container; |
| 395 | else |
| 396 | modal_container = nullptr; // Don't check modal dialogs. |
| 397 | |
| 398 | // In normal session. |
| 399 | if (!blocking_container) |
| 400 | return true; |
| 401 | |
| 402 | if (!IsWindowAboveContainer(window, blocking_container)) |
| 403 | return false; |
| 404 | |
| 405 | // If the window is in the target modal container, only allow the top most |
| 406 | // one. |
| 407 | if (modal_container && modal_container->Contains(window)) |
sky | ea4ca94 | 2016-09-12 21:56:19 | [diff] [blame] | 408 | return modal_layout_manager->IsPartOfActiveModalWindow( |
| 409 | WmWindowAura::Get(window)); |
oshima | 9a61ecf | 2016-06-18 10:43:05 | [diff] [blame] | 410 | |
| 411 | return true; |
| 412 | } |
| 413 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 414 | aura::Window* RootWindowController::GetContainer(int container_id) { |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 415 | return GetRootWindow()->GetChildById(container_id); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 416 | } |
| 417 | |
[email protected] | d8a2495 | 2013-08-05 20:05:05 | [diff] [blame] | 418 | const aura::Window* RootWindowController::GetContainer(int container_id) const { |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 419 | return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id); |
[email protected] | d8a2495 | 2013-08-05 20:05:05 | [diff] [blame] | 420 | } |
| 421 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 422 | void RootWindowController::ShowShelf() { |
jamescook | 1cad77e9 | 2016-08-31 00:02:26 | [diff] [blame] | 423 | if (!wm_shelf_aura_->IsShelfInitialized()) |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 424 | return; |
jamescook | 1cad77e9 | 2016-08-31 00:02:26 | [diff] [blame] | 425 | // TODO(jamescook): Move this into WmShelf. |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 426 | wm_shelf_aura_->shelf_widget()->SetShelfVisibility(true); |
| 427 | wm_shelf_aura_->shelf_widget()->status_area_widget()->Show(); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 428 | } |
| 429 | |
jamescook | 6500ad13 | 2016-05-27 06:15:54 | [diff] [blame] | 430 | void RootWindowController::CreateShelf() { |
jamescook | 1cad77e9 | 2016-08-31 00:02:26 | [diff] [blame] | 431 | if (wm_shelf_aura_->IsShelfInitialized()) |
jamescook | 6500ad13 | 2016-05-27 06:15:54 | [diff] [blame] | 432 | return; |
jamescook | 1cad77e9 | 2016-08-31 00:02:26 | [diff] [blame] | 433 | wm_shelf_aura_->InitializeShelf(); |
jamescook | 6500ad13 | 2016-05-27 06:15:54 | [diff] [blame] | 434 | |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 435 | if (panel_layout_manager_) |
jamescook | be6ed82 | 2016-06-06 20:08:55 | [diff] [blame] | 436 | panel_layout_manager_->SetShelf(wm_shelf_aura_.get()); |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 437 | if (docked_layout_manager_) { |
jamescook | be6ed82 | 2016-06-06 20:08:55 | [diff] [blame] | 438 | docked_layout_manager_->SetShelf(wm_shelf_aura_.get()); |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 439 | if (wm_shelf_aura_->shelf_layout_manager()) { |
jamescook | 612205f | 2016-05-26 06:02:11 | [diff] [blame] | 440 | docked_layout_manager_->AddObserver( |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 441 | wm_shelf_aura_->shelf_layout_manager()); |
| 442 | } |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 443 | } |
[email protected] | b8642ec | 2014-04-17 05:20:39 | [diff] [blame] | 444 | |
| 445 | // Notify shell observers that the shelf has been created. |
jamescook | 1cad77e9 | 2016-08-31 00:02:26 | [diff] [blame] | 446 | // TODO(jamescook): Move this into WmShelf::InitializeShelf(). This will |
| 447 | // require changing AttachedPanelWidgetTargeter's access to WmShelf. |
msw | 61e1667 | 2016-08-12 16:36:58 | [diff] [blame] | 448 | WmShell::Get()->NotifyShelfCreatedForRootWindow( |
sky | 80556bc4 | 2016-06-07 22:46:13 | [diff] [blame] | 449 | WmWindowAura::Get(GetRootWindow())); |
jamescook | 6500ad13 | 2016-05-27 06:15:54 | [diff] [blame] | 450 | |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 451 | wm_shelf_aura_->shelf_widget()->PostCreateShelf(); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 452 | } |
| 453 | |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 454 | void RootWindowController::UpdateAfterLoginStatusChange(LoginStatus status) { |
| 455 | if (status != LoginStatus::NOT_LOGGED_IN) |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 456 | mouse_event_target_.reset(); |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 457 | StatusAreaWidget* status_area_widget = |
| 458 | wm_shelf_aura_->shelf_widget()->status_area_widget(); |
| 459 | if (status_area_widget) |
| 460 | status_area_widget->UpdateAfterLoginStatusChange(status); |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 461 | } |
| 462 | |
msw | 3f439af | 2016-09-08 22:35:26 | [diff] [blame] | 463 | void RootWindowController::OnInitialWallpaperAnimationStarted() { |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 464 | #if defined(OS_CHROMEOS) |
pgal.u-szeged | d84534d3 | 2014-10-29 12:34:30 | [diff] [blame] | 465 | if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 466 | switches::kAshAnimateFromBootSplashScreen) && |
| 467 | boot_splash_screen_.get()) { |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 468 | // Make the splash screen fade out so it doesn't obscure the wallpaper's |
| 469 | // brightness/grayscale animation. |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 470 | boot_splash_screen_->StartHideAnimation( |
| 471 | base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs)); |
| 472 | } |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 473 | #endif |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 474 | } |
| 475 | |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 476 | void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) { |
| 477 | // Make sure the wallpaper is visible. |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 478 | system_wallpaper_->SetColor(SK_ColorBLACK); |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 479 | #if defined(OS_CHROMEOS) |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 480 | boot_splash_screen_.reset(); |
[email protected] | 252eb23 | 2013-08-14 22:09:27 | [diff] [blame] | 481 | #endif |
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 482 | } |
| 483 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 484 | void RootWindowController::CloseChildWindows() { |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 485 | mouse_event_target_.reset(); |
| 486 | |
[email protected] | 2a57beb5 | 2014-06-09 20:02:26 | [diff] [blame] | 487 | // Remove observer as deactivating keyboard causes |docked_layout_manager_| |
| 488 | // to fire notifications. |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 489 | if (docked_layout_manager_ && wm_shelf_aura_->shelf_layout_manager()) { |
jamescook | 612205f | 2016-05-26 06:02:11 | [diff] [blame] | 490 | docked_layout_manager_->RemoveObserver( |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 491 | wm_shelf_aura_->shelf_layout_manager()); |
| 492 | } |
[email protected] | 2a57beb5 | 2014-06-09 20:02:26 | [diff] [blame] | 493 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 494 | // Deactivate keyboard container before closing child windows and shutting |
| 495 | // down associated layout managers. |
[email protected] | a0b3fb88 | 2014-04-07 19:26:03 | [diff] [blame] | 496 | DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 497 | |
[email protected] | 79a87b7e | 2013-01-25 05:08:22 | [diff] [blame] | 498 | // panel_layout_manager_ needs to be shut down before windows are destroyed. |
| 499 | if (panel_layout_manager_) { |
| 500 | panel_layout_manager_->Shutdown(); |
| 501 | panel_layout_manager_ = NULL; |
| 502 | } |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 503 | // docked_layout_manager_ needs to be shut down before windows are destroyed. |
| 504 | if (docked_layout_manager_) { |
[email protected] | 7115bd3 | 2013-07-19 08:25:39 | [diff] [blame] | 505 | docked_layout_manager_->Shutdown(); |
| 506 | docked_layout_manager_ = NULL; |
| 507 | } |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 508 | wm_shelf_aura_->ShutdownShelfWidget(); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 509 | |
sky | d053905c | 2016-08-30 22:37:35 | [diff] [blame] | 510 | wm_root_window_controller_->DeleteWorkspaceController(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 511 | |
[email protected] | 0fbfa97 | 2013-10-02 19:23:33 | [diff] [blame] | 512 | // Explicitly destroy top level windows. We do this as during part of |
| 513 | // destruction such windows may query the RootWindow for state. |
sky | 29f3171 | 2016-09-07 22:50:38 | [diff] [blame] | 514 | aura::Window* root_window = GetRootWindow(); |
oshima | f38efa9 | 2015-10-27 19:06:52 | [diff] [blame] | 515 | aura::WindowTracker non_toplevel_windows; |
| 516 | non_toplevel_windows.Add(root_window); |
| 517 | while (!non_toplevel_windows.windows().empty()) { |
| 518 | const aura::Window* non_toplevel_window = |
| 519 | *non_toplevel_windows.windows().begin(); |
| 520 | non_toplevel_windows.Remove(const_cast<aura::Window*>(non_toplevel_window)); |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 521 | aura::WindowTracker toplevel_windows; |
| 522 | for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) { |
| 523 | aura::Window* child = non_toplevel_window->children()[i]; |
[email protected] | 0fbfa97 | 2013-10-02 19:23:33 | [diff] [blame] | 524 | if (!child->owned_by_parent()) |
| 525 | continue; |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 526 | if (child->delegate()) |
| 527 | toplevel_windows.Add(child); |
| 528 | else |
oshima | f38efa9 | 2015-10-27 19:06:52 | [diff] [blame] | 529 | non_toplevel_windows.Add(child); |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 530 | } |
| 531 | while (!toplevel_windows.windows().empty()) |
| 532 | delete *toplevel_windows.windows().begin(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 533 | } |
[email protected] | 8b3e3d8 | 2013-08-20 14:36:30 | [diff] [blame] | 534 | // And then remove the containers. |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 535 | while (!root_window->children().empty()) { |
| 536 | aura::Window* window = root_window->children()[0]; |
[email protected] | 0fbfa97 | 2013-10-02 19:23:33 | [diff] [blame] | 537 | if (window->owned_by_parent()) { |
| 538 | delete window; |
| 539 | } else { |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 540 | root_window->RemoveChild(window); |
[email protected] | 0fbfa97 | 2013-10-02 19:23:33 | [diff] [blame] | 541 | } |
| 542 | } |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 543 | |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 544 | wm_shelf_aura_->DestroyShelfWidget(); |
| 545 | |
msw | ccb5d69 | 2016-08-17 20:37:48 | [diff] [blame] | 546 | // CloseChildWindows may be called twice during the shutdown of ash unittests. |
jamescook | 1cad77e9 | 2016-08-31 00:02:26 | [diff] [blame] | 547 | // Avoid notifying WmShelf that the shelf has been destroyed twice. |
| 548 | if (wm_shelf_aura_->IsShelfInitialized()) |
| 549 | wm_shelf_aura_->ShutdownShelf(); |
sky | 29f3171 | 2016-09-07 22:50:38 | [diff] [blame] | 550 | |
| 551 | aura::client::SetDragDropClient(root_window, nullptr); |
| 552 | aura::client::SetTooltipClient(root_window, nullptr); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 553 | } |
| 554 | |
[email protected] | bf9cdb36 | 2013-10-25 19:22:45 | [diff] [blame] | 555 | void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
msw | 6d9e0fd | 2016-08-12 04:06:02 | [diff] [blame] | 556 | // Clear the workspace controller, so it doesn't incorrectly update the shelf. |
sky | d053905c | 2016-08-30 22:37:35 | [diff] [blame] | 557 | wm_root_window_controller_->DeleteWorkspaceController(); |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 558 | ReparentAllWindows(GetRootWindow(), dst); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 559 | } |
| 560 | |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 561 | ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 562 | return wm_shelf_aura_->shelf_layout_manager(); |
| 563 | } |
| 564 | |
| 565 | StatusAreaWidget* RootWindowController::GetStatusAreaWidget() { |
| 566 | ShelfWidget* shelf_widget = wm_shelf_aura_->shelf_widget(); |
| 567 | return shelf_widget ? shelf_widget->status_area_widget() : nullptr; |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 568 | } |
| 569 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 570 | SystemTray* RootWindowController::GetSystemTray() { |
| 571 | // We assume in throughout the code that this will not return NULL. If code |
| 572 | // triggers this for valid reasons, it should test status_area_widget first. |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 573 | CHECK(wm_shelf_aura_->shelf_widget()->status_area_widget()); |
| 574 | return wm_shelf_aura_->shelf_widget()->status_area_widget()->system_tray(); |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 575 | } |
| 576 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 577 | void RootWindowController::UpdateShelfVisibility() { |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 578 | wm_shelf_aura_->UpdateVisibilityState(); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 579 | } |
| 580 | |
varkha | d99fa94f | 2015-06-29 22:35:46 | [diff] [blame] | 581 | aura::Window* RootWindowController::GetWindowForFullscreenMode() { |
sky | 0702b27 | 2016-06-03 22:10:41 | [diff] [blame] | 582 | return WmWindowAura::GetAuraWindow( |
| 583 | wm::GetWindowForFullscreenMode(WmWindowAura::Get(GetRootWindow()))); |
[email protected] | 2ee2f5d | 2013-01-10 23:37:16 | [diff] [blame] | 584 | } |
| 585 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 586 | void RootWindowController::ActivateKeyboard( |
| 587 | keyboard::KeyboardController* keyboard_controller) { |
| 588 | if (!keyboard::IsKeyboardEnabled() || |
| 589 | GetContainer(kShellWindowId_VirtualKeyboardContainer)) { |
| 590 | return; |
| 591 | } |
| 592 | DCHECK(keyboard_controller); |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 593 | keyboard_controller->AddObserver(wm_shelf_aura_->shelf_layout_manager()); |
bshe | 9858b4a | 2014-09-16 20:46:38 | [diff] [blame] | 594 | keyboard_controller->AddObserver(panel_layout_manager_); |
| 595 | keyboard_controller->AddObserver(docked_layout_manager_); |
sky | f71e6c9 | 2016-08-30 18:49:19 | [diff] [blame] | 596 | keyboard_controller->AddObserver(workspace_controller()->layout_manager()); |
rsadam | 7bd510bb | 2014-12-09 20:10:56 | [diff] [blame] | 597 | keyboard_controller->AddObserver( |
| 598 | always_on_top_controller_->GetLayoutManager()); |
msw | 61e1667 | 2016-08-12 16:36:58 | [diff] [blame] | 599 | WmShell::Get()->NotifyVirtualKeyboardActivated(true); |
bshe | c387542 | 2014-09-29 13:21:30 | [diff] [blame] | 600 | aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); |
[email protected] | b2da9b60 | 2014-03-05 18:39:52 | [diff] [blame] | 601 | DCHECK(parent); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 602 | aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 603 | keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); |
| 604 | parent->AddChild(keyboard_container); |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 605 | } |
[email protected] | 86459e2c | 2013-04-10 13:39:24 | [diff] [blame] | 606 | |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 607 | void RootWindowController::DeactivateKeyboard( |
| 608 | keyboard::KeyboardController* keyboard_controller) { |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 609 | if (!keyboard_controller || |
| 610 | !keyboard_controller->keyboard_container_initialized()) { |
[email protected] | b6ba05d90 | 2013-10-04 21:38:45 | [diff] [blame] | 611 | return; |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 612 | } |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 613 | aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 614 | if (keyboard_container->GetRootWindow() == GetRootWindow()) { |
bshe | c387542 | 2014-09-29 13:21:30 | [diff] [blame] | 615 | aura::Window* parent = |
| 616 | GetContainer(kShellWindowId_ImeWindowParentContainer); |
[email protected] | b2da9b60 | 2014-03-05 18:39:52 | [diff] [blame] | 617 | DCHECK(parent); |
| 618 | parent->RemoveChild(keyboard_container); |
bshe | 9858b4a | 2014-09-16 20:46:38 | [diff] [blame] | 619 | // Virtual keyboard may be deactivated while still showing, notify all |
| 620 | // observers that keyboard bounds changed to 0 before remove them. |
| 621 | keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect()); |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 622 | keyboard_controller->RemoveObserver(wm_shelf_aura_->shelf_layout_manager()); |
bshe | 9858b4a | 2014-09-16 20:46:38 | [diff] [blame] | 623 | keyboard_controller->RemoveObserver(panel_layout_manager_); |
| 624 | keyboard_controller->RemoveObserver(docked_layout_manager_); |
| 625 | keyboard_controller->RemoveObserver( |
sky | f71e6c9 | 2016-08-30 18:49:19 | [diff] [blame] | 626 | workspace_controller()->layout_manager()); |
rsadam | 7bd510bb | 2014-12-09 20:10:56 | [diff] [blame] | 627 | keyboard_controller->RemoveObserver( |
| 628 | always_on_top_controller_->GetLayoutManager()); |
msw | 61e1667 | 2016-08-12 16:36:58 | [diff] [blame] | 629 | WmShell::Get()->NotifyVirtualKeyboardActivated(false); |
[email protected] | 86459e2c | 2013-04-10 13:39:24 | [diff] [blame] | 630 | } |
| 631 | } |
| 632 | |
[email protected] | 602022b | 2014-03-31 17:07:31 | [diff] [blame] | 633 | bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { |
bshe | c387542 | 2014-09-29 13:21:30 | [diff] [blame] | 634 | aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); |
[email protected] | 602022b | 2014-03-31 17:07:31 | [diff] [blame] | 635 | return parent ? parent->Contains(window) : false; |
| 636 | } |
| 637 | |
dmazzoni | ff86e347 | 2016-06-03 19:52:32 | [diff] [blame] | 638 | void RootWindowController::SetTouchAccessibilityAnchorPoint( |
| 639 | const gfx::Point& anchor_point) { |
| 640 | #if defined(OS_CHROMEOS) |
| 641 | if (touch_exploration_manager_) |
| 642 | touch_exploration_manager_->SetTouchAccessibilityAnchorPoint(anchor_point); |
| 643 | #endif // defined(OS_CHROMEOS) |
| 644 | } |
| 645 | |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 646 | //////////////////////////////////////////////////////////////////////////////// |
| 647 | // RootWindowController, private: |
| 648 | |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 649 | RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) |
| 650 | : ash_host_(ash_host), |
jamescook | be6ed82 | 2016-06-06 20:08:55 | [diff] [blame] | 651 | wm_shelf_aura_(new WmShelfAura), |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 652 | docked_layout_manager_(NULL), |
| 653 | panel_layout_manager_(NULL), |
| 654 | touch_hud_debug_(NULL), |
| 655 | touch_hud_projection_(NULL) { |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 656 | aura::Window* root_window = GetRootWindow(); |
| 657 | GetRootWindowSettings(root_window)->controller = this; |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 658 | |
sky | d053905c | 2016-08-30 22:37:35 | [diff] [blame] | 659 | // Has to happen after this is set as |controller| of RootWindowSettings. |
| 660 | wm_root_window_controller_ = WmRootWindowControllerAura::Get(root_window); |
| 661 | |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 662 | stacking_controller_.reset(new StackingController); |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 663 | aura::client::SetWindowTreeClient(root_window, stacking_controller_.get()); |
| 664 | capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 665 | } |
| 666 | |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 667 | void RootWindowController::Init(RootWindowType root_window_type, |
| 668 | bool first_run_after_boot) { |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 669 | aura::Window* root_window = GetRootWindow(); |
[email protected] | 51f43811 | 2013-11-18 19:32:50 | [diff] [blame] | 670 | Shell* shell = Shell::GetInstance(); |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 671 | shell->InitRootWindow(root_window); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 672 | |
sky | d053905c | 2016-08-30 22:37:35 | [diff] [blame] | 673 | wm_root_window_controller_->CreateContainers(); |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 674 | |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 675 | CreateSystemWallpaper(first_run_after_boot); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 676 | |
| 677 | InitLayoutManagers(); |
| 678 | InitTouchHuds(); |
| 679 | |
sky | ea4ca94 | 2016-09-12 21:56:19 | [diff] [blame] | 680 | if (WmShell::Get() |
| 681 | ->GetPrimaryRootWindowController() |
sky | b733d418 | 2016-09-09 23:18:38 | [diff] [blame] | 682 | ->GetSystemModalLayoutManager(nullptr) |
| 683 | ->has_window_dimmer()) { |
sky | ea4ca94 | 2016-09-12 21:56:19 | [diff] [blame] | 684 | wm_root_window_controller_->GetSystemModalLayoutManager(nullptr) |
| 685 | ->CreateModalBackground(); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 686 | } |
| 687 | |
sky | 88bd4be6 | 2016-06-09 17:34:41 | [diff] [blame] | 688 | WmShell::Get()->AddShellObserver(this); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 689 | |
sky | d053905c | 2016-08-30 22:37:35 | [diff] [blame] | 690 | wm_root_window_controller_->root_window_layout_manager()->OnWindowResized(); |
[email protected] | 608de6c | 2013-10-29 00:14:28 | [diff] [blame] | 691 | if (root_window_type == PRIMARY) { |
bshe | 9858b4a | 2014-09-16 20:46:38 | [diff] [blame] | 692 | shell->InitKeyboard(); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 693 | } else { |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 694 | ash_host_->AsWindowTreeHost()->Show(); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 695 | |
[email protected] | 864b5855 | 2013-12-19 04:19:38 | [diff] [blame] | 696 | // Create a shelf if a user is already logged in. |
msw | bc0a8b48 | 2016-06-30 02:21:14 | [diff] [blame] | 697 | if (WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers()) |
jamescook | 6500ad13 | 2016-05-27 06:15:54 | [diff] [blame] | 698 | CreateShelf(); |
[email protected] | 0e3e7cb | 2014-04-12 05:18:25 | [diff] [blame] | 699 | |
| 700 | // Notify shell observers about new root window. |
sky | 80556bc4 | 2016-06-07 22:46:13 | [diff] [blame] | 701 | shell->OnRootWindowAdded(WmWindowAura::Get(root_window)); |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 702 | } |
[email protected] | a825e831 | 2014-05-05 22:05:01 | [diff] [blame] | 703 | |
| 704 | #if defined(OS_CHROMEOS) |
pgal.u-szeged | d84534d3 | 2014-10-29 12:34:30 | [diff] [blame] | 705 | if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
[email protected] | 2e0b235 | 2014-07-28 13:28:28 | [diff] [blame] | 706 | switches::kAshDisableTouchExplorationMode)) { |
[email protected] | 7d48759 | 2014-07-24 03:54:50 | [diff] [blame] | 707 | touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); |
[email protected] | a825e831 | 2014-05-05 22:05:01 | [diff] [blame] | 708 | } |
| 709 | #endif |
[email protected] | a273d33a | 2013-10-17 12:41:21 | [diff] [blame] | 710 | } |
| 711 | |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 712 | void RootWindowController::InitLayoutManagers() { |
sky | d053905c | 2016-08-30 22:37:35 | [diff] [blame] | 713 | wm_root_window_controller_->CreateLayoutManagers(); |
sky | 7cd30704 | 2016-06-01 21:10:48 | [diff] [blame] | 714 | |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 715 | aura::Window* root_window = GetRootWindow(); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 716 | |
sky | e782a26 | 2016-05-31 20:28:57 | [diff] [blame] | 717 | aura::Window* lock_container = |
| 718 | root_window->GetChildById(kShellWindowId_LockScreenContainer); |
| 719 | DCHECK(lock_container); |
| 720 | lock_container->SetLayoutManager(new LockLayoutManager(lock_container)); |
| 721 | |
sky | 0702b27 | 2016-06-03 22:10:41 | [diff] [blame] | 722 | WmWindow* always_on_top_container = |
| 723 | WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer)); |
rsadam | 7bd510bb | 2014-12-09 20:10:56 | [diff] [blame] | 724 | always_on_top_controller_.reset( |
| 725 | new AlwaysOnTopController(always_on_top_container)); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 726 | |
jamescook | 752e8df | 2016-08-09 19:54:39 | [diff] [blame] | 727 | // Create the shelf and status area widgets. |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 728 | DCHECK(!wm_shelf_aura_->shelf_widget()); |
jamescook | 752e8df | 2016-08-09 19:54:39 | [diff] [blame] | 729 | aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); |
| 730 | aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); |
| 731 | WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); |
| 732 | WmWindow* wm_status_container = WmWindowAura::Get(status_container); |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 733 | wm_shelf_aura_->CreateShelfWidget(WmWindowAura::Get(root_window)); |
| 734 | |
jamescook | 752e8df | 2016-08-09 19:54:39 | [diff] [blame] | 735 | // Make it easier to resize windows that partially overlap the shelf. Must |
| 736 | // occur after the ShelfLayoutManager is constructed by ShelfWidget. |
| 737 | shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( |
| 738 | wm_shelf_container, wm_shelf_aura_.get())); |
| 739 | status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( |
| 740 | wm_status_container, wm_shelf_aura_.get())); |
| 741 | |
msw | bc0a8b48 | 2016-06-30 02:21:14 | [diff] [blame] | 742 | if (!WmShell::Get() |
| 743 | ->GetSessionStateDelegate() |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 744 | ->IsActiveUserSessionStarted()) { |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 745 | // This window exists only to be a event target on login screen. |
| 746 | // It does not have to handle events, nor be visible. |
| 747 | mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); |
danakj | b161836d | 2015-04-03 05:14:18 | [diff] [blame] | 748 | mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 749 | |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 750 | aura::Window* lock_wallpaper_container = |
| 751 | GetContainer(kShellWindowId_LockScreenWallpaperContainer); |
| 752 | lock_wallpaper_container->AddChild(mouse_event_target_.get()); |
[email protected] | cf6fea2 | 2013-08-07 14:24:01 | [diff] [blame] | 753 | mouse_event_target_->Show(); |
| 754 | } |
| 755 | |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 756 | // Create Docked windows layout manager |
sky | 0702b27 | 2016-06-03 22:10:41 | [diff] [blame] | 757 | WmWindow* docked_container = |
| 758 | WmWindowAura::Get(GetContainer(kShellWindowId_DockedContainer)); |
sky | ca412269 | 2016-04-26 04:47:57 | [diff] [blame] | 759 | docked_layout_manager_ = new DockedWindowLayoutManager(docked_container); |
sky | 3f7af881 | 2016-04-21 19:30:03 | [diff] [blame] | 760 | docked_container->SetLayoutManager(base::WrapUnique(docked_layout_manager_)); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 761 | |
[email protected] | 1ca79d4 | 2014-07-18 16:26:10 | [diff] [blame] | 762 | // Installs SnapLayoutManager to containers who set the |
| 763 | // |kSnapsChildrenToPhysicalPixelBoundary| property. |
| 764 | wm::InstallSnapLayoutManagerToContainers(root_window); |
| 765 | |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 766 | // Create Panel layout manager |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 767 | aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer); |
sky | 0702b27 | 2016-06-03 22:10:41 | [diff] [blame] | 768 | WmWindow* wm_panel_container = WmWindowAura::Get(panel_container); |
sky | ad031502 | 2016-04-25 19:40:31 | [diff] [blame] | 769 | panel_layout_manager_ = new PanelLayoutManager(wm_panel_container); |
| 770 | wm_panel_container->SetLayoutManager(base::WrapUnique(panel_layout_manager_)); |
[email protected] | 3537d47 | 2014-01-15 05:45:31 | [diff] [blame] | 771 | panel_container_handler_.reset(new PanelWindowEventHandler); |
| 772 | panel_container->AddPreTargetHandler(panel_container_handler_.get()); |
[email protected] | b8642ec | 2014-04-17 05:20:39 | [diff] [blame] | 773 | |
| 774 | // Install an AttachedPanelWindowTargeter on the panel container to make it |
| 775 | // easier to correctly target shelf buttons with touch. |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 776 | gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, |
[email protected] | b8642ec | 2014-04-17 05:20:39 | [diff] [blame] | 777 | -kResizeOutsideBoundsSize, |
| 778 | -kResizeOutsideBoundsSize); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 779 | gfx::Insets touch_extend = |
| 780 | mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch); |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 781 | panel_container->SetEventTargeter( |
| 782 | std::unique_ptr<ui::EventTargeter>(new AttachedPanelWindowTargeter( |
| 783 | panel_container, mouse_extend, touch_extend, panel_layout_manager_))); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 784 | } |
| 785 | |
| 786 | void RootWindowController::InitTouchHuds() { |
pgal.u-szeged | d84534d3 | 2014-10-29 12:34:30 | [diff] [blame] | 787 | base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 788 | if (command_line->HasSwitch(switches::kAshTouchHud)) |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 789 | set_touch_hud_debug(new TouchHudDebug(GetRootWindow())); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 790 | if (Shell::GetInstance()->is_touch_hud_projection_enabled()) |
| 791 | EnableTouchHudProjection(); |
| 792 | } |
| 793 | |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 794 | void RootWindowController::CreateSystemWallpaper(bool is_first_run_after_boot) { |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 795 | SkColor color = SK_ColorBLACK; |
| 796 | #if defined(OS_CHROMEOS) |
| 797 | if (is_first_run_after_boot) |
| 798 | color = kChromeOsBootColor; |
| 799 | #endif |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 800 | system_wallpaper_.reset( |
| 801 | new SystemWallpaperController(GetRootWindow(), color)); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 802 | |
| 803 | #if defined(OS_CHROMEOS) |
| 804 | // Make a copy of the system's boot splash screen so we can composite it |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 805 | // onscreen until the wallpaper is ready. |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 806 | if (is_first_run_after_boot && |
pgal.u-szeged | d84534d3 | 2014-10-29 12:34:30 | [diff] [blame] | 807 | (base::CommandLine::ForCurrentProcess()->HasSwitch( |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 808 | switches::kAshCopyHostBackgroundAtBoot) || |
pgal.u-szeged | d84534d3 | 2014-10-29 12:34:30 | [diff] [blame] | 809 | base::CommandLine::ForCurrentProcess()->HasSwitch( |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 810 | switches::kAshAnimateFromBootSplashScreen))) |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 811 | boot_splash_screen_.reset(new BootSplashScreen(GetHost())); |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame] | 812 | #endif |
| 813 | } |
| 814 | |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 815 | void RootWindowController::EnableTouchHudProjection() { |
| 816 | if (touch_hud_projection_) |
| 817 | return; |
[email protected] | f5c9dbc | 2014-04-11 08:13:45 | [diff] [blame] | 818 | set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | void RootWindowController::DisableTouchHudProjection() { |
| 822 | if (!touch_hud_projection_) |
| 823 | return; |
| 824 | touch_hud_projection_->Remove(); |
| 825 | } |
| 826 | |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 827 | void RootWindowController::OnLoginStateChanged(LoginStatus status) { |
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 828 | wm_shelf_aura_->UpdateVisibilityState(); |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
| 832 | if (enabled) |
| 833 | EnableTouchHudProjection(); |
| 834 | else |
| 835 | DisableTouchHudProjection(); |
| 836 | } |
| 837 | |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 838 | RootWindowController* GetRootWindowController(const aura::Window* root_window) { |
msw | 15156bf | 2016-09-13 21:49:17 | [diff] [blame^] | 839 | return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; |
[email protected] | 6b2d4a0b | 2013-09-06 06:29:54 | [diff] [blame] | 840 | } |
| 841 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 842 | } // namespace ash |