Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: ash/root_window_controller.cc

Issue 2623393002: Revert of Moves definitions of RootWindowController into root_window_controller.cc (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/root_window_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_touch_exploration_manager_chromeos.h" 10 #include "ash/ash_touch_exploration_manager_chromeos.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 aura::Window::Windows windows = common_parent->children(); 137 aura::Window::Windows windows = common_parent->children();
138 auto blocking_iter = std::find(windows.begin(), windows.end(), blocking); 138 auto blocking_iter = std::find(windows.begin(), windows.end(), blocking);
139 // If the target window is above blocking window, the window can handle 139 // If the target window is above blocking window, the window can handle
140 // events. 140 // events.
141 return std::find(blocking_iter, windows.end(), target) != windows.end(); 141 return std::find(blocking_iter, windows.end(), target) != windows.end();
142 } 142 }
143 143
144 return true; 144 return true;
145 } 145 }
146 146
147 // Scales |value| that is originally between 0 and |src_max| to be between
148 // 0 and |dst_max|.
149 float ToRelativeValue(int value, int src_max, int dst_max) {
150 return static_cast<float>(value) / static_cast<float>(src_max) * dst_max;
151 }
152
153 // Uses ToRelativeValue() to scale the origin of |bounds_in_out|. The
154 // width/height are not changed.
155 void MoveOriginRelativeToSize(const gfx::Size& src_size,
156 const gfx::Size& dst_size,
157 gfx::Rect* bounds_in_out) {
158 gfx::Point origin = bounds_in_out->origin();
159 bounds_in_out->set_origin(gfx::Point(
160 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()),
161 ToRelativeValue(origin.y(), src_size.height(), dst_size.height())));
162 }
163
164 // Reparents |window| to |new_parent|.
165 // TODO(sky): This should take an aura::Window. http://crbug.com/671246.
166 void ReparentWindow(WmWindow* window, WmWindow* new_parent) {
167 const gfx::Size src_size = window->GetParent()->GetBounds().size();
168 const gfx::Size dst_size = new_parent->GetBounds().size();
169 // Update the restore bounds to make it relative to the display.
170 wm::WindowState* state = window->GetWindowState();
171 gfx::Rect restore_bounds;
172 bool has_restore_bounds = state->HasRestoreBounds();
173
174 bool update_bounds =
175 (state->IsNormalOrSnapped() || state->IsMinimized()) &&
176 new_parent->GetShellWindowId() != kShellWindowId_DockedContainer;
177 gfx::Rect local_bounds;
178 if (update_bounds) {
179 local_bounds = state->window()->GetBounds();
180 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds);
181 }
182
183 if (has_restore_bounds) {
184 restore_bounds = state->GetRestoreBoundsInParent();
185 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds);
186 }
187
188 new_parent->AddChild(window);
189
190 // Docked windows have bounds handled by the layout manager in AddChild().
191 if (update_bounds)
192 window->SetBounds(local_bounds);
193
194 if (has_restore_bounds)
195 state->SetRestoreBoundsInParent(restore_bounds);
196 }
197
198 // Reparents the appropriate set of windows from |src| to |dst|.
199 // TODO(sky): This should take an aura::Window. http://crbug.com/671246.
200 void ReparentAllWindows(WmWindow* src, WmWindow* dst) {
201 // Set of windows to move.
202 const int kContainerIdsToMove[] = {
203 kShellWindowId_DefaultContainer,
204 kShellWindowId_DockedContainer,
205 kShellWindowId_PanelContainer,
206 kShellWindowId_AlwaysOnTopContainer,
207 kShellWindowId_SystemModalContainer,
208 kShellWindowId_LockSystemModalContainer,
209 kShellWindowId_UnparentedControlContainer,
210 kShellWindowId_OverlayContainer,
211 };
212 const int kExtraContainerIdsToMoveInUnifiedMode[] = {
213 kShellWindowId_LockScreenContainer,
214 kShellWindowId_LockScreenWallpaperContainer,
215 };
216 std::vector<int> container_ids(
217 kContainerIdsToMove,
218 kContainerIdsToMove + arraysize(kContainerIdsToMove));
219 // Check the display mode as this is also necessary when trasitioning between
220 // mirror and unified mode.
221 if (WmShell::Get()->IsInUnifiedModeIgnoreMirroring()) {
222 for (int id : kExtraContainerIdsToMoveInUnifiedMode)
223 container_ids.push_back(id);
224 }
225
226 for (int id : container_ids) {
227 WmWindow* src_container = src->GetChildByShellWindowId(id);
228 WmWindow* dst_container = dst->GetChildByShellWindowId(id);
229 while (!src_container->GetChildren().empty()) {
230 // Restart iteration from the source container windows each time as they
231 // may change as a result of moving other windows.
232 WmWindow::Windows src_container_children = src_container->GetChildren();
233 WmWindow::Windows::const_iterator iter = src_container_children.begin();
234 while (iter != src_container_children.end() &&
235 SystemModalContainerLayoutManager::IsModalBackground(*iter)) {
236 ++iter;
237 }
238 // If the entire window list is modal background windows then stop.
239 if (iter == src_container_children.end())
240 break;
241 ReparentWindow(*iter, dst_container);
242 }
243 }
244 }
245
246 // Creates a new window for use as a container.
247 // TODO(sky): This should create an aura::Window. http://crbug.com/671246.
248 WmWindow* CreateContainer(int window_id, const char* name, WmWindow* parent) {
249 WmWindow* window = WmShell::Get()->NewWindow(ui::wm::WINDOW_TYPE_UNKNOWN,
250 ui::LAYER_NOT_DRAWN);
251 window->SetShellWindowId(window_id);
252 window->SetName(name);
253 parent->AddChild(window);
254 if (window_id != kShellWindowId_UnparentedControlContainer)
255 window->Show();
256 return window;
257 }
258
259 // TODO(sky): This should take an aura::Window. http://crbug.com/671246.
260 bool ShouldDestroyWindowInCloseChildWindows(WmWindow* window) {
261 if (!WmWindowAura::GetAuraWindow(window)->owned_by_parent())
262 return false;
263
264 if (!WmShell::Get()->IsRunningInMash())
265 return true;
266
267 aura::WindowMus* window_mus =
268 aura::WindowMus::Get(WmWindowAura::GetAuraWindow(window));
269 return Shell::window_tree_client()->WasCreatedByThisClient(window_mus) ||
270 Shell::window_tree_client()->IsRoot(window_mus);
271 }
272
273 } // namespace 147 } // namespace
274 148
275 RootWindowController::~RootWindowController() { 149 RootWindowController::~RootWindowController() {
276 Shutdown(); 150 Shutdown();
277 ash_host_.reset(); 151 ash_host_.reset();
278 mus_window_tree_host_.reset(); 152 mus_window_tree_host_.reset();
279 // The CaptureClient needs to be around for as long as the RootWindow is 153 // The CaptureClient needs to be around for as long as the RootWindow is
280 // valid. 154 // valid.
281 capture_client_.reset(); 155 capture_client_.reset();
282 if (animating_wallpaper_widget_controller_.get()) 156 if (animating_wallpaper_widget_controller_.get())
(...skipping 18 matching lines...) Expand all
301 (WmShell::Get()->IsRunningInMash() || Shell::HasInstance())); 175 (WmShell::Get()->IsRunningInMash() || Shell::HasInstance()));
302 return GetRootWindowController(window->GetRootWindow()); 176 return GetRootWindowController(window->GetRootWindow());
303 } 177 }
304 178
305 // static 179 // static
306 RootWindowController* RootWindowController::ForTargetRootWindow() { 180 RootWindowController* RootWindowController::ForTargetRootWindow() {
307 CHECK(Shell::HasInstance()); 181 CHECK(Shell::HasInstance());
308 return GetRootWindowController(Shell::GetTargetRootWindow()); 182 return GetRootWindowController(Shell::GetTargetRootWindow());
309 } 183 }
310 184
311 void RootWindowController::ConfigureWidgetInitParamsForContainer(
312 views::Widget* widget,
313 int shell_container_id,
314 views::Widget::InitParams* init_params) {
315 init_params->parent = GetContainer(shell_container_id);
316 }
317
318 aura::WindowTreeHost* RootWindowController::GetHost() { 185 aura::WindowTreeHost* RootWindowController::GetHost() {
319 return window_tree_host_; 186 return window_tree_host_;
320 } 187 }
321 188
322 const aura::WindowTreeHost* RootWindowController::GetHost() const { 189 const aura::WindowTreeHost* RootWindowController::GetHost() const {
323 return window_tree_host_; 190 return window_tree_host_;
324 } 191 }
325 192
326 aura::Window* RootWindowController::GetRootWindow() { 193 aura::Window* RootWindowController::GetRootWindow() {
327 return GetHost()->window(); 194 return GetHost()->window();
328 } 195 }
329 196
330 const aura::Window* RootWindowController::GetRootWindow() const { 197 const aura::Window* RootWindowController::GetRootWindow() const {
331 return GetHost()->window(); 198 return GetHost()->window();
332 } 199 }
333 200
334 const WmWindow* RootWindowController::GetWindow() const { 201 void RootWindowController::Shutdown() {
335 return WmWindowAura::Get(GetRootWindow()); 202 WmShell::Get()->RemoveShellObserver(this);
336 }
337 203
338 wm::WorkspaceWindowState RootWindowController::GetWorkspaceWindowState() { 204 touch_exploration_manager_.reset();
339 return workspace_controller_ ? workspace_controller()->GetWindowState()
340 : wm::WORKSPACE_WINDOW_STATE_DEFAULT;
341 }
342 205
343 bool RootWindowController::HasShelf() { 206 ResetRootForNewWindowsIfNecessary();
344 return wm_shelf_->shelf_widget() != nullptr;
345 }
346 207
347 WmShelf* RootWindowController::GetShelf() { 208 CloseChildWindows();
348 return wm_shelf_.get(); 209 aura::Window* root_window = GetRootWindow();
349 } 210 GetRootWindowSettings(root_window)->controller = NULL;
211 // Forget with the display ID so that display lookup
212 // ends up with invalid display.
213 GetRootWindowSettings(root_window)->display_id = display::kInvalidDisplayId;
214 if (ash_host_)
215 ash_host_->PrepareForShutdown();
350 216
351 void RootWindowController::CreateShelf() { 217 system_wallpaper_.reset();
352 if (wm_shelf_->IsShelfInitialized()) 218 aura::client::SetScreenPositionClient(root_window, NULL);
353 return;
354 wm_shelf_->InitializeShelf();
355
356 if (panel_layout_manager_)
357 panel_layout_manager_->SetShelf(wm_shelf_.get());
358 if (docked_window_layout_manager_) {
359 docked_window_layout_manager_->SetShelf(wm_shelf_.get());
360 if (wm_shelf_->shelf_layout_manager())
361 docked_window_layout_manager_->AddObserver(
362 wm_shelf_->shelf_layout_manager());
363 }
364
365 // Notify shell observers that the shelf has been created.
366 // TODO(jamescook): Move this into WmShelf::InitializeShelf(). This will
367 // require changing AttachedPanelWidgetTargeter's access to WmShelf.
368 WmShell::Get()->NotifyShelfCreatedForRootWindow(
369 WmWindowAura::Get(GetRootWindow()));
370
371 wm_shelf_->shelf_widget()->PostCreateShelf();
372 }
373
374 void RootWindowController::ShowShelf() {
375 if (!wm_shelf_->IsShelfInitialized())
376 return;
377 // TODO(jamescook): Move this into WmShelf.
378 wm_shelf_->shelf_widget()->SetShelfVisibility(true);
379 wm_shelf_->shelf_widget()->status_area_widget()->Show();
380 }
381
382 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
383 return wm_shelf_->shelf_layout_manager();
384 }
385
386 SystemModalContainerLayoutManager*
387 RootWindowController::GetSystemModalLayoutManager(WmWindow* window) {
388 WmWindow* modal_container = nullptr;
389 if (window) {
390 WmWindow* window_container = wm::GetContainerForWindow(window);
391 if (window_container &&
392 window_container->GetShellWindowId() >=
393 kShellWindowId_LockScreenContainer) {
394 modal_container = GetWmContainer(kShellWindowId_LockSystemModalContainer);
395 } else {
396 modal_container = GetWmContainer(kShellWindowId_SystemModalContainer);
397 }
398 } else {
399 int modal_window_id =
400 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()
401 ? kShellWindowId_LockSystemModalContainer
402 : kShellWindowId_SystemModalContainer;
403 modal_container = GetWmContainer(modal_window_id);
404 }
405 return modal_container ? static_cast<SystemModalContainerLayoutManager*>(
406 modal_container->GetLayoutManager())
407 : nullptr;
408 }
409
410 StatusAreaWidget* RootWindowController::GetStatusAreaWidget() {
411 ShelfWidget* shelf_widget = wm_shelf_->shelf_widget();
412 return shelf_widget ? shelf_widget->status_area_widget() : nullptr;
413 }
414
415 SystemTray* RootWindowController::GetSystemTray() {
416 // We assume in throughout the code that this will not return NULL. If code
417 // triggers this for valid reasons, it should test status_area_widget first.
418 CHECK(wm_shelf_->shelf_widget()->status_area_widget());
419 return wm_shelf_->shelf_widget()->status_area_widget()->system_tray();
420 } 219 }
421 220
422 bool RootWindowController::CanWindowReceiveEvents(aura::Window* window) { 221 bool RootWindowController::CanWindowReceiveEvents(aura::Window* window) {
423 if (GetRootWindow() != window->GetRootWindow()) 222 if (GetRootWindow() != window->GetRootWindow())
424 return false; 223 return false;
425 224
426 // Always allow events to fall through to the virtual keyboard even if 225 // Always allow events to fall through to the virtual keyboard even if
427 // displaying a system modal dialog. 226 // displaying a system modal dialog.
428 if (IsVirtualKeyboardWindow(window)) 227 if (IsVirtualKeyboardWindow(window))
429 return true; 228 return true;
(...skipping 27 matching lines...) Expand all
457 256
458 // If the window is in the target modal container, only allow the top most 257 // If the window is in the target modal container, only allow the top most
459 // one. 258 // one.
460 if (modal_container && modal_container->Contains(window)) 259 if (modal_container && modal_container->Contains(window))
461 return modal_layout_manager->IsPartOfActiveModalWindow( 260 return modal_layout_manager->IsPartOfActiveModalWindow(
462 WmWindowAura::Get(window)); 261 WmWindowAura::Get(window));
463 262
464 return true; 263 return true;
465 } 264 }
466 265
467 WmWindow* RootWindowController::FindEventTarget(
468 const gfx::Point& location_in_screen) {
469 gfx::Point location_in_root(location_in_screen);
470 aura::Window* root_window = GetRootWindow();
471 ::wm::ConvertPointFromScreen(root_window, &location_in_root);
472 ui::MouseEvent test_event(ui::ET_MOUSE_MOVED, location_in_root,
473 location_in_root, ui::EventTimeForNow(),
474 ui::EF_NONE, ui::EF_NONE);
475 ui::EventTarget* event_handler =
476 static_cast<ui::EventTarget*>(root_window)
477 ->GetEventTargeter()
478 ->FindTargetForEvent(root_window, &test_event);
479 return WmWindowAura::Get(static_cast<aura::Window*>(event_handler));
480 }
481
482 gfx::Point RootWindowController::GetLastMouseLocationInRoot() {
483 return window_tree_host_->dispatcher()->GetLastMouseLocationInRoot();
484 }
485
486 aura::Window* RootWindowController::GetContainer(int container_id) { 266 aura::Window* RootWindowController::GetContainer(int container_id) {
487 return GetRootWindow()->GetChildById(container_id); 267 return GetRootWindow()->GetChildById(container_id);
488 } 268 }
489 269
490 const aura::Window* RootWindowController::GetContainer(int container_id) const { 270 const aura::Window* RootWindowController::GetContainer(int container_id) const {
491 return window_tree_host_->window()->GetChildById(container_id); 271 return window_tree_host_->window()->GetChildById(container_id);
492 } 272 }
493 273
494 const WmWindow* RootWindowController::GetWmContainer(int container_id) const {
495 const aura::Window* window = GetContainer(container_id);
496 return WmWindowAura::Get(window);
497 }
498
499 void RootWindowController::SetWallpaperWidgetController(
500 WallpaperWidgetController* controller) {
501 wallpaper_widget_controller_.reset(controller);
502 }
503
504 void RootWindowController::SetAnimatingWallpaperWidgetController(
505 AnimatingWallpaperWidgetController* controller) {
506 if (animating_wallpaper_widget_controller_.get())
507 animating_wallpaper_widget_controller_->StopAnimating();
508 animating_wallpaper_widget_controller_.reset(controller);
509 }
510
511 void RootWindowController::OnInitialWallpaperAnimationStarted() { 274 void RootWindowController::OnInitialWallpaperAnimationStarted() {
512 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 275 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
513 switches::kAshAnimateFromBootSplashScreen) && 276 switches::kAshAnimateFromBootSplashScreen) &&
514 boot_splash_screen_.get()) { 277 boot_splash_screen_.get()) {
515 // Make the splash screen fade out so it doesn't obscure the wallpaper's 278 // Make the splash screen fade out so it doesn't obscure the wallpaper's
516 // brightness/grayscale animation. 279 // brightness/grayscale animation.
517 boot_splash_screen_->StartHideAnimation( 280 boot_splash_screen_->StartHideAnimation(
518 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs)); 281 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs));
519 } 282 }
520 } 283 }
521 284
522 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) { 285 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) {
523 // Make sure the wallpaper is visible. 286 // Make sure the wallpaper is visible.
524 system_wallpaper_->SetColor(SK_ColorBLACK); 287 system_wallpaper_->SetColor(SK_ColorBLACK);
525 boot_splash_screen_.reset(); 288 boot_splash_screen_.reset();
526 WmShell::Get()->wallpaper_delegate()->OnWallpaperAnimationFinished(); 289 WmShell::Get()->wallpaper_delegate()->OnWallpaperAnimationFinished();
527 // Only removes old component when wallpaper animation finished. If we 290 // Only removes old component when wallpaper animation finished. If we
528 // remove the old one before the new wallpaper is done fading in there will 291 // remove the old one before the new wallpaper is done fading in there will
529 // be a white flash during the animation. 292 // be a white flash during the animation.
530 if (animating_wallpaper_widget_controller()) { 293 if (animating_wallpaper_widget_controller()) {
531 WallpaperWidgetController* controller = 294 WallpaperWidgetController* controller =
532 animating_wallpaper_widget_controller()->GetController(true); 295 animating_wallpaper_widget_controller()->GetController(true);
533 DCHECK_EQ(controller->widget(), widget); 296 DCHECK_EQ(controller->widget(), widget);
534 // Release the old controller and close its wallpaper widget. 297 // Release the old controller and close its wallpaper widget.
535 SetWallpaperWidgetController(controller); 298 SetWallpaperWidgetController(controller);
536 } 299 }
537 } 300 }
538 301
539 void RootWindowController::Shutdown() {
540 WmShell::Get()->RemoveShellObserver(this);
541
542 touch_exploration_manager_.reset();
543
544 ResetRootForNewWindowsIfNecessary();
545
546 CloseChildWindows();
547 aura::Window* root_window = GetRootWindow();
548 GetRootWindowSettings(root_window)->controller = nullptr;
549 // Forget with the display ID so that display lookup
550 // ends up with invalid display.
551 GetRootWindowSettings(root_window)->display_id = display::kInvalidDisplayId;
552 if (ash_host_)
553 ash_host_->PrepareForShutdown();
554
555 system_wallpaper_.reset();
556 aura::client::SetScreenPositionClient(root_window, nullptr);
557 }
558
559 void RootWindowController::CloseChildWindows() { 302 void RootWindowController::CloseChildWindows() {
560 // NOTE: this may be called multiple times.
561
562 // Remove observer as deactivating keyboard causes 303 // Remove observer as deactivating keyboard causes
563 // docked_window_layout_manager() to fire notifications. 304 // docked_window_layout_manager() to fire notifications.
564 if (docked_window_layout_manager() && wm_shelf_->shelf_layout_manager()) { 305 if (docked_window_layout_manager() && wm_shelf_->shelf_layout_manager()) {
565 docked_window_layout_manager()->RemoveObserver( 306 docked_window_layout_manager()->RemoveObserver(
566 wm_shelf_->shelf_layout_manager()); 307 wm_shelf_->shelf_layout_manager());
567 } 308 }
568 309
569 // Deactivate keyboard container before closing child windows and shutting 310 // Deactivate keyboard container before closing child windows and shutting
570 // down associated layout managers. 311 // down associated layout managers.
571 DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); 312 DeactivateKeyboard(keyboard::KeyboardController::GetInstance());
572 313
573 // |panel_layout_manager_| needs to be shut down before windows are destroyed. 314 CloseChildWindowsImpl();
574 if (panel_layout_manager_) {
575 panel_layout_manager_->Shutdown();
576 panel_layout_manager_ = nullptr;
577 }
578
579 // |docked_window_layout_manager_| needs to be shut down before windows are
580 // destroyed.
581 if (docked_window_layout_manager_) {
582 docked_window_layout_manager_->Shutdown();
583 docked_window_layout_manager_ = nullptr;
584 }
585
586 WmShelf* shelf = GetShelf();
587 shelf->ShutdownShelfWidget();
588
589 workspace_controller_.reset();
590
591 // Explicitly destroy top level windows. We do this because such windows may
592 // query the RootWindow for state.
593 WmWindowTracker non_toplevel_windows;
594 WmWindow* root = GetWindow();
595 non_toplevel_windows.Add(root);
596 while (!non_toplevel_windows.windows().empty()) {
597 WmWindow* non_toplevel_window = non_toplevel_windows.Pop();
598 WmWindowTracker toplevel_windows;
599 for (WmWindow* child : non_toplevel_window->GetChildren()) {
600 if (!ShouldDestroyWindowInCloseChildWindows(child))
601 continue;
602 if (child->HasNonClientArea())
603 toplevel_windows.Add(child);
604 else
605 non_toplevel_windows.Add(child);
606 }
607 while (!toplevel_windows.windows().empty())
608 toplevel_windows.Pop()->Destroy();
609 }
610 // And then remove the containers.
611 while (!root->GetChildren().empty()) {
612 WmWindow* child = root->GetChildren()[0];
613 if (ShouldDestroyWindowInCloseChildWindows(child))
614 child->Destroy();
615 else
616 root->RemoveChild(child);
617 }
618
619 shelf->DestroyShelfWidget();
620
621 // CloseChildWindows() may be called twice during the shutdown of ash
622 // unittests. Avoid notifying WmShelf that the shelf has been destroyed twice.
623 if (shelf->IsShelfInitialized())
624 shelf->ShutdownShelf();
625 315
626 aura::client::SetDragDropClient(GetRootWindow(), nullptr); 316 aura::client::SetDragDropClient(GetRootWindow(), nullptr);
627 aura::client::SetTooltipClient(GetRootWindow(), nullptr); 317 aura::client::SetTooltipClient(GetRootWindow(), nullptr);
628 } 318 }
629 319
630 void RootWindowController::MoveWindowsTo(aura::Window* dst) { 320 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
631 // Clear the workspace controller, so it doesn't incorrectly update the shelf. 321 return wm_shelf_->shelf_layout_manager();
632 workspace_controller_.reset(); 322 }
633 ReparentAllWindows(GetWindow(), WmWindowAura::Get(dst)); 323
324 StatusAreaWidget* RootWindowController::GetStatusAreaWidget() {
325 ShelfWidget* shelf_widget = wm_shelf_->shelf_widget();
326 return shelf_widget ? shelf_widget->status_area_widget() : nullptr;
327 }
328
329 SystemTray* RootWindowController::GetSystemTray() {
330 // We assume in throughout the code that this will not return NULL. If code
331 // triggers this for valid reasons, it should test status_area_widget first.
332 CHECK(wm_shelf_->shelf_widget()->status_area_widget());
333 return wm_shelf_->shelf_widget()->status_area_widget()->system_tray();
634 } 334 }
635 335
636 void RootWindowController::UpdateShelfVisibility() { 336 void RootWindowController::UpdateShelfVisibility() {
637 wm_shelf_->UpdateVisibilityState(); 337 wm_shelf_->UpdateVisibilityState();
638 } 338 }
639 339
640 void RootWindowController::InitTouchHuds() {
641 if (WmShell::Get()->IsRunningInMash())
642 return;
643
644 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
645 if (command_line->HasSwitch(switches::kAshTouchHud))
646 set_touch_hud_debug(new TouchHudDebug(GetRootWindow()));
647 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
648 EnableTouchHudProjection();
649 }
650
651 aura::Window* RootWindowController::GetWindowForFullscreenMode() { 340 aura::Window* RootWindowController::GetWindowForFullscreenMode() {
652 return WmWindowAura::GetAuraWindow( 341 return WmWindowAura::GetAuraWindow(
653 wm::GetWindowForFullscreenMode(WmWindowAura::Get(GetRootWindow()))); 342 wm::GetWindowForFullscreenMode(WmWindowAura::Get(GetRootWindow())));
654 } 343 }
655 344
656 void RootWindowController::ActivateKeyboard( 345 void RootWindowController::ActivateKeyboard(
657 keyboard::KeyboardController* keyboard_controller) { 346 keyboard::KeyboardController* keyboard_controller) {
658 if (!keyboard::IsKeyboardEnabled() || 347 if (!keyboard::IsKeyboardEnabled() ||
659 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { 348 GetContainer(kShellWindowId_VirtualKeyboardContainer)) {
660 return; 349 return;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); 393 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
705 return parent ? parent->Contains(window) : false; 394 return parent ? parent->Contains(window) : false;
706 } 395 }
707 396
708 void RootWindowController::SetTouchAccessibilityAnchorPoint( 397 void RootWindowController::SetTouchAccessibilityAnchorPoint(
709 const gfx::Point& anchor_point) { 398 const gfx::Point& anchor_point) {
710 if (touch_exploration_manager_) 399 if (touch_exploration_manager_)
711 touch_exploration_manager_->SetTouchAccessibilityAnchorPoint(anchor_point); 400 touch_exploration_manager_->SetTouchAccessibilityAnchorPoint(anchor_point);
712 } 401 }
713 402
714 void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen,
715 ui::MenuSourceType source_type) {
716 ShellDelegate* delegate = WmShell::Get()->delegate();
717 DCHECK(delegate);
718 menu_model_.reset(delegate->CreateContextMenu(wm_shelf_.get(), nullptr));
719 if (!menu_model_)
720 return;
721
722 menu_model_adapter_ = base::MakeUnique<views::MenuModelAdapter>(
723 menu_model_.get(),
724 base::Bind(&RootWindowController::OnMenuClosed, base::Unretained(this)));
725
726 // The wallpaper controller may not be set yet if the user clicked on the
727 // status area before the initial animation completion. See crbug.com/222218
728 if (!wallpaper_widget_controller())
729 return;
730
731 menu_runner_ = base::MakeUnique<views::MenuRunner>(
732 menu_model_adapter_->CreateMenu(),
733 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC);
734 ignore_result(
735 menu_runner_->RunMenuAt(wallpaper_widget_controller()->widget(), nullptr,
736 gfx::Rect(location_in_screen, gfx::Size()),
737 views::MENU_ANCHOR_TOPLEFT, source_type));
738 }
739
740 void RootWindowController::UpdateAfterLoginStatusChange(LoginStatus status) {
741 StatusAreaWidget* status_area_widget =
742 wm_shelf_->shelf_widget()->status_area_widget();
743 if (status_area_widget)
744 status_area_widget->UpdateAfterLoginStatusChange(status);
745 }
746
747 //////////////////////////////////////////////////////////////////////////////// 403 ////////////////////////////////////////////////////////////////////////////////
748 // RootWindowController, private: 404 // RootWindowController, private:
749 405
750 RootWindowController::RootWindowController( 406 RootWindowController::RootWindowController(
751 AshWindowTreeHost* ash_host, 407 AshWindowTreeHost* ash_host,
752 aura::WindowTreeHost* window_tree_host) 408 aura::WindowTreeHost* window_tree_host)
753 : ash_host_(ash_host), 409 : ash_host_(ash_host),
754 mus_window_tree_host_(window_tree_host), 410 mus_window_tree_host_(window_tree_host),
755 window_tree_host_(ash_host ? ash_host->AsWindowTreeHost() 411 window_tree_host_(ash_host ? ash_host->AsWindowTreeHost()
756 : window_tree_host), 412 : window_tree_host),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 466 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
811 switches::kAshDisableTouchExplorationMode) && 467 switches::kAshDisableTouchExplorationMode) &&
812 !wm_shell->IsRunningInMash()) { 468 !wm_shell->IsRunningInMash()) {
813 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); 469 touch_exploration_manager_.reset(new AshTouchExplorationManager(this));
814 } 470 }
815 } 471 }
816 472
817 void RootWindowController::InitLayoutManagers() { 473 void RootWindowController::InitLayoutManagers() {
818 // Create the shelf and status area widgets. 474 // Create the shelf and status area widgets.
819 DCHECK(!wm_shelf_->shelf_widget()); 475 DCHECK(!wm_shelf_->shelf_widget());
820 GetShelf()->CreateShelfWidget(GetWindow()); 476 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer);
477 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer);
478 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container);
479 WmWindow* wm_status_container = WmWindowAura::Get(status_container);
821 480
822 WmWindow* root = GetWindow(); 481 CreateLayoutManagers();
823 root_window_layout_manager_ = new wm::RootWindowLayoutManager(root);
824 root->SetLayoutManager(base::WrapUnique(root_window_layout_manager_));
825
826 WmWindow* default_container = GetWmContainer(kShellWindowId_DefaultContainer);
827 // Installs WorkspaceLayoutManager on |default_container|.
828 workspace_controller_.reset(new WorkspaceController(default_container));
829
830 WmWindow* modal_container =
831 GetWmContainer(kShellWindowId_SystemModalContainer);
832 DCHECK(modal_container);
833 modal_container->SetLayoutManager(
834 base::MakeUnique<SystemModalContainerLayoutManager>(modal_container));
835
836 WmWindow* lock_modal_container =
837 GetWmContainer(kShellWindowId_LockSystemModalContainer);
838 DCHECK(lock_modal_container);
839 lock_modal_container->SetLayoutManager(
840 base::MakeUnique<SystemModalContainerLayoutManager>(
841 lock_modal_container));
842
843 WmWindow* lock_container = GetWmContainer(kShellWindowId_LockScreenContainer);
844 DCHECK(lock_container);
845 lock_container->SetLayoutManager(
846 base::MakeUnique<LockLayoutManager>(lock_container));
847
848 WmWindow* always_on_top_container =
849 GetWmContainer(kShellWindowId_AlwaysOnTopContainer);
850 DCHECK(always_on_top_container);
851 always_on_top_controller_ =
852 base::MakeUnique<AlwaysOnTopController>(always_on_top_container);
853
854 // Create Docked windows layout manager
855 WmWindow* docked_container = GetWmContainer(kShellWindowId_DockedContainer);
856 docked_window_layout_manager_ =
857 new DockedWindowLayoutManager(docked_container);
858 docked_container->SetLayoutManager(
859 base::WrapUnique(docked_window_layout_manager_));
860
861 // Create Panel layout manager
862 WmWindow* wm_panel_container = GetWmContainer(kShellWindowId_PanelContainer);
863 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container);
864 wm_panel_container->SetLayoutManager(base::WrapUnique(panel_layout_manager_));
865
866 wm::WmSnapToPixelLayoutManager::InstallOnContainers(root);
867 482
868 // Make it easier to resize windows that partially overlap the shelf. Must 483 // Make it easier to resize windows that partially overlap the shelf. Must
869 // occur after the ShelfLayoutManager is constructed by ShelfWidget. 484 // occur after the ShelfLayoutManager is constructed by ShelfWidget.
870 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer);
871 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container);
872 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( 485 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>(
873 wm_shelf_container, wm_shelf_.get())); 486 wm_shelf_container, wm_shelf_.get()));
874 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer);
875 WmWindow* wm_status_container = WmWindowAura::Get(status_container);
876 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( 487 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>(
877 wm_status_container, wm_shelf_.get())); 488 wm_status_container, wm_shelf_.get()));
878 489
879 panel_container_handler_ = base::MakeUnique<PanelWindowEventHandler>(); 490 panel_container_handler_ = base::MakeUnique<PanelWindowEventHandler>();
880 GetContainer(kShellWindowId_PanelContainer) 491 GetContainer(kShellWindowId_PanelContainer)
881 ->AddPreTargetHandler(panel_container_handler_.get()); 492 ->AddPreTargetHandler(panel_container_handler_.get());
882 493
883 // Install an AttachedPanelWindowTargeter on the panel container to make it 494 // Install an AttachedPanelWindowTargeter on the panel container to make it
884 // easier to correctly target shelf buttons with touch. 495 // easier to correctly target shelf buttons with touch.
885 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, 496 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize,
886 -kResizeOutsideBoundsSize, 497 -kResizeOutsideBoundsSize,
887 -kResizeOutsideBoundsSize); 498 -kResizeOutsideBoundsSize);
888 gfx::Insets touch_extend = 499 gfx::Insets touch_extend =
889 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch); 500 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch);
890 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer); 501 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer);
891 panel_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( 502 panel_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>(
892 new AttachedPanelWindowTargeter(panel_container, mouse_extend, 503 new AttachedPanelWindowTargeter(panel_container, mouse_extend,
893 touch_extend, panel_layout_manager()))); 504 touch_extend, panel_layout_manager())));
894 } 505 }
895 506
896 void RootWindowController::CreateContainers() { 507 void RootWindowController::InitTouchHuds() {
897 WmWindow* root = GetWindow(); 508 if (WmShell::Get()->IsRunningInMash())
898 // These containers are just used by PowerButtonController to animate groups 509 return;
899 // of containers simultaneously without messing up the current transformations
900 // on those containers. These are direct children of the root window; all of
901 // the other containers are their children.
902 510
903 // The wallpaper container is not part of the lock animation, so it is not 511 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
904 // included in those animate groups. When the screen is locked, the wallpaper 512 if (command_line->HasSwitch(switches::kAshTouchHud))
905 // is moved to the lock screen wallpaper container (and moved back on unlock). 513 set_touch_hud_debug(new TouchHudDebug(GetRootWindow()));
906 // Ensure that there's an opaque layer occluding the non-lock-screen layers. 514 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
907 WmWindow* wallpaper_container = CreateContainer( 515 EnableTouchHudProjection();
908 kShellWindowId_WallpaperContainer, "WallpaperContainer", root);
909 wallpaper_container->SetChildWindowVisibilityChangesAnimated();
910
911 WmWindow* non_lock_screen_containers =
912 CreateContainer(kShellWindowId_NonLockScreenContainersContainer,
913 "NonLockScreenContainersContainer", root);
914 // Clip all windows inside this container, as half pixel of the window's
915 // texture may become visible when the screen is scaled. crbug.com/368591.
916 non_lock_screen_containers->SetMasksToBounds(true);
917
918 WmWindow* lock_wallpaper_containers =
919 CreateContainer(kShellWindowId_LockScreenWallpaperContainer,
920 "LockScreenWallpaperContainer", root);
921 lock_wallpaper_containers->SetChildWindowVisibilityChangesAnimated();
922
923 WmWindow* lock_screen_containers =
924 CreateContainer(kShellWindowId_LockScreenContainersContainer,
925 "LockScreenContainersContainer", root);
926 WmWindow* lock_screen_related_containers =
927 CreateContainer(kShellWindowId_LockScreenRelatedContainersContainer,
928 "LockScreenRelatedContainersContainer", root);
929
930 CreateContainer(kShellWindowId_UnparentedControlContainer,
931 "UnparentedControlContainer", non_lock_screen_containers);
932
933 WmWindow* default_container =
934 CreateContainer(kShellWindowId_DefaultContainer, "DefaultContainer",
935 non_lock_screen_containers);
936 default_container->SetChildWindowVisibilityChangesAnimated();
937 default_container->SetSnapsChildrenToPhysicalPixelBoundary();
938 default_container->SetBoundsInScreenBehaviorForChildren(
939 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
940 default_container->SetChildrenUseExtendedHitRegion();
941
942 WmWindow* always_on_top_container =
943 CreateContainer(kShellWindowId_AlwaysOnTopContainer,
944 "AlwaysOnTopContainer", non_lock_screen_containers);
945 always_on_top_container->SetChildWindowVisibilityChangesAnimated();
946 always_on_top_container->SetSnapsChildrenToPhysicalPixelBoundary();
947 always_on_top_container->SetBoundsInScreenBehaviorForChildren(
948 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
949
950 WmWindow* docked_container =
951 CreateContainer(kShellWindowId_DockedContainer, "DockedContainer",
952 non_lock_screen_containers);
953 docked_container->SetChildWindowVisibilityChangesAnimated();
954 docked_container->SetSnapsChildrenToPhysicalPixelBoundary();
955 docked_container->SetBoundsInScreenBehaviorForChildren(
956 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
957 docked_container->SetChildrenUseExtendedHitRegion();
958
959 WmWindow* shelf_container =
960 CreateContainer(kShellWindowId_ShelfContainer, "ShelfContainer",
961 non_lock_screen_containers);
962 shelf_container->SetSnapsChildrenToPhysicalPixelBoundary();
963 shelf_container->SetBoundsInScreenBehaviorForChildren(
964 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
965 shelf_container->SetLockedToRoot(true);
966
967 WmWindow* panel_container =
968 CreateContainer(kShellWindowId_PanelContainer, "PanelContainer",
969 non_lock_screen_containers);
970 panel_container->SetSnapsChildrenToPhysicalPixelBoundary();
971 panel_container->SetBoundsInScreenBehaviorForChildren(
972 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
973
974 WmWindow* shelf_bubble_container =
975 CreateContainer(kShellWindowId_ShelfBubbleContainer,
976 "ShelfBubbleContainer", non_lock_screen_containers);
977 shelf_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
978 shelf_bubble_container->SetBoundsInScreenBehaviorForChildren(
979 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
980 shelf_bubble_container->SetLockedToRoot(true);
981
982 WmWindow* app_list_container =
983 CreateContainer(kShellWindowId_AppListContainer, "AppListContainer",
984 non_lock_screen_containers);
985 app_list_container->SetSnapsChildrenToPhysicalPixelBoundary();
986 app_list_container->SetBoundsInScreenBehaviorForChildren(
987 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
988
989 WmWindow* modal_container =
990 CreateContainer(kShellWindowId_SystemModalContainer,
991 "SystemModalContainer", non_lock_screen_containers);
992 modal_container->SetSnapsChildrenToPhysicalPixelBoundary();
993 modal_container->SetChildWindowVisibilityChangesAnimated();
994 modal_container->SetBoundsInScreenBehaviorForChildren(
995 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
996 modal_container->SetChildrenUseExtendedHitRegion();
997
998 // TODO(beng): Figure out if we can make this use
999 // SystemModalContainerEventFilter instead of stops_event_propagation.
1000 WmWindow* lock_container =
1001 CreateContainer(kShellWindowId_LockScreenContainer, "LockScreenContainer",
1002 lock_screen_containers);
1003 lock_container->SetSnapsChildrenToPhysicalPixelBoundary();
1004 lock_container->SetBoundsInScreenBehaviorForChildren(
1005 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1006 // TODO(beng): stopsevents
1007
1008 WmWindow* lock_modal_container =
1009 CreateContainer(kShellWindowId_LockSystemModalContainer,
1010 "LockSystemModalContainer", lock_screen_containers);
1011 lock_modal_container->SetSnapsChildrenToPhysicalPixelBoundary();
1012 lock_modal_container->SetChildWindowVisibilityChangesAnimated();
1013 lock_modal_container->SetBoundsInScreenBehaviorForChildren(
1014 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1015 lock_modal_container->SetChildrenUseExtendedHitRegion();
1016
1017 WmWindow* status_container =
1018 CreateContainer(kShellWindowId_StatusContainer, "StatusContainer",
1019 lock_screen_related_containers);
1020 status_container->SetSnapsChildrenToPhysicalPixelBoundary();
1021 status_container->SetBoundsInScreenBehaviorForChildren(
1022 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1023 status_container->SetLockedToRoot(true);
1024
1025 WmWindow* settings_bubble_container =
1026 CreateContainer(kShellWindowId_SettingBubbleContainer,
1027 "SettingBubbleContainer", lock_screen_related_containers);
1028 settings_bubble_container->SetChildWindowVisibilityChangesAnimated();
1029 settings_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
1030 settings_bubble_container->SetBoundsInScreenBehaviorForChildren(
1031 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1032 settings_bubble_container->SetLockedToRoot(true);
1033
1034 WmWindow* virtual_keyboard_parent_container = CreateContainer(
1035 kShellWindowId_ImeWindowParentContainer, "VirtualKeyboardParentContainer",
1036 lock_screen_related_containers);
1037 virtual_keyboard_parent_container->SetSnapsChildrenToPhysicalPixelBoundary();
1038 virtual_keyboard_parent_container->SetBoundsInScreenBehaviorForChildren(
1039 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1040
1041 WmWindow* menu_container =
1042 CreateContainer(kShellWindowId_MenuContainer, "MenuContainer",
1043 lock_screen_related_containers);
1044 menu_container->SetChildWindowVisibilityChangesAnimated();
1045 menu_container->SetSnapsChildrenToPhysicalPixelBoundary();
1046 menu_container->SetBoundsInScreenBehaviorForChildren(
1047 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1048
1049 WmWindow* drag_drop_container = CreateContainer(
1050 kShellWindowId_DragImageAndTooltipContainer,
1051 "DragImageAndTooltipContainer", lock_screen_related_containers);
1052 drag_drop_container->SetChildWindowVisibilityChangesAnimated();
1053 drag_drop_container->SetSnapsChildrenToPhysicalPixelBoundary();
1054 drag_drop_container->SetBoundsInScreenBehaviorForChildren(
1055 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1056
1057 WmWindow* overlay_container =
1058 CreateContainer(kShellWindowId_OverlayContainer, "OverlayContainer",
1059 lock_screen_related_containers);
1060 overlay_container->SetSnapsChildrenToPhysicalPixelBoundary();
1061 overlay_container->SetBoundsInScreenBehaviorForChildren(
1062 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1063
1064 WmWindow* mouse_cursor_container = CreateContainer(
1065 kShellWindowId_MouseCursorContainer, "MouseCursorContainer", root);
1066 mouse_cursor_container->SetBoundsInScreenBehaviorForChildren(
1067 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1068
1069 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
1070 "PowerButtonAnimationContainer", root);
1071 } 516 }
1072 517
1073 void RootWindowController::CreateSystemWallpaper( 518 void RootWindowController::CreateSystemWallpaper(
1074 RootWindowType root_window_type) { 519 RootWindowType root_window_type) {
1075 SkColor color = SK_ColorBLACK; 520 SkColor color = SK_ColorBLACK;
1076 // The splash screen appears on the primary display at boot. If this is a 521 // The splash screen appears on the primary display at boot. If this is a
1077 // secondary monitor (either connected at boot or connected later) or if the 522 // secondary monitor (either connected at boot or connected later) or if the
1078 // browser restarted for a second login then don't use the boot color. 523 // browser restarted for a second login then don't use the boot color.
1079 const bool is_boot_splash_screen = 524 const bool is_boot_splash_screen =
1080 root_window_type == RootWindowType::PRIMARY && 525 root_window_type == RootWindowType::PRIMARY &&
(...skipping 19 matching lines...) Expand all
1100 return; 545 return;
1101 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); 546 set_touch_hud_projection(new TouchHudProjection(GetRootWindow()));
1102 } 547 }
1103 548
1104 void RootWindowController::DisableTouchHudProjection() { 549 void RootWindowController::DisableTouchHudProjection() {
1105 if (!touch_hud_projection_) 550 if (!touch_hud_projection_)
1106 return; 551 return;
1107 touch_hud_projection_->Remove(); 552 touch_hud_projection_->Remove();
1108 } 553 }
1109 554
1110 void RootWindowController::ResetRootForNewWindowsIfNecessary() {
1111 WmShell* shell = WmShell::Get();
1112 // Change the target root window before closing child windows. If any child
1113 // being removed triggers a relayout of the shelf it will try to build a
1114 // window list adding windows from the target root window's containers which
1115 // may have already gone away.
1116 WmWindow* root = GetWindow();
1117 if (shell->GetRootWindowForNewWindows() == root) {
1118 // The root window for new windows is being destroyed. Switch to the primary
1119 // root window if possible.
1120 WmWindow* primary_root = shell->GetPrimaryRootWindow();
1121 shell->set_root_window_for_new_windows(primary_root == root ? nullptr
1122 : primary_root);
1123 }
1124 }
1125
1126 void RootWindowController::OnMenuClosed() {
1127 menu_runner_.reset();
1128 menu_model_adapter_.reset();
1129 menu_model_.reset();
1130 wm_shelf_->UpdateVisibilityState();
1131 }
1132
1133 void RootWindowController::OnLoginStateChanged(LoginStatus status) { 555 void RootWindowController::OnLoginStateChanged(LoginStatus status) {
1134 wm_shelf_->UpdateVisibilityState(); 556 wm_shelf_->UpdateVisibilityState();
1135 } 557 }
1136 558
1137 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { 559 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
1138 if (enabled) 560 if (enabled)
1139 EnableTouchHudProjection(); 561 EnableTouchHudProjection();
1140 else 562 else
1141 DisableTouchHudProjection(); 563 DisableTouchHudProjection();
1142 } 564 }
1143 565
1144 RootWindowController* GetRootWindowController(const aura::Window* root_window) { 566 RootWindowController* GetRootWindowController(const aura::Window* root_window) {
1145 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; 567 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr;
1146 } 568 }
1147 569
1148 } // namespace ash 570 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698