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

Side by Side Diff: ash/root_window_controller.cc

Issue 2318223003: mash: Migrate wallpaper controllers to ash/common. (Closed)
Patch Set: Fix nit. Created 4 years, 3 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') | ash/shell.h » ('j') | 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/aura/aura_layout_manager_adapter.h" 10 #include "ash/aura/aura_layout_manager_adapter.h"
11 #include "ash/aura/wm_root_window_controller_aura.h" 11 #include "ash/aura/wm_root_window_controller_aura.h"
12 #include "ash/aura/wm_shelf_aura.h" 12 #include "ash/aura/wm_shelf_aura.h"
13 #include "ash/aura/wm_window_aura.h" 13 #include "ash/aura/wm_window_aura.h"
14 #include "ash/common/ash_constants.h" 14 #include "ash/common/ash_constants.h"
15 #include "ash/common/ash_switches.h" 15 #include "ash/common/ash_switches.h"
16 #include "ash/common/focus_cycler.h" 16 #include "ash/common/focus_cycler.h"
17 #include "ash/common/login_status.h" 17 #include "ash/common/login_status.h"
18 #include "ash/common/session/session_state_delegate.h" 18 #include "ash/common/session/session_state_delegate.h"
19 #include "ash/common/shelf/shelf_delegate.h" 19 #include "ash/common/shelf/shelf_delegate.h"
20 #include "ash/common/shelf/shelf_layout_manager.h" 20 #include "ash/common/shelf/shelf_layout_manager.h"
21 #include "ash/common/shelf/shelf_types.h" 21 #include "ash/common/shelf/shelf_types.h"
22 #include "ash/common/shelf/shelf_widget.h" 22 #include "ash/common/shelf/shelf_widget.h"
23 #include "ash/common/shell_delegate.h" 23 #include "ash/common/shell_delegate.h"
24 #include "ash/common/shell_window_ids.h" 24 #include "ash/common/shell_window_ids.h"
25 #include "ash/common/system/status_area_layout_manager.h" 25 #include "ash/common/system/status_area_layout_manager.h"
26 #include "ash/common/system/status_area_widget.h" 26 #include "ash/common/system/status_area_widget.h"
27 #include "ash/common/system/tray/system_tray_delegate.h" 27 #include "ash/common/system/tray/system_tray_delegate.h"
28 #include "ash/common/wallpaper/wallpaper_delegate.h" 28 #include "ash/common/wallpaper/wallpaper_delegate.h"
29 #include "ash/common/wallpaper/wallpaper_widget_controller.h"
29 #include "ash/common/wm/always_on_top_controller.h" 30 #include "ash/common/wm/always_on_top_controller.h"
30 #include "ash/common/wm/container_finder.h" 31 #include "ash/common/wm/container_finder.h"
31 #include "ash/common/wm/dock/docked_window_layout_manager.h" 32 #include "ash/common/wm/dock/docked_window_layout_manager.h"
32 #include "ash/common/wm/fullscreen_window_finder.h" 33 #include "ash/common/wm/fullscreen_window_finder.h"
33 #include "ash/common/wm/panels/panel_layout_manager.h" 34 #include "ash/common/wm/panels/panel_layout_manager.h"
34 #include "ash/common/wm/root_window_layout_manager.h" 35 #include "ash/common/wm/root_window_layout_manager.h"
35 #include "ash/common/wm/switchable_windows.h" 36 #include "ash/common/wm/switchable_windows.h"
36 #include "ash/common/wm/window_state.h" 37 #include "ash/common/wm/window_state.h"
37 #include "ash/common/wm/workspace/workspace_layout_manager.h" 38 #include "ash/common/wm/workspace/workspace_layout_manager.h"
38 #include "ash/common/wm/workspace_controller.h" 39 #include "ash/common/wm/workspace_controller.h"
39 #include "ash/common/wm_shell.h" 40 #include "ash/common/wm_shell.h"
40 #include "ash/common/wm_window.h" 41 #include "ash/common/wm_window.h"
41 #include "ash/display/display_manager.h" 42 #include "ash/display/display_manager.h"
42 #include "ash/high_contrast/high_contrast_controller.h" 43 #include "ash/high_contrast/high_contrast_controller.h"
43 #include "ash/host/ash_window_tree_host.h" 44 #include "ash/host/ash_window_tree_host.h"
44 #include "ash/root_window_settings.h" 45 #include "ash/root_window_settings.h"
45 #include "ash/shelf/shelf_window_targeter.h" 46 #include "ash/shelf/shelf_window_targeter.h"
46 #include "ash/shell.h" 47 #include "ash/shell.h"
47 #include "ash/touch/touch_hud_debug.h" 48 #include "ash/touch/touch_hud_debug.h"
48 #include "ash/touch/touch_hud_projection.h" 49 #include "ash/touch/touch_hud_projection.h"
49 #include "ash/touch/touch_observer_hud.h" 50 #include "ash/touch/touch_observer_hud.h"
50 #include "ash/wallpaper/wallpaper_widget_controller.h"
51 #include "ash/wm/lock_layout_manager.h" 51 #include "ash/wm/lock_layout_manager.h"
52 #include "ash/wm/panels/attached_panel_window_targeter.h" 52 #include "ash/wm/panels/attached_panel_window_targeter.h"
53 #include "ash/wm/panels/panel_window_event_handler.h" 53 #include "ash/wm/panels/panel_window_event_handler.h"
54 #include "ash/wm/stacking_controller.h" 54 #include "ash/wm/stacking_controller.h"
55 #include "ash/wm/system_modal_container_layout_manager.h" 55 #include "ash/wm/system_modal_container_layout_manager.h"
56 #include "ash/wm/system_wallpaper_controller.h" 56 #include "ash/wm/system_wallpaper_controller.h"
57 #include "ash/wm/window_properties.h" 57 #include "ash/wm/window_properties.h"
58 #include "ash/wm/window_state_aura.h" 58 #include "ash/wm/window_state_aura.h"
59 #include "ash/wm/window_util.h" 59 #include "ash/wm/window_util.h"
60 #include "base/command_line.h" 60 #include "base/command_line.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 327 }
328 328
329 const aura::Window* RootWindowController::GetRootWindow() const { 329 const aura::Window* RootWindowController::GetRootWindow() const {
330 return GetHost()->window(); 330 return GetHost()->window();
331 } 331 }
332 332
333 WorkspaceController* RootWindowController::workspace_controller() { 333 WorkspaceController* RootWindowController::workspace_controller() {
334 return wm_root_window_controller_->workspace_controller(); 334 return wm_root_window_controller_->workspace_controller();
335 } 335 }
336 336
337 void RootWindowController::SetWallpaperWidgetController(
338 WallpaperWidgetController* controller) {
339 wallpaper_widget_controller_.reset(controller);
340 }
341
342 void RootWindowController::SetAnimatingWallpaperWidgetController(
343 AnimatingWallpaperWidgetController* controller) {
344 if (animating_wallpaper_widget_controller_.get())
345 animating_wallpaper_widget_controller_->StopAnimating();
346 animating_wallpaper_widget_controller_.reset(controller);
347 }
348
349 void RootWindowController::Shutdown() { 337 void RootWindowController::Shutdown() {
350 WmShell::Get()->RemoveShellObserver(this); 338 WmShell::Get()->RemoveShellObserver(this);
351 339
352 #if defined(OS_CHROMEOS) 340 #if defined(OS_CHROMEOS)
353 if (touch_exploration_manager_) { 341 if (touch_exploration_manager_) {
354 touch_exploration_manager_.reset(); 342 touch_exploration_manager_.reset();
355 } 343 }
356 #endif 344 #endif
357 345
358 if (animating_wallpaper_widget_controller_.get())
359 animating_wallpaper_widget_controller_->StopAnimating();
360 wallpaper_widget_controller_.reset();
361 animating_wallpaper_widget_controller_.reset();
362 aura::Window* root_window = GetRootWindow(); 346 aura::Window* root_window = GetRootWindow();
363 WmWindow* root_shutting_down = WmWindowAura::Get(root_window); 347 WmWindow* root_shutting_down = WmWindowAura::Get(root_window);
364 WmShell* shell = WmShell::Get(); 348 WmShell* shell = WmShell::Get();
365 // Change the target root window before closing child windows. If any child 349 // Change the target root window before closing child windows. If any child
366 // being removed triggers a relayout of the shelf it will try to build a 350 // being removed triggers a relayout of the shelf it will try to build a
367 // window list adding windows from the target root window's containers which 351 // window list adding windows from the target root window's containers which
368 // may have already gone away. 352 // may have already gone away.
369 if (shell->GetRootWindowForNewWindows() == root_shutting_down) { 353 if (shell->GetRootWindowForNewWindows() == root_shutting_down) {
370 // The root window for new windows is being destroyed. Switch to the primary 354 // The root window for new windows is being destroyed. Switch to the primary
371 // root window if possible. 355 // root window if possible.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 480
497 void RootWindowController::UpdateAfterLoginStatusChange(LoginStatus status) { 481 void RootWindowController::UpdateAfterLoginStatusChange(LoginStatus status) {
498 if (status != LoginStatus::NOT_LOGGED_IN) 482 if (status != LoginStatus::NOT_LOGGED_IN)
499 mouse_event_target_.reset(); 483 mouse_event_target_.reset();
500 StatusAreaWidget* status_area_widget = 484 StatusAreaWidget* status_area_widget =
501 wm_shelf_aura_->shelf_widget()->status_area_widget(); 485 wm_shelf_aura_->shelf_widget()->status_area_widget();
502 if (status_area_widget) 486 if (status_area_widget)
503 status_area_widget->UpdateAfterLoginStatusChange(status); 487 status_area_widget->UpdateAfterLoginStatusChange(status);
504 } 488 }
505 489
506 void RootWindowController::HandleInitialWallpaperAnimationStarted() { 490 void RootWindowController::OnInitialWallpaperAnimationStarted() {
507 #if defined(OS_CHROMEOS) 491 #if defined(OS_CHROMEOS)
508 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 492 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
509 switches::kAshAnimateFromBootSplashScreen) && 493 switches::kAshAnimateFromBootSplashScreen) &&
510 boot_splash_screen_.get()) { 494 boot_splash_screen_.get()) {
511 // Make the splash screen fade out so it doesn't obscure the wallpaper's 495 // Make the splash screen fade out so it doesn't obscure the wallpaper's
512 // brightness/grayscale animation. 496 // brightness/grayscale animation.
513 boot_splash_screen_->StartHideAnimation( 497 boot_splash_screen_->StartHideAnimation(
514 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs)); 498 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs));
515 } 499 }
516 #endif 500 #endif
517 } 501 }
518 502
519 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) { 503 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) {
520 // Make sure the wallpaper is visible. 504 // Make sure the wallpaper is visible.
521 system_wallpaper_->SetColor(SK_ColorBLACK); 505 system_wallpaper_->SetColor(SK_ColorBLACK);
522 #if defined(OS_CHROMEOS) 506 #if defined(OS_CHROMEOS)
523 boot_splash_screen_.reset(); 507 boot_splash_screen_.reset();
524 #endif 508 #endif
525
526 WmShell::Get()->wallpaper_delegate()->OnWallpaperAnimationFinished();
527 // 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
529 // be a white flash during the animation.
530 if (animating_wallpaper_widget_controller()) {
531 WallpaperWidgetController* controller =
532 animating_wallpaper_widget_controller()->GetController(true);
533 DCHECK_EQ(controller->widget(), widget);
534 // Release the old controller and close its wallpaper widget.
535 SetWallpaperWidgetController(controller);
536 }
537 } 509 }
538 510
539 void RootWindowController::CloseChildWindows() { 511 void RootWindowController::CloseChildWindows() {
540 mouse_event_target_.reset(); 512 mouse_event_target_.reset();
541 513
542 // Remove observer as deactivating keyboard causes |docked_layout_manager_| 514 // Remove observer as deactivating keyboard causes |docked_layout_manager_|
543 // to fire notifications. 515 // to fire notifications.
544 if (docked_layout_manager_ && wm_shelf_aura_->shelf_layout_manager()) { 516 if (docked_layout_manager_ && wm_shelf_aura_->shelf_layout_manager()) {
545 docked_layout_manager_->RemoveObserver( 517 docked_layout_manager_->RemoveObserver(
546 wm_shelf_aura_->shelf_layout_manager()); 518 wm_shelf_aura_->shelf_layout_manager());
(...skipping 11 matching lines...) Expand all
558 // docked_layout_manager_ needs to be shut down before windows are destroyed. 530 // docked_layout_manager_ needs to be shut down before windows are destroyed.
559 if (docked_layout_manager_) { 531 if (docked_layout_manager_) {
560 docked_layout_manager_->Shutdown(); 532 docked_layout_manager_->Shutdown();
561 docked_layout_manager_ = NULL; 533 docked_layout_manager_ = NULL;
562 } 534 }
563 aura::Window* root_window = GetRootWindow(); 535 aura::Window* root_window = GetRootWindow();
564 aura::client::SetDragDropClient(root_window, NULL); 536 aura::client::SetDragDropClient(root_window, NULL);
565 537
566 wm_shelf_aura_->ShutdownShelfWidget(); 538 wm_shelf_aura_->ShutdownShelfWidget();
567 539
568 // Close wallpaper widget first as it depends on tooltip.
569 wallpaper_widget_controller_.reset();
570 animating_wallpaper_widget_controller_.reset();
571
572 wm_root_window_controller_->DeleteWorkspaceController(); 540 wm_root_window_controller_->DeleteWorkspaceController();
573 aura::client::SetTooltipClient(root_window, NULL); 541 aura::client::SetTooltipClient(root_window, NULL);
574 542
575 // Explicitly destroy top level windows. We do this as during part of 543 // Explicitly destroy top level windows. We do this as during part of
576 // destruction such windows may query the RootWindow for state. 544 // destruction such windows may query the RootWindow for state.
577 aura::WindowTracker non_toplevel_windows; 545 aura::WindowTracker non_toplevel_windows;
578 non_toplevel_windows.Add(root_window); 546 non_toplevel_windows.Add(root_window);
579 while (!non_toplevel_windows.windows().empty()) { 547 while (!non_toplevel_windows.windows().empty()) {
580 const aura::Window* non_toplevel_window = 548 const aura::Window* non_toplevel_window =
581 *non_toplevel_windows.windows().begin(); 549 *non_toplevel_windows.windows().begin();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 menu_model_.reset(delegate->CreateContextMenu(wm_shelf_aura_.get(), nullptr)); 608 menu_model_.reset(delegate->CreateContextMenu(wm_shelf_aura_.get(), nullptr));
641 if (!menu_model_) 609 if (!menu_model_)
642 return; 610 return;
643 611
644 menu_model_adapter_.reset(new views::MenuModelAdapter( 612 menu_model_adapter_.reset(new views::MenuModelAdapter(
645 menu_model_.get(), 613 menu_model_.get(),
646 base::Bind(&RootWindowController::OnMenuClosed, base::Unretained(this)))); 614 base::Bind(&RootWindowController::OnMenuClosed, base::Unretained(this))));
647 615
648 // Wallpaper controller may not be set yet if user clicked on status are 616 // Wallpaper controller may not be set yet if user clicked on status are
649 // before initial animation completion. See crbug.com/222218 617 // before initial animation completion. See crbug.com/222218
650 if (!wallpaper_widget_controller_.get()) 618 WallpaperWidgetController* wallpaper_widget_controller =
619 wm_root_window_controller_->wallpaper_widget_controller();
620 if (!wallpaper_widget_controller)
651 return; 621 return;
652 622
653 menu_runner_.reset(new views::MenuRunner( 623 menu_runner_.reset(new views::MenuRunner(
654 menu_model_adapter_->CreateMenu(), 624 menu_model_adapter_->CreateMenu(),
655 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC)); 625 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC));
656 ignore_result( 626 ignore_result(
657 menu_runner_->RunMenuAt(wallpaper_widget_controller_->widget(), nullptr, 627 menu_runner_->RunMenuAt(wallpaper_widget_controller->widget(), nullptr,
658 gfx::Rect(location_in_screen, gfx::Size()), 628 gfx::Rect(location_in_screen, gfx::Size()),
659 views::MENU_ANCHOR_TOPLEFT, source_type)); 629 views::MENU_ANCHOR_TOPLEFT, source_type));
660 } 630 }
661 631
662 void RootWindowController::UpdateShelfVisibility() { 632 void RootWindowController::UpdateShelfVisibility() {
663 wm_shelf_aura_->UpdateVisibilityState(); 633 wm_shelf_aura_->UpdateVisibilityState();
664 } 634 }
665 635
666 aura::Window* RootWindowController::GetWindowForFullscreenMode() { 636 aura::Window* RootWindowController::GetWindowForFullscreenMode() {
667 return WmWindowAura::GetAuraWindow( 637 return WmWindowAura::GetAuraWindow(
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 aura::Window* primary_root_window = Shell::GetInstance() 920 aura::Window* primary_root_window = Shell::GetInstance()
951 ->window_tree_host_manager() 921 ->window_tree_host_manager()
952 ->GetPrimaryRootWindow(); 922 ->GetPrimaryRootWindow();
953 return GetRootWindowSettings(primary_root_window)->controller; 923 return GetRootWindowSettings(primary_root_window)->controller;
954 } 924 }
955 925
956 return GetRootWindowSettings(root_window)->controller; 926 return GetRootWindowSettings(root_window)->controller;
957 } 927 }
958 928
959 } // namespace ash 929 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698