| 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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/desktop_background/desktop_background_widget_controller.h" | 11 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| 12 #include "ash/display/display_controller.h" | 12 #include "ash/display/display_controller.h" |
| 13 #include "ash/display/display_manager.h" | 13 #include "ash/display/display_manager.h" |
| 14 #include "ash/focus_cycler.h" | 14 #include "ash/focus_cycler.h" |
| 15 #include "ash/session_state_delegate.h" | 15 #include "ash/session_state_delegate.h" |
| 16 #include "ash/shelf/shelf_layout_manager.h" | 16 #include "ash/shelf/shelf_layout_manager.h" |
| 17 #include "ash/shelf/shelf_types.h" | 17 #include "ash/shelf/shelf_types.h" |
| 18 #include "ash/shelf/shelf_widget.h" | 18 #include "ash/shelf/shelf_widget.h" |
| 19 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 20 #include "ash/shell_delegate.h" | 20 #include "ash/shell_delegate.h" |
| 21 #include "ash/shell_factory.h" | 21 #include "ash/shell_factory.h" |
| 22 #include "ash/shell_window_ids.h" | 22 #include "ash/shell_window_ids.h" |
| 23 #include "ash/system/status_area_widget.h" | 23 #include "ash/system/status_area_widget.h" |
| 24 #include "ash/system/tray/system_tray_delegate.h" | 24 #include "ash/system/tray/system_tray_delegate.h" |
| 25 #include "ash/touch/touch_observer_hud.h" | 25 #include "ash/touch/touch_observer_hud.h" |
| 26 #include "ash/wm/base_layout_manager.h" | 26 #include "ash/wm/base_layout_manager.h" |
| 27 #include "ash/wm/boot_splash_screen.h" | 27 #include "ash/wm/boot_splash_screen.h" |
| 28 #include "ash/wm/dock/dock_layout_manager.h" |
| 28 #include "ash/wm/panels/panel_layout_manager.h" | 29 #include "ash/wm/panels/panel_layout_manager.h" |
| 29 #include "ash/wm/property_util.h" | 30 #include "ash/wm/property_util.h" |
| 30 #include "ash/wm/root_window_layout_manager.h" | 31 #include "ash/wm/root_window_layout_manager.h" |
| 31 #include "ash/wm/screen_dimmer.h" | 32 #include "ash/wm/screen_dimmer.h" |
| 32 #include "ash/wm/stacking_controller.h" | 33 #include "ash/wm/stacking_controller.h" |
| 33 #include "ash/wm/status_area_layout_manager.h" | 34 #include "ash/wm/status_area_layout_manager.h" |
| 34 #include "ash/wm/system_background_controller.h" | 35 #include "ash/wm/system_background_controller.h" |
| 35 #include "ash/wm/system_modal_container_layout_manager.h" | 36 #include "ash/wm/system_modal_container_layout_manager.h" |
| 36 #include "ash/wm/toplevel_window_event_handler.h" | 37 #include "ash/wm/toplevel_window_event_handler.h" |
| 37 #include "ash/wm/window_properties.h" | 38 #include "ash/wm/window_properties.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 new_parent->AddChild(window); | 105 new_parent->AddChild(window); |
| 105 if (!restore_bounds.IsEmpty()) | 106 if (!restore_bounds.IsEmpty()) |
| 106 SetRestoreBoundsInParent(window, restore_bounds); | 107 SetRestoreBoundsInParent(window, restore_bounds); |
| 107 } | 108 } |
| 108 | 109 |
| 109 // Reparents the appropriate set of windows from |src| to |dst|. | 110 // Reparents the appropriate set of windows from |src| to |dst|. |
| 110 void ReparentAllWindows(aura::RootWindow* src, aura::RootWindow* dst) { | 111 void ReparentAllWindows(aura::RootWindow* src, aura::RootWindow* dst) { |
| 111 // Set of windows to move. | 112 // Set of windows to move. |
| 112 const int kContainerIdsToMove[] = { | 113 const int kContainerIdsToMove[] = { |
| 113 internal::kShellWindowId_DefaultContainer, | 114 internal::kShellWindowId_DefaultContainer, |
| 115 internal::kShellWindowId_DockContainer, |
| 114 internal::kShellWindowId_PanelContainer, | 116 internal::kShellWindowId_PanelContainer, |
| 115 internal::kShellWindowId_AlwaysOnTopContainer, | 117 internal::kShellWindowId_AlwaysOnTopContainer, |
| 116 internal::kShellWindowId_SystemModalContainer, | 118 internal::kShellWindowId_SystemModalContainer, |
| 117 internal::kShellWindowId_LockSystemModalContainer, | 119 internal::kShellWindowId_LockSystemModalContainer, |
| 118 internal::kShellWindowId_InputMethodContainer, | 120 internal::kShellWindowId_InputMethodContainer, |
| 119 internal::kShellWindowId_UnparentedControlContainer, | 121 internal::kShellWindowId_UnparentedControlContainer, |
| 120 }; | 122 }; |
| 121 // For workspace windows we need to manually reparent the windows. This way | 123 // For workspace windows we need to manually reparent the windows. This way |
| 122 // workspace can move the windows to the appropriate workspace. | 124 // workspace can move the windows to the appropriate workspace. |
| 123 std::vector<aura::Window*> windows(GetWorkspaceWindows(src)); | 125 std::vector<aura::Window*> windows(GetWorkspaceWindows(src)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace | 164 } // namespace |
| 163 | 165 |
| 164 namespace internal { | 166 namespace internal { |
| 165 | 167 |
| 166 RootWindowController::RootWindowController(aura::RootWindow* root_window) | 168 RootWindowController::RootWindowController(aura::RootWindow* root_window) |
| 167 : root_window_(root_window), | 169 : root_window_(root_window), |
| 168 root_window_layout_(NULL), | 170 root_window_layout_(NULL), |
| 169 shelf_(NULL), | 171 shelf_(NULL), |
| 172 dock_layout_manager_(NULL), |
| 170 panel_layout_manager_(NULL), | 173 panel_layout_manager_(NULL), |
| 171 touch_observer_hud_(NULL) { | 174 touch_observer_hud_(NULL) { |
| 172 SetRootWindowController(root_window, this); | 175 SetRootWindowController(root_window, this); |
| 173 screen_dimmer_.reset(new ScreenDimmer(root_window)); | 176 screen_dimmer_.reset(new ScreenDimmer(root_window)); |
| 174 | 177 |
| 175 stacking_controller_.reset(new ash::StackingController); | 178 stacking_controller_.reset(new ash::StackingController); |
| 176 aura::client::SetStackingClient(root_window, stacking_controller_.get()); | 179 aura::client::SetStackingClient(root_window, stacking_controller_.get()); |
| 177 } | 180 } |
| 178 | 181 |
| 179 RootWindowController::~RootWindowController() { | 182 RootWindowController::~RootWindowController() { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 void RootWindowController::InitForPrimaryDisplay() { | 268 void RootWindowController::InitForPrimaryDisplay() { |
| 266 DCHECK(!shelf_.get()); | 269 DCHECK(!shelf_.get()); |
| 267 aura::Window* shelf_container = | 270 aura::Window* shelf_container = |
| 268 GetContainer(ash::internal::kShellWindowId_ShelfContainer); | 271 GetContainer(ash::internal::kShellWindowId_ShelfContainer); |
| 269 // TODO(harrym): Remove when status area is view. | 272 // TODO(harrym): Remove when status area is view. |
| 270 aura::Window* status_container = | 273 aura::Window* status_container = |
| 271 GetContainer(ash::internal::kShellWindowId_StatusContainer); | 274 GetContainer(ash::internal::kShellWindowId_StatusContainer); |
| 272 shelf_.reset(new ash::ShelfWidget( | 275 shelf_.reset(new ash::ShelfWidget( |
| 273 shelf_container, status_container, workspace_controller())); | 276 shelf_container, status_container, workspace_controller())); |
| 274 | 277 |
| 278 // Create Dock layout manager |
| 279 aura::Window* dock_container = GetContainer( |
| 280 internal::kShellWindowId_DockContainer); |
| 281 dock_layout_manager_ = |
| 282 new internal::DockLayoutManager(dock_container); |
| 283 dock_container_handler_.reset( |
| 284 new ToplevelWindowEventHandler(dock_container)); |
| 285 dock_container->SetLayoutManager(dock_layout_manager_); |
| 286 dock_layout_manager_->AddObserver(shelf()->shelf_layout_manager()); |
| 287 |
| 275 // Create Panel layout manager | 288 // Create Panel layout manager |
| 276 aura::Window* panel_container = GetContainer( | 289 aura::Window* panel_container = GetContainer( |
| 277 internal::kShellWindowId_PanelContainer); | 290 internal::kShellWindowId_PanelContainer); |
| 278 panel_layout_manager_ = | 291 panel_layout_manager_ = |
| 279 new internal::PanelLayoutManager(panel_container); | 292 new internal::PanelLayoutManager(panel_container); |
| 280 panel_container_handler_.reset( | 293 panel_container_handler_.reset( |
| 281 new ToplevelWindowEventHandler(panel_container)); | 294 new ToplevelWindowEventHandler(panel_container)); |
| 282 panel_container->SetLayoutManager(panel_layout_manager_); | 295 panel_container->SetLayoutManager(panel_layout_manager_); |
| 283 | 296 |
| 284 if (Shell::GetInstance()->session_state_delegate()->NumberOfLoggedInUsers()) | 297 if (Shell::GetInstance()->session_state_delegate()->NumberOfLoggedInUsers()) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 315 switches::kAshCopyHostBackgroundAtBoot) || | 328 switches::kAshCopyHostBackgroundAtBoot) || |
| 316 CommandLine::ForCurrentProcess()->HasSwitch( | 329 CommandLine::ForCurrentProcess()->HasSwitch( |
| 317 switches::kAshAnimateFromBootSplashScreen))) | 330 switches::kAshAnimateFromBootSplashScreen))) |
| 318 boot_splash_screen_.reset(new BootSplashScreen(root_window_.get())); | 331 boot_splash_screen_.reset(new BootSplashScreen(root_window_.get())); |
| 319 #endif | 332 #endif |
| 320 } | 333 } |
| 321 | 334 |
| 322 void RootWindowController::OnLauncherCreated() { | 335 void RootWindowController::OnLauncherCreated() { |
| 323 if (panel_layout_manager_) | 336 if (panel_layout_manager_) |
| 324 panel_layout_manager_->SetLauncher(shelf_->launcher()); | 337 panel_layout_manager_->SetLauncher(shelf_->launcher()); |
| 338 if (dock_layout_manager_) |
| 339 dock_layout_manager_->SetLauncher(shelf_->launcher()); |
| 325 } | 340 } |
| 326 | 341 |
| 327 void RootWindowController::ShowLauncher() { | 342 void RootWindowController::ShowLauncher() { |
| 328 if (!shelf_.get() || !shelf_->launcher()) | 343 if (!shelf_.get() || !shelf_->launcher()) |
| 329 return; | 344 return; |
| 330 shelf_->launcher()->SetVisible(true); | 345 shelf_->launcher()->SetVisible(true); |
| 331 shelf_->status_area_widget()->Show(); | 346 shelf_->status_area_widget()->Show(); |
| 332 } | 347 } |
| 333 | 348 |
| 334 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { | 349 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 359 system_background_->SetColor(SK_ColorBLACK); | 374 system_background_->SetColor(SK_ColorBLACK); |
| 360 boot_splash_screen_.reset(); | 375 boot_splash_screen_.reset(); |
| 361 } | 376 } |
| 362 | 377 |
| 363 void RootWindowController::CloseChildWindows() { | 378 void RootWindowController::CloseChildWindows() { |
| 364 // panel_layout_manager_ needs to be shut down before windows are destroyed. | 379 // panel_layout_manager_ needs to be shut down before windows are destroyed. |
| 365 if (panel_layout_manager_) { | 380 if (panel_layout_manager_) { |
| 366 panel_layout_manager_->Shutdown(); | 381 panel_layout_manager_->Shutdown(); |
| 367 panel_layout_manager_ = NULL; | 382 panel_layout_manager_ = NULL; |
| 368 } | 383 } |
| 384 if (dock_layout_manager_) { |
| 385 dock_layout_manager_->Shutdown(); |
| 386 dock_layout_manager_ = NULL; |
| 387 } |
| 369 | 388 |
| 370 // TODO(harrym): Remove when Status Area Widget is a child view. | 389 // TODO(harrym): Remove when Status Area Widget is a child view. |
| 371 if (shelf_) | 390 if (shelf_) |
| 372 shelf_->ShutdownStatusAreaWidget(); | 391 shelf_->ShutdownStatusAreaWidget(); |
| 373 | 392 |
| 374 if (shelf_.get() && shelf_->shelf_layout_manager()) | 393 if (shelf_.get() && shelf_->shelf_layout_manager()) |
| 375 shelf_->shelf_layout_manager()->set_workspace_controller(NULL); | 394 shelf_->shelf_layout_manager()->set_workspace_controller(NULL); |
| 376 | 395 |
| 377 // Close background widget first as it depends on tooltip. | 396 // Close background widget first as it depends on tooltip. |
| 378 root_window_->SetProperty(kDesktopController, | 397 root_window_->SetProperty(kDesktopController, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 aura::Window* always_on_top_container = CreateContainer( | 545 aura::Window* always_on_top_container = CreateContainer( |
| 527 kShellWindowId_AlwaysOnTopContainer, | 546 kShellWindowId_AlwaysOnTopContainer, |
| 528 "AlwaysOnTopContainer", | 547 "AlwaysOnTopContainer", |
| 529 non_lock_screen_containers); | 548 non_lock_screen_containers); |
| 530 always_on_top_container_handler_.reset( | 549 always_on_top_container_handler_.reset( |
| 531 new ToplevelWindowEventHandler(always_on_top_container)); | 550 new ToplevelWindowEventHandler(always_on_top_container)); |
| 532 views::corewm::SetChildWindowVisibilityChangesAnimated( | 551 views::corewm::SetChildWindowVisibilityChangesAnimated( |
| 533 always_on_top_container); | 552 always_on_top_container); |
| 534 SetUsesScreenCoordinates(always_on_top_container); | 553 SetUsesScreenCoordinates(always_on_top_container); |
| 535 | 554 |
| 555 aura::Window* dock_container = CreateContainer( |
| 556 kShellWindowId_DockContainer, |
| 557 "DockContainer", |
| 558 non_lock_screen_containers); |
| 559 SetUsesScreenCoordinates(dock_container); |
| 560 |
| 536 aura::Window* panel_container = CreateContainer( | 561 aura::Window* panel_container = CreateContainer( |
| 537 kShellWindowId_PanelContainer, | 562 kShellWindowId_PanelContainer, |
| 538 "PanelContainer", | 563 "PanelContainer", |
| 539 non_lock_screen_containers); | 564 non_lock_screen_containers); |
| 540 SetUsesScreenCoordinates(panel_container); | 565 SetUsesScreenCoordinates(panel_container); |
| 541 | 566 |
| 542 aura::Window* launcher_container = | 567 aura::Window* launcher_container = |
| 543 CreateContainer(kShellWindowId_ShelfContainer, | 568 CreateContainer(kShellWindowId_ShelfContainer, |
| 544 "LauncherContainer", | 569 "LauncherContainer", |
| 545 non_lock_screen_containers); | 570 non_lock_screen_containers); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 "OverlayContainer", | 648 "OverlayContainer", |
| 624 lock_screen_related_containers); | 649 lock_screen_related_containers); |
| 625 SetUsesScreenCoordinates(overlay_container); | 650 SetUsesScreenCoordinates(overlay_container); |
| 626 | 651 |
| 627 CreateContainer(kShellWindowId_PowerButtonAnimationContainer, | 652 CreateContainer(kShellWindowId_PowerButtonAnimationContainer, |
| 628 "PowerButtonAnimationContainer", root_window) ; | 653 "PowerButtonAnimationContainer", root_window) ; |
| 629 } | 654 } |
| 630 | 655 |
| 631 } // namespace internal | 656 } // namespace internal |
| 632 } // namespace ash | 657 } // namespace ash |
| OLD | NEW |