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

Side by Side Diff: ash/root_window_controller.cc

Issue 2027733002: Creates RootWindowControllerCommon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@create_containers_wm_types
Patch Set: merge 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_common.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/ash_constants.h" 10 #include "ash/ash_constants.h"
11 #include "ash/ash_switches.h" 11 #include "ash/ash_switches.h"
12 #include "ash/desktop_background/desktop_background_controller.h" 12 #include "ash/desktop_background/desktop_background_controller.h"
13 #include "ash/desktop_background/desktop_background_widget_controller.h" 13 #include "ash/desktop_background/desktop_background_widget_controller.h"
14 #include "ash/desktop_background/user_wallpaper_delegate.h" 14 #include "ash/desktop_background/user_wallpaper_delegate.h"
15 #include "ash/display/display_manager.h" 15 #include "ash/display/display_manager.h"
16 #include "ash/focus_cycler.h" 16 #include "ash/focus_cycler.h"
17 #include "ash/high_contrast/high_contrast_controller.h" 17 #include "ash/high_contrast/high_contrast_controller.h"
18 #include "ash/host/ash_window_tree_host.h" 18 #include "ash/host/ash_window_tree_host.h"
19 #include "ash/root_window_controller_common.h"
19 #include "ash/root_window_settings.h" 20 #include "ash/root_window_settings.h"
20 #include "ash/session/session_state_delegate.h" 21 #include "ash/session/session_state_delegate.h"
21 #include "ash/shelf/shelf_layout_manager.h" 22 #include "ash/shelf/shelf_layout_manager.h"
22 #include "ash/shelf/shelf_types.h" 23 #include "ash/shelf/shelf_types.h"
23 #include "ash/shelf/shelf_widget.h" 24 #include "ash/shelf/shelf_widget.h"
24 #include "ash/shell.h" 25 #include "ash/shell.h"
25 #include "ash/shell_delegate.h" 26 #include "ash/shell_delegate.h"
26 #include "ash/shell_factory.h" 27 #include "ash/shell_factory.h"
27 #include "ash/shell_window_ids.h" 28 #include "ash/shell_window_ids.h"
28 #include "ash/system/status_area_widget.h" 29 #include "ash/system/status_area_widget.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 namespace { 96 namespace {
96 97
97 #if defined(OS_CHROMEOS) 98 #if defined(OS_CHROMEOS)
98 // Duration for the animation that hides the boot splash screen, in 99 // Duration for the animation that hides the boot splash screen, in
99 // milliseconds. This should be short enough in relation to 100 // milliseconds. This should be short enough in relation to
100 // 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
101 // background image animation isn't hidden by the splash screen animation. 102 // background image animation isn't hidden by the splash screen animation.
102 const int kBootSplashScreenHideDurationMs = 500; 103 const int kBootSplashScreenHideDurationMs = 500;
103 #endif 104 #endif
104 105
105 // Creates a new window for use as a container.
106 wm::WmWindow* CreateContainer(int window_id,
107 const char* name,
108 wm::WmWindow* parent) {
109 wm::WmWindow* window = wm::WmGlobals::Get()->NewContainerWindow();
110 window->SetShellWindowId(window_id);
111 window->SetName(name);
112 parent->AddChild(window);
113 if (window_id != kShellWindowId_UnparentedControlContainer)
114 window->Show();
115 return window;
116 }
117
118 float ToRelativeValue(int value, int src, int dst) { 106 float ToRelativeValue(int value, int src, int dst) {
119 return static_cast<float>(value) / static_cast<float>(src) * dst; 107 return static_cast<float>(value) / static_cast<float>(src) * dst;
120 } 108 }
121 109
122 void MoveOriginRelativeToSize(const gfx::Size& src_size, 110 void MoveOriginRelativeToSize(const gfx::Size& src_size,
123 const gfx::Size& dst_size, 111 const gfx::Size& dst_size,
124 gfx::Rect* bounds_in_out) { 112 gfx::Rect* bounds_in_out) {
125 gfx::Point origin = bounds_in_out->origin(); 113 gfx::Point origin = bounds_in_out->origin();
126 bounds_in_out->set_origin(gfx::Point( 114 bounds_in_out->set_origin(gfx::Point(
127 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()), 115 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()),
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // RootWindowController, private: 649 // RootWindowController, private:
662 650
663 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) 651 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host)
664 : ash_host_(ash_host), 652 : ash_host_(ash_host),
665 root_window_layout_(NULL), 653 root_window_layout_(NULL),
666 docked_layout_manager_(NULL), 654 docked_layout_manager_(NULL),
667 panel_layout_manager_(NULL), 655 panel_layout_manager_(NULL),
668 touch_hud_debug_(NULL), 656 touch_hud_debug_(NULL),
669 touch_hud_projection_(NULL) { 657 touch_hud_projection_(NULL) {
670 aura::Window* root_window = GetRootWindow(); 658 aura::Window* root_window = GetRootWindow();
659 root_window_controller_common_.reset(
660 new RootWindowControllerCommon(wm::WmWindowAura::Get(root_window)));
671 GetRootWindowSettings(root_window)->controller = this; 661 GetRootWindowSettings(root_window)->controller = this;
672 662
673 stacking_controller_.reset(new StackingController); 663 stacking_controller_.reset(new StackingController);
674 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get()); 664 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get());
675 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); 665 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window));
676 } 666 }
677 667
678 void RootWindowController::Init(RootWindowType root_window_type, 668 void RootWindowController::Init(RootWindowType root_window_type,
679 bool first_run_after_boot) { 669 bool first_run_after_boot) {
680 aura::Window* root_window = GetRootWindow(); 670 aura::Window* root_window = GetRootWindow();
681 Shell* shell = Shell::GetInstance(); 671 Shell* shell = Shell::GetInstance();
682 shell->InitRootWindow(root_window); 672 shell->InitRootWindow(root_window);
683 673
684 CreateContainersInRootWindow(wm::WmWindowAura::Get(root_window)); 674 root_window_controller_common_->CreateContainers();
685 675
686 CreateSystemBackground(first_run_after_boot); 676 CreateSystemBackground(first_run_after_boot);
687 677
688 InitLayoutManagers(); 678 InitLayoutManagers();
689 InitTouchHuds(); 679 InitTouchHuds();
690 680
691 if (Shell::GetPrimaryRootWindowController()-> 681 if (Shell::GetPrimaryRootWindowController()->
692 GetSystemModalLayoutManager(NULL)->has_modal_background()) { 682 GetSystemModalLayoutManager(NULL)->has_modal_background()) {
693 GetSystemModalLayoutManager(NULL)->CreateModalBackground(); 683 GetSystemModalLayoutManager(NULL)->CreateModalBackground();
694 } 684 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 // onscreen until the desktop background is ready. 821 // onscreen until the desktop background is ready.
832 if (is_first_run_after_boot && 822 if (is_first_run_after_boot &&
833 (base::CommandLine::ForCurrentProcess()->HasSwitch( 823 (base::CommandLine::ForCurrentProcess()->HasSwitch(
834 switches::kAshCopyHostBackgroundAtBoot) || 824 switches::kAshCopyHostBackgroundAtBoot) ||
835 base::CommandLine::ForCurrentProcess()->HasSwitch( 825 base::CommandLine::ForCurrentProcess()->HasSwitch(
836 switches::kAshAnimateFromBootSplashScreen))) 826 switches::kAshAnimateFromBootSplashScreen)))
837 boot_splash_screen_.reset(new BootSplashScreen(GetHost())); 827 boot_splash_screen_.reset(new BootSplashScreen(GetHost()));
838 #endif 828 #endif
839 } 829 }
840 830
841 void RootWindowController::CreateContainersInRootWindow(
842 wm::WmWindow* root_window) {
843 // These containers are just used by PowerButtonController to animate groups
844 // of containers simultaneously without messing up the current transformations
845 // on those containers. These are direct children of the root window; all of
846 // the other containers are their children.
847
848 // The desktop background container is not part of the lock animation, so it
849 // is not included in those animate groups.
850 // When screen is locked desktop background is moved to lock screen background
851 // container (moved back on unlock). We want to make sure that there's an
852 // opaque layer occluding the non-lock-screen layers.
853 wm::WmWindow* desktop_background_container =
854 CreateContainer(kShellWindowId_DesktopBackgroundContainer,
855 "DesktopBackgroundContainer", root_window);
856 desktop_background_container->SetChildWindowVisibilityChangesAnimated();
857
858 wm::WmWindow* non_lock_screen_containers =
859 CreateContainer(kShellWindowId_NonLockScreenContainersContainer,
860 "NonLockScreenContainersContainer", root_window);
861 // Clip all windows inside this container, as half pixel of the window's
862 // texture may become visible when the screen is scaled. crbug.com/368591.
863 non_lock_screen_containers->SetMasksToBounds(true);
864
865 wm::WmWindow* lock_background_containers =
866 CreateContainer(kShellWindowId_LockScreenBackgroundContainer,
867 "LockScreenBackgroundContainer", root_window);
868 lock_background_containers->SetChildWindowVisibilityChangesAnimated();
869
870 wm::WmWindow* lock_screen_containers =
871 CreateContainer(kShellWindowId_LockScreenContainersContainer,
872 "LockScreenContainersContainer", root_window);
873 wm::WmWindow* lock_screen_related_containers =
874 CreateContainer(kShellWindowId_LockScreenRelatedContainersContainer,
875 "LockScreenRelatedContainersContainer", root_window);
876
877 CreateContainer(kShellWindowId_UnparentedControlContainer,
878 "UnparentedControlContainer",
879 non_lock_screen_containers);
880
881 wm::WmWindow* default_container =
882 CreateContainer(kShellWindowId_DefaultContainer, "DefaultContainer",
883 non_lock_screen_containers);
884 default_container->SetChildWindowVisibilityChangesAnimated();
885 default_container->SetSnapsChildrenToPhysicalPixelBoundary();
886 default_container->SetBoundsInScreenBehaviorForChildren(
887 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
888 default_container->SetChildrenUseExtendedHitRegion();
889
890 wm::WmWindow* always_on_top_container =
891 CreateContainer(kShellWindowId_AlwaysOnTopContainer,
892 "AlwaysOnTopContainer", non_lock_screen_containers);
893 always_on_top_container->SetChildWindowVisibilityChangesAnimated();
894 always_on_top_container->SetSnapsChildrenToPhysicalPixelBoundary();
895 always_on_top_container->SetBoundsInScreenBehaviorForChildren(
896 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
897
898 wm::WmWindow* docked_container =
899 CreateContainer(kShellWindowId_DockedContainer, "DockedContainer",
900 non_lock_screen_containers);
901 docked_container->SetChildWindowVisibilityChangesAnimated();
902 docked_container->SetSnapsChildrenToPhysicalPixelBoundary();
903 docked_container->SetBoundsInScreenBehaviorForChildren(
904 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
905 docked_container->SetChildrenUseExtendedHitRegion();
906
907 wm::WmWindow* shelf_container =
908 CreateContainer(kShellWindowId_ShelfContainer, "ShelfContainer",
909 non_lock_screen_containers);
910 shelf_container->SetSnapsChildrenToPhysicalPixelBoundary();
911 shelf_container->SetBoundsInScreenBehaviorForChildren(
912 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
913 shelf_container->SetDescendantsStayInSameRootWindow(true);
914
915 wm::WmWindow* panel_container =
916 CreateContainer(kShellWindowId_PanelContainer, "PanelContainer",
917 non_lock_screen_containers);
918 panel_container->SetSnapsChildrenToPhysicalPixelBoundary();
919 panel_container->SetBoundsInScreenBehaviorForChildren(
920 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
921
922 wm::WmWindow* shelf_bubble_container =
923 CreateContainer(kShellWindowId_ShelfBubbleContainer,
924 "ShelfBubbleContainer", non_lock_screen_containers);
925 shelf_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
926 shelf_bubble_container->SetBoundsInScreenBehaviorForChildren(
927 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
928 shelf_bubble_container->SetDescendantsStayInSameRootWindow(true);
929
930 wm::WmWindow* app_list_container =
931 CreateContainer(kShellWindowId_AppListContainer, "AppListContainer",
932 non_lock_screen_containers);
933 app_list_container->SetSnapsChildrenToPhysicalPixelBoundary();
934 app_list_container->SetBoundsInScreenBehaviorForChildren(
935 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
936
937 wm::WmWindow* modal_container =
938 CreateContainer(kShellWindowId_SystemModalContainer,
939 "SystemModalContainer", non_lock_screen_containers);
940 modal_container->SetSnapsChildrenToPhysicalPixelBoundary();
941 modal_container->SetChildWindowVisibilityChangesAnimated();
942 modal_container->SetBoundsInScreenBehaviorForChildren(
943 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
944 modal_container->SetChildrenUseExtendedHitRegion();
945
946 // TODO(beng): Figure out if we can make this use
947 // SystemModalContainerEventFilter instead of stops_event_propagation.
948 wm::WmWindow* lock_container =
949 CreateContainer(kShellWindowId_LockScreenContainer, "LockScreenContainer",
950 lock_screen_containers);
951 lock_container->SetSnapsChildrenToPhysicalPixelBoundary();
952 lock_container->SetBoundsInScreenBehaviorForChildren(
953 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
954 // TODO(beng): stopsevents
955
956 wm::WmWindow* lock_modal_container =
957 CreateContainer(kShellWindowId_LockSystemModalContainer,
958 "LockSystemModalContainer", lock_screen_containers);
959 lock_modal_container->SetSnapsChildrenToPhysicalPixelBoundary();
960 lock_modal_container->SetChildWindowVisibilityChangesAnimated();
961 lock_modal_container->SetBoundsInScreenBehaviorForChildren(
962 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
963 lock_modal_container->SetChildrenUseExtendedHitRegion();
964
965 wm::WmWindow* status_container =
966 CreateContainer(kShellWindowId_StatusContainer, "StatusContainer",
967 lock_screen_related_containers);
968 status_container->SetSnapsChildrenToPhysicalPixelBoundary();
969 status_container->SetBoundsInScreenBehaviorForChildren(
970 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
971 status_container->SetDescendantsStayInSameRootWindow(true);
972
973 wm::WmWindow* settings_bubble_container =
974 CreateContainer(kShellWindowId_SettingBubbleContainer,
975 "SettingBubbleContainer", lock_screen_related_containers);
976 settings_bubble_container->SetChildWindowVisibilityChangesAnimated();
977 settings_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
978 settings_bubble_container->SetBoundsInScreenBehaviorForChildren(
979 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
980 settings_bubble_container->SetDescendantsStayInSameRootWindow(true);
981
982 wm::WmWindow* virtual_keyboard_parent_container = CreateContainer(
983 kShellWindowId_ImeWindowParentContainer, "VirtualKeyboardParentContainer",
984 lock_screen_related_containers);
985 virtual_keyboard_parent_container->SetSnapsChildrenToPhysicalPixelBoundary();
986 virtual_keyboard_parent_container->SetBoundsInScreenBehaviorForChildren(
987 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
988
989 wm::WmWindow* menu_container =
990 CreateContainer(kShellWindowId_MenuContainer, "MenuContainer",
991 lock_screen_related_containers);
992 menu_container->SetChildWindowVisibilityChangesAnimated();
993 menu_container->SetSnapsChildrenToPhysicalPixelBoundary();
994 menu_container->SetBoundsInScreenBehaviorForChildren(
995 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
996
997 wm::WmWindow* drag_drop_container = CreateContainer(
998 kShellWindowId_DragImageAndTooltipContainer,
999 "DragImageAndTooltipContainer", lock_screen_related_containers);
1000 drag_drop_container->SetChildWindowVisibilityChangesAnimated();
1001 drag_drop_container->SetSnapsChildrenToPhysicalPixelBoundary();
1002 drag_drop_container->SetBoundsInScreenBehaviorForChildren(
1003 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1004
1005 wm::WmWindow* overlay_container =
1006 CreateContainer(kShellWindowId_OverlayContainer, "OverlayContainer",
1007 lock_screen_related_containers);
1008 overlay_container->SetSnapsChildrenToPhysicalPixelBoundary();
1009 overlay_container->SetBoundsInScreenBehaviorForChildren(
1010 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1011
1012 #if defined(OS_CHROMEOS)
1013 wm::WmWindow* mouse_cursor_container = CreateContainer(
1014 kShellWindowId_MouseCursorContainer, "MouseCursorContainer", root_window);
1015 mouse_cursor_container->SetBoundsInScreenBehaviorForChildren(
1016 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
1017 #endif
1018
1019 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
1020 "PowerButtonAnimationContainer", root_window);
1021 }
1022
1023 void RootWindowController::EnableTouchHudProjection() { 831 void RootWindowController::EnableTouchHudProjection() {
1024 if (touch_hud_projection_) 832 if (touch_hud_projection_)
1025 return; 833 return;
1026 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); 834 set_touch_hud_projection(new TouchHudProjection(GetRootWindow()));
1027 } 835 }
1028 836
1029 void RootWindowController::DisableTouchHudProjection() { 837 void RootWindowController::DisableTouchHudProjection() {
1030 if (!touch_hud_projection_) 838 if (!touch_hud_projection_)
1031 return; 839 return;
1032 touch_hud_projection_->Remove(); 840 touch_hud_projection_->Remove();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 aura::Window* primary_root_window = Shell::GetInstance() 872 aura::Window* primary_root_window = Shell::GetInstance()
1065 ->window_tree_host_manager() 873 ->window_tree_host_manager()
1066 ->GetPrimaryRootWindow(); 874 ->GetPrimaryRootWindow();
1067 return GetRootWindowSettings(primary_root_window)->controller; 875 return GetRootWindowSettings(primary_root_window)->controller;
1068 } 876 }
1069 877
1070 return GetRootWindowSettings(root_window)->controller; 878 return GetRootWindowSettings(root_window)->controller;
1071 } 879 }
1072 880
1073 } // namespace ash 881 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/root_window_controller_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698