| 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" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // static | 199 // static |
| 200 RootWindowController* RootWindowController::ForActiveRootWindow() { | 200 RootWindowController* RootWindowController::ForActiveRootWindow() { |
| 201 return GetRootWindowController(Shell::GetActiveRootWindow()); | 201 return GetRootWindowController(Shell::GetActiveRootWindow()); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void RootWindowController::Shutdown() { | 204 void RootWindowController::Shutdown() { |
| 205 // Remove touch observer HUD. | 205 // Remove touch observer HUD. |
| 206 SetTouchObserverHUD(NULL); | 206 SetTouchObserverHUD(NULL); |
| 207 | 207 |
| 208 CloseChildWindows(); | 208 CloseChildWindows(); |
| 209 if (Shell::GetActiveRootWindow() == root_window_.get()) { | 209 if (Shell::GetActiveRootWindow() == root_window_) { |
| 210 Shell::GetInstance()->set_active_root_window( | 210 Shell::GetInstance()->set_active_root_window( |
| 211 Shell::GetPrimaryRootWindow() == root_window_.get() ? | 211 Shell::GetPrimaryRootWindow() == root_window_.get() ? |
| 212 NULL : Shell::GetPrimaryRootWindow()); | 212 NULL : Shell::GetPrimaryRootWindow()); |
| 213 } | 213 } |
| 214 SetRootWindowController(root_window_.get(), NULL); | 214 SetRootWindowController(root_window_.get(), NULL); |
| 215 screen_dimmer_.reset(); | 215 screen_dimmer_.reset(); |
| 216 workspace_controller_.reset(); | 216 workspace_controller_.reset(); |
| 217 // Forget with the display ID so that display lookup | 217 // Forget with the display ID so that display lookup |
| 218 // ends up with invalid display. | 218 // ends up with invalid display. |
| 219 root_window_->ClearProperty(kDisplayIdKey); | 219 root_window_->ClearProperty(kDisplayIdKey); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 void RootWindowController::ShowLauncher() { | 340 void RootWindowController::ShowLauncher() { |
| 341 if (!shelf_.get() || !shelf_->launcher()) | 341 if (!shelf_.get() || !shelf_->launcher()) |
| 342 return; | 342 return; |
| 343 shelf_->launcher()->SetVisible(true); | 343 shelf_->launcher()->SetVisible(true); |
| 344 shelf_->status_area_widget()->Show(); | 344 shelf_->status_area_widget()->Show(); |
| 345 } | 345 } |
| 346 | 346 |
| 347 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { | 347 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { |
| 348 // TODO(oshima): remove if when launcher per display is enabled by | 348 // TODO(oshima): remove if when launcher per display is enabled by |
| 349 // default. | 349 // default. |
| 350 if (shelf_.get()) | 350 if (shelf_) |
| 351 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 351 shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| 352 } | 352 } |
| 353 | 353 |
| 354 void RootWindowController::UpdateAfterLoginStatusChange( | 354 void RootWindowController::UpdateAfterLoginStatusChange( |
| 355 user::LoginStatus status) { | 355 user::LoginStatus status) { |
| 356 if (shelf_.get() && shelf_->status_area_widget()) | 356 if (shelf_.get() && shelf_->status_area_widget()) |
| 357 shelf_->status_area_widget()->UpdateAfterLoginStatusChange(status); | 357 shelf_->status_area_widget()->UpdateAfterLoginStatusChange(status); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() { | 360 void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 374 } | 374 } |
| 375 | 375 |
| 376 void RootWindowController::CloseChildWindows() { | 376 void RootWindowController::CloseChildWindows() { |
| 377 // panel_layout_manager_ needs to be shut down before windows are destroyed. | 377 // panel_layout_manager_ needs to be shut down before windows are destroyed. |
| 378 if (panel_layout_manager_) { | 378 if (panel_layout_manager_) { |
| 379 panel_layout_manager_->Shutdown(); | 379 panel_layout_manager_->Shutdown(); |
| 380 panel_layout_manager_ = NULL; | 380 panel_layout_manager_ = NULL; |
| 381 } | 381 } |
| 382 | 382 |
| 383 // TODO(harrym): Remove when Status Area Widget is a child view. | 383 // TODO(harrym): Remove when Status Area Widget is a child view. |
| 384 if (shelf_.get()) | 384 if (shelf_) |
| 385 shelf_->ShutdownStatusAreaWidget(); | 385 shelf_->ShutdownStatusAreaWidget(); |
| 386 | 386 |
| 387 if (shelf_.get() && shelf_->shelf_layout_manager()) | 387 if (shelf_.get() && shelf_->shelf_layout_manager()) |
| 388 shelf_->shelf_layout_manager()->set_workspace_controller(NULL); | 388 shelf_->shelf_layout_manager()->set_workspace_controller(NULL); |
| 389 | 389 |
| 390 // Close background widget first as it depends on tooltip. | 390 // Close background widget first as it depends on tooltip. |
| 391 root_window_->SetProperty(kDesktopController, | 391 root_window_->SetProperty(kDesktopController, |
| 392 static_cast<DesktopBackgroundWidgetController*>(NULL)); | 392 static_cast<DesktopBackgroundWidgetController*>(NULL)); |
| 393 root_window_->SetProperty(kAnimatingDesktopController, | 393 root_window_->SetProperty(kAnimatingDesktopController, |
| 394 static_cast<AnimatingDesktopController*>(NULL)); | 394 static_cast<AnimatingDesktopController*>(NULL)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 433 |
| 434 // Restore focused or active window if it's still alive. | 434 // Restore focused or active window if it's still alive. |
| 435 if (focused && tracker.Contains(focused) && dst->Contains(focused)) { | 435 if (focused && tracker.Contains(focused) && dst->Contains(focused)) { |
| 436 aura::client::GetFocusClient(dst)->FocusWindow(focused); | 436 aura::client::GetFocusClient(dst)->FocusWindow(focused); |
| 437 } else if (active && tracker.Contains(active) && dst->Contains(active)) { | 437 } else if (active && tracker.Contains(active) && dst->Contains(active)) { |
| 438 activation_client->ActivateWindow(active); | 438 activation_client->ActivateWindow(active); |
| 439 } | 439 } |
| 440 } | 440 } |
| 441 | 441 |
| 442 void RootWindowController::SetTouchObserverHUD(TouchObserverHUD* hud) { | 442 void RootWindowController::SetTouchObserverHUD(TouchObserverHUD* hud) { |
| 443 if (touch_observer_hud_.get()) | 443 if (touch_observer_hud_) |
| 444 root_window_->RemovePreTargetHandler(touch_observer_hud_.get()); | 444 root_window_->RemovePreTargetHandler(touch_observer_hud_.get()); |
| 445 if (hud) | 445 if (hud) |
| 446 root_window_->AddPreTargetHandler(hud); | 446 root_window_->AddPreTargetHandler(hud); |
| 447 touch_observer_hud_.reset(hud); | 447 touch_observer_hud_.reset(hud); |
| 448 } | 448 } |
| 449 | 449 |
| 450 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 450 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
| 451 return shelf_.get() ? shelf_->shelf_layout_manager() : NULL; | 451 return shelf_.get() ? shelf_->shelf_layout_manager() : NULL; |
| 452 } | 452 } |
| 453 | 453 |
| 454 SystemTray* RootWindowController::GetSystemTray() { | 454 SystemTray* RootWindowController::GetSystemTray() { |
| 455 // We assume in throughout the code that this will not return NULL. If code | 455 // We assume in throughout the code that this will not return NULL. If code |
| 456 // triggers this for valid reasons, it should test status_area_widget first. | 456 // triggers this for valid reasons, it should test status_area_widget first. |
| 457 CHECK(shelf_.get() && shelf_->status_area_widget()); | 457 CHECK(shelf_.get() && shelf_->status_area_widget()); |
| 458 return shelf_->status_area_widget()->system_tray(); | 458 return shelf_->status_area_widget()->system_tray(); |
| 459 } | 459 } |
| 460 | 460 |
| 461 void RootWindowController::ShowContextMenu( | 461 void RootWindowController::ShowContextMenu( |
| 462 const gfx::Point& location_in_screen) { | 462 const gfx::Point& location_in_screen) { |
| 463 aura::RootWindow* target = Shell::IsLauncherPerDisplayEnabled() ? | 463 aura::RootWindow* target = Shell::IsLauncherPerDisplayEnabled() ? |
| 464 root_window() : Shell::GetPrimaryRootWindow(); | 464 root_window() : Shell::GetPrimaryRootWindow(); |
| 465 DCHECK(Shell::GetInstance()->delegate()); | 465 DCHECK(Shell::GetInstance()->delegate()); |
| 466 scoped_ptr<ui::MenuModel> menu_model( | 466 scoped_ptr<ui::MenuModel> menu_model( |
| 467 Shell::GetInstance()->delegate()->CreateContextMenu(target)); | 467 Shell::GetInstance()->delegate()->CreateContextMenu(target)); |
| 468 if (!menu_model.get()) | 468 if (!menu_model) |
| 469 return; | 469 return; |
| 470 | 470 |
| 471 internal::DesktopBackgroundWidgetController* background = | 471 internal::DesktopBackgroundWidgetController* background = |
| 472 root_window_->GetProperty(kDesktopController); | 472 root_window_->GetProperty(kDesktopController); |
| 473 // Background controller may not be set yet if user clicked on status are | 473 // Background controller may not be set yet if user clicked on status are |
| 474 // before initial animation completion. See crbug.com/222218 | 474 // before initial animation completion. See crbug.com/222218 |
| 475 if (!background) | 475 if (!background) |
| 476 return; | 476 return; |
| 477 | 477 |
| 478 views::MenuRunner menu_runner(menu_model.get()); | 478 views::MenuRunner menu_runner(menu_model.get()); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 "OverlayContainer", | 669 "OverlayContainer", |
| 670 lock_screen_related_containers); | 670 lock_screen_related_containers); |
| 671 SetUsesScreenCoordinates(overlay_container); | 671 SetUsesScreenCoordinates(overlay_container); |
| 672 | 672 |
| 673 CreateContainer(kShellWindowId_PowerButtonAnimationContainer, | 673 CreateContainer(kShellWindowId_PowerButtonAnimationContainer, |
| 674 "PowerButtonAnimationContainer", root_window) ; | 674 "PowerButtonAnimationContainer", root_window) ; |
| 675 } | 675 } |
| 676 | 676 |
| 677 } // namespace internal | 677 } // namespace internal |
| 678 } // namespace ash | 678 } // namespace ash |
| OLD | NEW |