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

Side by Side Diff: ash/root_window_controller.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/root_window_controller_unittest.cc » ('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"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // wm/window_animation.cc's brightness/grayscale fade animation that the login 101 // wm/window_animation.cc's brightness/grayscale fade animation that the login
102 // background image animation isn't hidden by the splash screen animation. 102 // background image animation isn't hidden by the splash screen animation.
103 const int kBootSplashScreenHideDurationMs = 500; 103 const int kBootSplashScreenHideDurationMs = 500;
104 #endif 104 #endif
105 105
106 float ToRelativeValue(int value, int src, int dst) { 106 float ToRelativeValue(int value, int src, int dst) {
107 return static_cast<float>(value) / static_cast<float>(src) * dst; 107 return static_cast<float>(value) / static_cast<float>(src) * dst;
108 } 108 }
109 109
110 void MoveOriginRelativeToSize(const gfx::Size& src_size, 110 void MoveOriginRelativeToSize(const gfx::Size& src_size,
111 const gfx::Size& dst_size, 111 const gfx::Size& dst_size,
112 gfx::Rect* bounds_in_out) { 112 gfx::Rect* bounds_in_out) {
113 gfx::Point origin = bounds_in_out->origin(); 113 gfx::Point origin = bounds_in_out->origin();
114 bounds_in_out->set_origin(gfx::Point( 114 bounds_in_out->set_origin(gfx::Point(
115 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()), 115 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()),
116 ToRelativeValue(origin.y(), src_size.height(), dst_size.height()))); 116 ToRelativeValue(origin.y(), src_size.height(), dst_size.height())));
117 } 117 }
118 118
119 // Reparents |window| to |new_parent|. 119 // Reparents |window| to |new_parent|.
120 void ReparentWindow(aura::Window* window, aura::Window* new_parent) { 120 void ReparentWindow(aura::Window* window, aura::Window* new_parent) {
121 const gfx::Size src_size = window->parent()->bounds().size(); 121 const gfx::Size src_size = window->parent()->bounds().size();
122 const gfx::Size dst_size = new_parent->bounds().size(); 122 const gfx::Size dst_size = new_parent->bounds().size();
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 animating_wallpaper_controller_->StopAnimating(); 384 animating_wallpaper_controller_->StopAnimating();
385 wallpaper_controller_.reset(); 385 wallpaper_controller_.reset();
386 animating_wallpaper_controller_.reset(); 386 animating_wallpaper_controller_.reset();
387 aura::Window* root_window = GetRootWindow(); 387 aura::Window* root_window = GetRootWindow();
388 Shell* shell = Shell::GetInstance(); 388 Shell* shell = Shell::GetInstance();
389 // Change the target root window before closing child windows. If any child 389 // Change the target root window before closing child windows. If any child
390 // being removed triggers a relayout of the shelf it will try to build a 390 // being removed triggers a relayout of the shelf it will try to build a
391 // window list adding windows from the target root window's containers which 391 // window list adding windows from the target root window's containers which
392 // may have already gone away. 392 // may have already gone away.
393 if (Shell::GetTargetRootWindow() == root_window) { 393 if (Shell::GetTargetRootWindow() == root_window) {
394 shell->set_target_root_window( 394 shell->set_target_root_window(Shell::GetPrimaryRootWindow() == root_window
395 Shell::GetPrimaryRootWindow() == root_window 395 ? NULL
396 ? NULL 396 : Shell::GetPrimaryRootWindow());
397 : Shell::GetPrimaryRootWindow());
398 } 397 }
399 398
400 CloseChildWindows(); 399 CloseChildWindows();
401 GetRootWindowSettings(root_window)->controller = NULL; 400 GetRootWindowSettings(root_window)->controller = NULL;
402 workspace_controller_.reset(); 401 workspace_controller_.reset();
403 // Forget with the display ID so that display lookup 402 // Forget with the display ID so that display lookup
404 // ends up with invalid display. 403 // ends up with invalid display.
405 GetRootWindowSettings(root_window)->display_id = 404 GetRootWindowSettings(root_window)->display_id =
406 display::Display::kInvalidDisplayID; 405 display::Display::kInvalidDisplayID;
407 ash_host_->PrepareForShutdown(); 406 ash_host_->PrepareForShutdown();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 if (window) { 459 if (window) {
461 aura::Window* window_container = WmWindowAura::GetAuraWindow( 460 aura::Window* window_container = WmWindowAura::GetAuraWindow(
462 wm::GetContainerForWindow(WmWindowAura::Get(window))); 461 wm::GetContainerForWindow(WmWindowAura::Get(window)));
463 if (window_container && 462 if (window_container &&
464 window_container->id() >= kShellWindowId_LockScreenContainer) { 463 window_container->id() >= kShellWindowId_LockScreenContainer) {
465 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer); 464 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer);
466 } else { 465 } else {
467 modal_container = GetContainer(kShellWindowId_SystemModalContainer); 466 modal_container = GetContainer(kShellWindowId_SystemModalContainer);
468 } 467 }
469 } else { 468 } else {
470 int modal_window_id = Shell::GetInstance()->session_state_delegate() 469 int modal_window_id =
471 ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer : 470 Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked()
472 kShellWindowId_SystemModalContainer; 471 ? kShellWindowId_LockSystemModalContainer
472 : kShellWindowId_SystemModalContainer;
473 modal_container = GetContainer(modal_window_id); 473 modal_container = GetContainer(modal_window_id);
474 } 474 }
475 return modal_container ? static_cast<SystemModalContainerLayoutManager*>( 475 return modal_container ? static_cast<SystemModalContainerLayoutManager*>(
476 modal_container->layout_manager()) : NULL; 476 modal_container->layout_manager())
477 : NULL;
477 } 478 }
478 479
479 aura::Window* RootWindowController::GetContainer(int container_id) { 480 aura::Window* RootWindowController::GetContainer(int container_id) {
480 return GetRootWindow()->GetChildById(container_id); 481 return GetRootWindow()->GetChildById(container_id);
481 } 482 }
482 483
483 const aura::Window* RootWindowController::GetContainer(int container_id) const { 484 const aura::Window* RootWindowController::GetContainer(int container_id) const {
484 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id); 485 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id);
485 } 486 }
486 487
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 #endif 538 #endif
538 } 539 }
539 540
540 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) { 541 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) {
541 // Make sure the wallpaper is visible. 542 // Make sure the wallpaper is visible.
542 system_background_->SetColor(SK_ColorBLACK); 543 system_background_->SetColor(SK_ColorBLACK);
543 #if defined(OS_CHROMEOS) 544 #if defined(OS_CHROMEOS)
544 boot_splash_screen_.reset(); 545 boot_splash_screen_.reset();
545 #endif 546 #endif
546 547
547 Shell::GetInstance()->user_wallpaper_delegate()-> 548 Shell::GetInstance()
548 OnWallpaperAnimationFinished(); 549 ->user_wallpaper_delegate()
550 ->OnWallpaperAnimationFinished();
549 // Only removes old component when wallpaper animation finished. If we 551 // Only removes old component when wallpaper animation finished. If we
550 // remove the old one before the new wallpaper is done fading in there will 552 // remove the old one before the new wallpaper is done fading in there will
551 // be a white flash during the animation. 553 // be a white flash during the animation.
552 if (animating_wallpaper_controller()) { 554 if (animating_wallpaper_controller()) {
553 DesktopBackgroundWidgetController* controller = 555 DesktopBackgroundWidgetController* controller =
554 animating_wallpaper_controller()->GetController(true); 556 animating_wallpaper_controller()->GetController(true);
555 // |desktop_widget_| should be the same animating widget we try to move 557 // |desktop_widget_| should be the same animating widget we try to move
556 // to |kDesktopController|. Otherwise, we may close |desktop_widget_| 558 // to |kDesktopController|. Otherwise, we may close |desktop_widget_|
557 // before move it to |kDesktopController|. 559 // before move it to |kDesktopController|.
558 DCHECK_EQ(controller->widget(), widget); 560 DCHECK_EQ(controller->widget(), widget);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 DCHECK(keyboard_controller); 699 DCHECK(keyboard_controller);
698 keyboard_controller->AddObserver(shelf_widget()->shelf_layout_manager()); 700 keyboard_controller->AddObserver(shelf_widget()->shelf_layout_manager());
699 keyboard_controller->AddObserver(panel_layout_manager_); 701 keyboard_controller->AddObserver(panel_layout_manager_);
700 keyboard_controller->AddObserver(docked_layout_manager_); 702 keyboard_controller->AddObserver(docked_layout_manager_);
701 keyboard_controller->AddObserver(workspace_controller_->layout_manager()); 703 keyboard_controller->AddObserver(workspace_controller_->layout_manager());
702 keyboard_controller->AddObserver( 704 keyboard_controller->AddObserver(
703 always_on_top_controller_->GetLayoutManager()); 705 always_on_top_controller_->GetLayoutManager());
704 Shell::GetInstance()->delegate()->VirtualKeyboardActivated(true); 706 Shell::GetInstance()->delegate()->VirtualKeyboardActivated(true);
705 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); 707 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
706 DCHECK(parent); 708 DCHECK(parent);
707 aura::Window* keyboard_container = 709 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow();
708 keyboard_controller->GetContainerWindow();
709 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); 710 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer);
710 parent->AddChild(keyboard_container); 711 parent->AddChild(keyboard_container);
711 } 712 }
712 713
713 void RootWindowController::DeactivateKeyboard( 714 void RootWindowController::DeactivateKeyboard(
714 keyboard::KeyboardController* keyboard_controller) { 715 keyboard::KeyboardController* keyboard_controller) {
715 if (!keyboard_controller || 716 if (!keyboard_controller ||
716 !keyboard_controller->keyboard_container_initialized()) { 717 !keyboard_controller->keyboard_container_initialized()) {
717 return; 718 return;
718 } 719 }
719 aura::Window* keyboard_container = 720 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow();
720 keyboard_controller->GetContainerWindow();
721 if (keyboard_container->GetRootWindow() == GetRootWindow()) { 721 if (keyboard_container->GetRootWindow() == GetRootWindow()) {
722 aura::Window* parent = 722 aura::Window* parent =
723 GetContainer(kShellWindowId_ImeWindowParentContainer); 723 GetContainer(kShellWindowId_ImeWindowParentContainer);
724 DCHECK(parent); 724 DCHECK(parent);
725 parent->RemoveChild(keyboard_container); 725 parent->RemoveChild(keyboard_container);
726 // Virtual keyboard may be deactivated while still showing, notify all 726 // Virtual keyboard may be deactivated while still showing, notify all
727 // observers that keyboard bounds changed to 0 before remove them. 727 // observers that keyboard bounds changed to 0 before remove them.
728 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect()); 728 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect());
729 keyboard_controller->RemoveObserver(shelf_widget()->shelf_layout_manager()); 729 keyboard_controller->RemoveObserver(shelf_widget()->shelf_layout_manager());
730 keyboard_controller->RemoveObserver(panel_layout_manager_); 730 keyboard_controller->RemoveObserver(panel_layout_manager_);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 Shell* shell = Shell::GetInstance(); 776 Shell* shell = Shell::GetInstance();
777 shell->InitRootWindow(root_window); 777 shell->InitRootWindow(root_window);
778 778
779 root_window_controller_common_->CreateContainers(); 779 root_window_controller_common_->CreateContainers();
780 780
781 CreateSystemBackground(first_run_after_boot); 781 CreateSystemBackground(first_run_after_boot);
782 782
783 InitLayoutManagers(); 783 InitLayoutManagers();
784 InitTouchHuds(); 784 InitTouchHuds();
785 785
786 if (Shell::GetPrimaryRootWindowController()-> 786 if (Shell::GetPrimaryRootWindowController()
787 GetSystemModalLayoutManager(NULL)->has_modal_background()) { 787 ->GetSystemModalLayoutManager(NULL)
788 ->has_modal_background()) {
788 GetSystemModalLayoutManager(NULL)->CreateModalBackground(); 789 GetSystemModalLayoutManager(NULL)->CreateModalBackground();
789 } 790 }
790 791
791 WmShell::Get()->AddShellObserver(this); 792 WmShell::Get()->AddShellObserver(this);
792 793
793 root_window_controller_common_->root_window_layout()->OnWindowResized(); 794 root_window_controller_common_->root_window_layout()->OnWindowResized();
794 if (root_window_type == PRIMARY) { 795 if (root_window_type == PRIMARY) {
795 shell->InitKeyboard(); 796 shell->InitKeyboard();
796 } else { 797 } else {
797 ash_host_->AsWindowTreeHost()->Show(); 798 ash_host_->AsWindowTreeHost()->Show();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 WmWindow* shelf_container = 853 WmWindow* shelf_container =
853 WmWindowAura::Get(GetContainer(kShellWindowId_ShelfContainer)); 854 WmWindowAura::Get(GetContainer(kShellWindowId_ShelfContainer));
854 WmWindow* status_container = 855 WmWindow* status_container =
855 WmWindowAura::Get(GetContainer(kShellWindowId_StatusContainer)); 856 WmWindowAura::Get(GetContainer(kShellWindowId_StatusContainer));
856 shelf_widget_.reset(new ShelfWidget(shelf_container, status_container, 857 shelf_widget_.reset(new ShelfWidget(shelf_container, status_container,
857 wm_shelf_aura_.get(), 858 wm_shelf_aura_.get(),
858 workspace_controller())); 859 workspace_controller()));
859 workspace_layout_manager_delegate->set_shelf( 860 workspace_layout_manager_delegate->set_shelf(
860 shelf_widget_->shelf_layout_manager()); 861 shelf_widget_->shelf_layout_manager());
861 862
862 if (!Shell::GetInstance()->session_state_delegate()-> 863 if (!Shell::GetInstance()
863 IsActiveUserSessionStarted()) { 864 ->session_state_delegate()
865 ->IsActiveUserSessionStarted()) {
864 // This window exists only to be a event target on login screen. 866 // This window exists only to be a event target on login screen.
865 // It does not have to handle events, nor be visible. 867 // It does not have to handle events, nor be visible.
866 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); 868 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate));
867 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); 869 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN);
868 870
869 aura::Window* lock_background_container = 871 aura::Window* lock_background_container =
870 GetContainer(kShellWindowId_LockScreenBackgroundContainer); 872 GetContainer(kShellWindowId_LockScreenBackgroundContainer);
871 lock_background_container->AddChild(mouse_event_target_.get()); 873 lock_background_container->AddChild(mouse_event_target_.get());
872 mouse_event_target_->Show(); 874 mouse_event_target_->Show();
873 } 875 }
(...skipping 11 matching lines...) Expand all
885 // Create Panel layout manager 887 // Create Panel layout manager
886 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer); 888 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer);
887 WmWindow* wm_panel_container = WmWindowAura::Get(panel_container); 889 WmWindow* wm_panel_container = WmWindowAura::Get(panel_container);
888 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container); 890 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container);
889 wm_panel_container->SetLayoutManager(base::WrapUnique(panel_layout_manager_)); 891 wm_panel_container->SetLayoutManager(base::WrapUnique(panel_layout_manager_));
890 panel_container_handler_.reset(new PanelWindowEventHandler); 892 panel_container_handler_.reset(new PanelWindowEventHandler);
891 panel_container->AddPreTargetHandler(panel_container_handler_.get()); 893 panel_container->AddPreTargetHandler(panel_container_handler_.get());
892 894
893 // Install an AttachedPanelWindowTargeter on the panel container to make it 895 // Install an AttachedPanelWindowTargeter on the panel container to make it
894 // easier to correctly target shelf buttons with touch. 896 // easier to correctly target shelf buttons with touch.
895 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, 897 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize,
896 -kResizeOutsideBoundsSize,
897 -kResizeOutsideBoundsSize, 898 -kResizeOutsideBoundsSize,
898 -kResizeOutsideBoundsSize); 899 -kResizeOutsideBoundsSize);
899 gfx::Insets touch_extend = mouse_extend.Scale( 900 gfx::Insets touch_extend =
900 kResizeOutsideBoundsScaleForTouch); 901 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch);
901 panel_container->SetEventTargeter( 902 panel_container->SetEventTargeter(
902 std::unique_ptr<ui::EventTargeter>(new AttachedPanelWindowTargeter( 903 std::unique_ptr<ui::EventTargeter>(new AttachedPanelWindowTargeter(
903 panel_container, mouse_extend, touch_extend, panel_layout_manager_))); 904 panel_container, mouse_extend, touch_extend, panel_layout_manager_)));
904 } 905 }
905 906
906 void RootWindowController::InitTouchHuds() { 907 void RootWindowController::InitTouchHuds() {
907 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 908 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
908 if (command_line->HasSwitch(switches::kAshTouchHud)) 909 if (command_line->HasSwitch(switches::kAshTouchHud))
909 set_touch_hud_debug(new TouchHudDebug(GetRootWindow())); 910 set_touch_hud_debug(new TouchHudDebug(GetRootWindow()));
910 if (Shell::GetInstance()->is_touch_hud_projection_enabled()) 911 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 shelf_widget_->shelf_layout_manager()->UpdateVisibilityState(); 957 shelf_widget_->shelf_layout_manager()->UpdateVisibilityState();
957 } 958 }
958 959
959 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { 960 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
960 if (enabled) 961 if (enabled)
961 EnableTouchHudProjection(); 962 EnableTouchHudProjection();
962 else 963 else
963 DisableTouchHudProjection(); 964 DisableTouchHudProjection();
964 } 965 }
965 966
966 RootWindowController* GetRootWindowController( 967 RootWindowController* GetRootWindowController(const aura::Window* root_window) {
967 const aura::Window* root_window) {
968 if (!root_window) 968 if (!root_window)
969 return nullptr; 969 return nullptr;
970 970
971 if (Shell::GetInstance()->in_mus()) { 971 if (Shell::GetInstance()->in_mus()) {
972 // On mus, like desktop aura, each top-level widget has its own root window, 972 // On mus, like desktop aura, each top-level widget has its own root window,
973 // so |root_window| is not necessarily the display's root. For now, just 973 // so |root_window| is not necessarily the display's root. For now, just
974 // the use the primary display root. 974 // the use the primary display root.
975 // TODO(jamescook): Multi-display support. This depends on how mus windows 975 // TODO(jamescook): Multi-display support. This depends on how mus windows
976 // will be owned by displays. 976 // will be owned by displays.
977 aura::Window* primary_root_window = Shell::GetInstance() 977 aura::Window* primary_root_window = Shell::GetInstance()
978 ->window_tree_host_manager() 978 ->window_tree_host_manager()
979 ->GetPrimaryRootWindow(); 979 ->GetPrimaryRootWindow();
980 return GetRootWindowSettings(primary_root_window)->controller; 980 return GetRootWindowSettings(primary_root_window)->controller;
981 } 981 }
982 982
983 return GetRootWindowSettings(root_window)->controller; 983 return GetRootWindowSettings(root_window)->controller;
984 } 984 }
985 985
986 } // namespace ash 986 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/root_window_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698