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