| OLD | NEW |
| 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/shell.h" | 5 #include "ash/shell.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/app_list/app_list.h" | 9 #include "ash/app_list/app_list.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Screen width above which we automatically start in overlapping window mode, | 72 // Screen width above which we automatically start in overlapping window mode, |
| 73 // in pixels. Should be at least 1366 pixels as we traditionally used a single | 73 // in pixels. Should be at least 1366 pixels as we traditionally used a single |
| 74 // window on Chrome OS ZGB devices with that width. | 74 // window on Chrome OS ZGB devices with that width. |
| 75 const int kOverlappingWindowModeWidthThreshold = 1366; | 75 const int kOverlappingWindowModeWidthThreshold = 1366; |
| 76 | 76 |
| 77 // Screen height above which we automatically start in overlapping window mode, | 77 // Screen height above which we automatically start in overlapping window mode, |
| 78 // in pixels. Should be at least 800 pixels as we traditionally used a single | 78 // in pixels. Should be at least 800 pixels as we traditionally used a single |
| 79 // window on Chrome OS alex devices with that height. | 79 // window on Chrome OS alex devices with that height. |
| 80 const int kOverlappingWindowModeHeightThreshold = 800; | 80 const int kOverlappingWindowModeHeightThreshold = 800; |
| 81 | 81 |
| 82 // Creates a new window for use as a container. |
| 83 aura::Window* CreateContainer(int window_id, aura::Window* parent) { |
| 84 aura::Window* container = new aura::Window(NULL); |
| 85 container->set_id(window_id); |
| 86 container->Init(ui::Layer::LAYER_NOT_DRAWN); |
| 87 parent->AddChild(container); |
| 88 if (window_id != internal::kShellWindowId_UnparentedControlContainer) |
| 89 container->Show(); |
| 90 return container; |
| 91 } |
| 92 |
| 82 // Creates each of the special window containers that holds windows of various | 93 // Creates each of the special window containers that holds windows of various |
| 83 // types in the shell UI. They are added to |containers| from back to front in | 94 // types in the shell UI. |
| 84 // the z-index. | 95 void CreateSpecialContainers(aura::Window* root_window) { |
| 85 void CreateSpecialContainers(aura::Window::Windows* containers) { | 96 // These containers are just used by PowerButtonController to animate groups |
| 86 aura::Window* unparented_control_container = new aura::Window(NULL); | 97 // of containers simultaneously without messing up the current transformations |
| 87 unparented_control_container->set_id( | 98 // on those containers. These are direct children of the root window; all of |
| 88 internal::kShellWindowId_UnparentedControlContainer); | 99 // the other containers are their children. |
| 89 containers->push_back(unparented_control_container); | 100 aura::Window* non_lock_screen_containers = CreateContainer( |
| 101 internal::kShellWindowId_NonLockScreenContainersContainer, root_window); |
| 102 aura::Window* lock_screen_containers = CreateContainer( |
| 103 internal::kShellWindowId_LockScreenContainersContainer, root_window); |
| 104 aura::Window* lock_screen_related_containers = CreateContainer( |
| 105 internal::kShellWindowId_LockScreenRelatedContainersContainer, |
| 106 root_window); |
| 90 | 107 |
| 91 aura::Window* background_container = new aura::Window(NULL); | 108 CreateContainer(internal::kShellWindowId_UnparentedControlContainer, |
| 92 background_container->set_id( | 109 non_lock_screen_containers); |
| 93 internal::kShellWindowId_DesktopBackgroundContainer); | |
| 94 containers->push_back(background_container); | |
| 95 | 110 |
| 96 aura::Window* default_container = new aura::Window(NULL); | 111 CreateContainer(internal::kShellWindowId_DesktopBackgroundContainer, |
| 112 non_lock_screen_containers); |
| 113 |
| 114 aura::Window* default_container = CreateContainer( |
| 115 internal::kShellWindowId_DefaultContainer, non_lock_screen_containers); |
| 97 default_container->SetEventFilter( | 116 default_container->SetEventFilter( |
| 98 new ToplevelWindowEventFilter(default_container)); | 117 new ToplevelWindowEventFilter(default_container)); |
| 99 default_container->set_id(internal::kShellWindowId_DefaultContainer); | |
| 100 SetChildWindowVisibilityChangesAnimated(default_container); | 118 SetChildWindowVisibilityChangesAnimated(default_container); |
| 101 containers->push_back(default_container); | |
| 102 | 119 |
| 103 aura::Window* always_on_top_container = new aura::Window(NULL); | 120 aura::Window* always_on_top_container = CreateContainer( |
| 121 internal::kShellWindowId_AlwaysOnTopContainer, |
| 122 non_lock_screen_containers); |
| 104 always_on_top_container->SetEventFilter( | 123 always_on_top_container->SetEventFilter( |
| 105 new ToplevelWindowEventFilter(always_on_top_container)); | 124 new ToplevelWindowEventFilter(always_on_top_container)); |
| 106 always_on_top_container->set_id( | |
| 107 internal::kShellWindowId_AlwaysOnTopContainer); | |
| 108 SetChildWindowVisibilityChangesAnimated(always_on_top_container); | 125 SetChildWindowVisibilityChangesAnimated(always_on_top_container); |
| 109 containers->push_back(always_on_top_container); | |
| 110 | 126 |
| 111 aura::Window* panel_container = new aura::Window(NULL); | 127 aura::Window* panel_container = CreateContainer( |
| 112 panel_container->set_id(internal::kShellWindowId_PanelContainer); | 128 internal::kShellWindowId_PanelContainer, non_lock_screen_containers); |
| 113 if (CommandLine::ForCurrentProcess()-> | 129 if (CommandLine::ForCurrentProcess()-> |
| 114 HasSwitch(switches::kAuraPanelManager)) { | 130 HasSwitch(switches::kAuraPanelManager)) { |
| 115 internal::PanelLayoutManager* layout_manager = | 131 internal::PanelLayoutManager* layout_manager = |
| 116 new internal::PanelLayoutManager(panel_container); | 132 new internal::PanelLayoutManager(panel_container); |
| 117 panel_container->SetEventFilter( | 133 panel_container->SetEventFilter( |
| 118 new internal::PanelWindowEventFilter(panel_container, layout_manager)); | 134 new internal::PanelWindowEventFilter(panel_container, layout_manager)); |
| 119 panel_container->SetLayoutManager(layout_manager); | 135 panel_container->SetLayoutManager(layout_manager); |
| 120 } | 136 } |
| 121 containers->push_back(panel_container); | |
| 122 | 137 |
| 123 aura::Window* launcher_container = new aura::Window(NULL); | 138 CreateContainer(internal::kShellWindowId_LauncherContainer, |
| 124 launcher_container->set_id(internal::kShellWindowId_LauncherContainer); | 139 non_lock_screen_containers); |
| 125 containers->push_back(launcher_container); | |
| 126 | 140 |
| 127 aura::Window* modal_container = new aura::Window(NULL); | 141 aura::Window* modal_container = CreateContainer( |
| 142 internal::kShellWindowId_SystemModalContainer, |
| 143 non_lock_screen_containers); |
| 128 modal_container->SetEventFilter( | 144 modal_container->SetEventFilter( |
| 129 new ToplevelWindowEventFilter(modal_container)); | 145 new ToplevelWindowEventFilter(modal_container)); |
| 130 modal_container->SetLayoutManager( | 146 modal_container->SetLayoutManager( |
| 131 new internal::SystemModalContainerLayoutManager(modal_container)); | 147 new internal::SystemModalContainerLayoutManager(modal_container)); |
| 132 modal_container->set_id(internal::kShellWindowId_SystemModalContainer); | |
| 133 SetChildWindowVisibilityChangesAnimated(modal_container); | 148 SetChildWindowVisibilityChangesAnimated(modal_container); |
| 134 containers->push_back(modal_container); | |
| 135 | 149 |
| 136 // TODO(beng): Figure out if we can make this use | 150 // TODO(beng): Figure out if we can make this use |
| 137 // SystemModalContainerEventFilter instead of stops_event_propagation. | 151 // SystemModalContainerEventFilter instead of stops_event_propagation. |
| 138 aura::Window* lock_container = new aura::Window(NULL); | 152 aura::Window* lock_container = CreateContainer( |
| 153 internal::kShellWindowId_LockScreenContainer, lock_screen_containers); |
| 139 lock_container->SetLayoutManager(new internal::BaseLayoutManager); | 154 lock_container->SetLayoutManager(new internal::BaseLayoutManager); |
| 140 lock_container->set_stops_event_propagation(true); | 155 lock_container->set_stops_event_propagation(true); |
| 141 lock_container->set_id(internal::kShellWindowId_LockScreenContainer); | |
| 142 containers->push_back(lock_container); | |
| 143 | 156 |
| 144 aura::Window* lock_modal_container = new aura::Window(NULL); | 157 aura::Window* lock_modal_container = CreateContainer( |
| 158 internal::kShellWindowId_LockSystemModalContainer, |
| 159 lock_screen_containers); |
| 145 lock_modal_container->SetEventFilter( | 160 lock_modal_container->SetEventFilter( |
| 146 new ToplevelWindowEventFilter(lock_modal_container)); | 161 new ToplevelWindowEventFilter(lock_modal_container)); |
| 147 lock_modal_container->SetLayoutManager( | 162 lock_modal_container->SetLayoutManager( |
| 148 new internal::SystemModalContainerLayoutManager(lock_modal_container)); | 163 new internal::SystemModalContainerLayoutManager(lock_modal_container)); |
| 149 lock_modal_container->set_id( | |
| 150 internal::kShellWindowId_LockSystemModalContainer); | |
| 151 SetChildWindowVisibilityChangesAnimated(lock_modal_container); | 164 SetChildWindowVisibilityChangesAnimated(lock_modal_container); |
| 152 containers->push_back(lock_modal_container); | |
| 153 | 165 |
| 154 aura::Window* status_container = new aura::Window(NULL); | 166 CreateContainer(internal::kShellWindowId_StatusContainer, |
| 155 status_container->set_id(internal::kShellWindowId_StatusContainer); | 167 lock_screen_related_containers); |
| 156 containers->push_back(status_container); | |
| 157 | 168 |
| 158 aura::Window* menu_container = new aura::Window(NULL); | 169 aura::Window* menu_container = CreateContainer( |
| 159 menu_container->set_id(internal::kShellWindowId_MenuContainer); | 170 internal::kShellWindowId_MenuContainer, lock_screen_related_containers); |
| 160 SetChildWindowVisibilityChangesAnimated(menu_container); | 171 SetChildWindowVisibilityChangesAnimated(menu_container); |
| 161 containers->push_back(menu_container); | |
| 162 | 172 |
| 163 aura::Window* drag_drop_container = new aura::Window(NULL); | 173 aura::Window* drag_drop_container = CreateContainer( |
| 164 drag_drop_container->set_id( | 174 internal::kShellWindowId_DragImageAndTooltipContainer, |
| 165 internal::kShellWindowId_DragImageAndTooltipContainer); | 175 lock_screen_related_containers); |
| 166 SetChildWindowVisibilityChangesAnimated(drag_drop_container); | 176 SetChildWindowVisibilityChangesAnimated(drag_drop_container); |
| 167 containers->push_back(drag_drop_container); | |
| 168 | 177 |
| 169 aura::Window* setting_bubble_container = new aura::Window(NULL); | 178 CreateContainer(internal::kShellWindowId_SettingBubbleContainer, |
| 170 setting_bubble_container->set_id( | 179 lock_screen_related_containers); |
| 171 internal::kShellWindowId_SettingBubbleContainer); | |
| 172 containers->push_back(setting_bubble_container); | |
| 173 | 180 |
| 174 aura::Window* overlay_container = new aura::Window(NULL); | 181 CreateContainer(internal::kShellWindowId_OverlayContainer, |
| 175 overlay_container->set_id(internal::kShellWindowId_OverlayContainer); | 182 lock_screen_related_containers); |
| 176 containers->push_back(overlay_container); | |
| 177 } | 183 } |
| 178 | 184 |
| 179 // Maximizes all the windows in a |container|. | 185 // Maximizes all the windows in a |container|. |
| 180 void MaximizeWindows(aura::Window* container) { | 186 void MaximizeWindows(aura::Window* container) { |
| 181 const std::vector<aura::Window*>& windows = container->children(); | 187 const std::vector<aura::Window*>& windows = container->children(); |
| 182 for (std::vector<aura::Window*>::const_iterator it = windows.begin(); | 188 for (std::vector<aura::Window*>::const_iterator it = windows.begin(); |
| 183 it != windows.end(); | 189 it != windows.end(); |
| 184 ++it) | 190 ++it) |
| 185 window_util::MaximizeWindow(*it); | 191 window_util::MaximizeWindow(*it); |
| 186 } | 192 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 323 |
| 318 // Window mode must be set before computing containers or layout managers. | 324 // Window mode must be set before computing containers or layout managers. |
| 319 gfx::Size monitor_size = gfx::Screen::GetPrimaryMonitorSize(); | 325 gfx::Size monitor_size = gfx::Screen::GetPrimaryMonitorSize(); |
| 320 window_mode_ = ComputeWindowMode(monitor_size, command_line); | 326 window_mode_ = ComputeWindowMode(monitor_size, command_line); |
| 321 | 327 |
| 322 aura::RootWindow* root_window = GetRootWindow(); | 328 aura::RootWindow* root_window = GetRootWindow(); |
| 323 root_window->SetCursor(aura::kCursorPointer); | 329 root_window->SetCursor(aura::kCursorPointer); |
| 324 | 330 |
| 325 activation_controller_.reset(new internal::ActivationController); | 331 activation_controller_.reset(new internal::ActivationController); |
| 326 | 332 |
| 327 aura::Window::Windows containers; | 333 CreateSpecialContainers(root_window); |
| 328 CreateSpecialContainers(&containers); | |
| 329 aura::Window::Windows::const_iterator i; | |
| 330 for (i = containers.begin(); i != containers.end(); ++i) { | |
| 331 (*i)->Init(ui::Layer::LAYER_NOT_DRAWN); | |
| 332 root_window->AddChild(*i); | |
| 333 if ((*i)->id() != internal::kShellWindowId_UnparentedControlContainer) | |
| 334 (*i)->Show(); | |
| 335 } | |
| 336 | 334 |
| 337 stacking_controller_.reset(new internal::StackingController); | 335 stacking_controller_.reset(new internal::StackingController); |
| 338 | 336 |
| 339 root_window_layout_ = new internal::RootWindowLayoutManager(root_window); | 337 root_window_layout_ = new internal::RootWindowLayoutManager(root_window); |
| 340 root_window->SetLayoutManager(root_window_layout_); | 338 root_window->SetLayoutManager(root_window_layout_); |
| 341 | 339 |
| 342 if (delegate_.get()) | 340 if (delegate_.get()) |
| 343 status_widget_ = delegate_->CreateStatusArea(); | 341 status_widget_ = delegate_->CreateStatusArea(); |
| 344 if (!status_widget_) | 342 if (!status_widget_) |
| 345 status_widget_ = internal::CreateStatusArea(); | 343 status_widget_ = internal::CreateStatusArea(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 | 616 |
| 619 // Create the desktop background image. | 617 // Create the desktop background image. |
| 620 SetDesktopBackgroundMode(BACKGROUND_IMAGE); | 618 SetDesktopBackgroundMode(BACKGROUND_IMAGE); |
| 621 } | 619 } |
| 622 | 620 |
| 623 void Shell::ResetLayoutManager(int container_id) { | 621 void Shell::ResetLayoutManager(int container_id) { |
| 624 GetContainer(container_id)->SetLayoutManager(NULL); | 622 GetContainer(container_id)->SetLayoutManager(NULL); |
| 625 } | 623 } |
| 626 | 624 |
| 627 } // namespace ash | 625 } // namespace ash |
| OLD | NEW |