| 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 <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_touch_exploration_manager_chromeos.h" | 10 #include "ash/ash_touch_exploration_manager_chromeos.h" |
| 11 #include "ash/aura/aura_layout_manager_adapter.h" | 11 #include "ash/aura/aura_layout_manager_adapter.h" |
| 12 #include "ash/aura/wm_root_window_controller_aura.h" | 12 #include "ash/aura/wm_root_window_controller_aura.h" |
| 13 #include "ash/aura/wm_shelf_aura.h" | |
| 14 #include "ash/aura/wm_window_aura.h" | 13 #include "ash/aura/wm_window_aura.h" |
| 15 #include "ash/common/ash_constants.h" | 14 #include "ash/common/ash_constants.h" |
| 16 #include "ash/common/ash_switches.h" | 15 #include "ash/common/ash_switches.h" |
| 17 #include "ash/common/focus_cycler.h" | 16 #include "ash/common/focus_cycler.h" |
| 18 #include "ash/common/login_status.h" | 17 #include "ash/common/login_status.h" |
| 19 #include "ash/common/session/session_state_delegate.h" | 18 #include "ash/common/session/session_state_delegate.h" |
| 20 #include "ash/common/shelf/shelf_delegate.h" | 19 #include "ash/common/shelf/shelf_delegate.h" |
| 21 #include "ash/common/shelf/shelf_layout_manager.h" | 20 #include "ash/common/shelf/shelf_layout_manager.h" |
| 22 #include "ash/common/shelf/shelf_widget.h" | 21 #include "ash/common/shelf/shelf_widget.h" |
| 22 #include "ash/common/shelf/wm_shelf.h" |
| 23 #include "ash/common/shell_delegate.h" | 23 #include "ash/common/shell_delegate.h" |
| 24 #include "ash/common/system/status_area_layout_manager.h" | 24 #include "ash/common/system/status_area_layout_manager.h" |
| 25 #include "ash/common/system/status_area_widget.h" | 25 #include "ash/common/system/status_area_widget.h" |
| 26 #include "ash/common/system/tray/system_tray_delegate.h" | 26 #include "ash/common/system/tray/system_tray_delegate.h" |
| 27 #include "ash/common/wallpaper/wallpaper_delegate.h" | 27 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 28 #include "ash/common/wallpaper/wallpaper_widget_controller.h" | 28 #include "ash/common/wallpaper/wallpaper_widget_controller.h" |
| 29 #include "ash/common/wm/always_on_top_controller.h" | 29 #include "ash/common/wm/always_on_top_controller.h" |
| 30 #include "ash/common/wm/container_finder.h" | 30 #include "ash/common/wm/container_finder.h" |
| 31 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 31 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 32 #include "ash/common/wm/fullscreen_window_finder.h" | 32 #include "ash/common/wm/fullscreen_window_finder.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 275 |
| 276 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) { | 276 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) { |
| 277 // Make sure the wallpaper is visible. | 277 // Make sure the wallpaper is visible. |
| 278 system_wallpaper_->SetColor(SK_ColorBLACK); | 278 system_wallpaper_->SetColor(SK_ColorBLACK); |
| 279 boot_splash_screen_.reset(); | 279 boot_splash_screen_.reset(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void RootWindowController::CloseChildWindows() { | 282 void RootWindowController::CloseChildWindows() { |
| 283 // Remove observer as deactivating keyboard causes | 283 // Remove observer as deactivating keyboard causes |
| 284 // docked_window_layout_manager() to fire notifications. | 284 // docked_window_layout_manager() to fire notifications. |
| 285 if (docked_window_layout_manager() && | 285 if (docked_window_layout_manager() && wm_shelf_->shelf_layout_manager()) { |
| 286 wm_shelf_aura_->shelf_layout_manager()) { | |
| 287 docked_window_layout_manager()->RemoveObserver( | 286 docked_window_layout_manager()->RemoveObserver( |
| 288 wm_shelf_aura_->shelf_layout_manager()); | 287 wm_shelf_->shelf_layout_manager()); |
| 289 } | 288 } |
| 290 | 289 |
| 291 // Deactivate keyboard container before closing child windows and shutting | 290 // Deactivate keyboard container before closing child windows and shutting |
| 292 // down associated layout managers. | 291 // down associated layout managers. |
| 293 DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); | 292 DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); |
| 294 | 293 |
| 295 wm_root_window_controller_->CloseChildWindows(); | 294 wm_root_window_controller_->CloseChildWindows(); |
| 296 | 295 |
| 297 aura::client::SetDragDropClient(GetRootWindow(), nullptr); | 296 aura::client::SetDragDropClient(GetRootWindow(), nullptr); |
| 298 aura::client::SetTooltipClient(GetRootWindow(), nullptr); | 297 aura::client::SetTooltipClient(GetRootWindow(), nullptr); |
| 299 } | 298 } |
| 300 | 299 |
| 301 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 300 void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
| 302 wm_root_window_controller_->MoveWindowsTo(WmWindowAura::Get(dst)); | 301 wm_root_window_controller_->MoveWindowsTo(WmWindowAura::Get(dst)); |
| 303 } | 302 } |
| 304 | 303 |
| 305 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 304 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
| 306 return wm_shelf_aura_->shelf_layout_manager(); | 305 return wm_shelf_->shelf_layout_manager(); |
| 307 } | 306 } |
| 308 | 307 |
| 309 StatusAreaWidget* RootWindowController::GetStatusAreaWidget() { | 308 StatusAreaWidget* RootWindowController::GetStatusAreaWidget() { |
| 310 ShelfWidget* shelf_widget = wm_shelf_aura_->shelf_widget(); | 309 ShelfWidget* shelf_widget = wm_shelf_->shelf_widget(); |
| 311 return shelf_widget ? shelf_widget->status_area_widget() : nullptr; | 310 return shelf_widget ? shelf_widget->status_area_widget() : nullptr; |
| 312 } | 311 } |
| 313 | 312 |
| 314 SystemTray* RootWindowController::GetSystemTray() { | 313 SystemTray* RootWindowController::GetSystemTray() { |
| 315 // We assume in throughout the code that this will not return NULL. If code | 314 // We assume in throughout the code that this will not return NULL. If code |
| 316 // triggers this for valid reasons, it should test status_area_widget first. | 315 // triggers this for valid reasons, it should test status_area_widget first. |
| 317 CHECK(wm_shelf_aura_->shelf_widget()->status_area_widget()); | 316 CHECK(wm_shelf_->shelf_widget()->status_area_widget()); |
| 318 return wm_shelf_aura_->shelf_widget()->status_area_widget()->system_tray(); | 317 return wm_shelf_->shelf_widget()->status_area_widget()->system_tray(); |
| 319 } | 318 } |
| 320 | 319 |
| 321 void RootWindowController::UpdateShelfVisibility() { | 320 void RootWindowController::UpdateShelfVisibility() { |
| 322 wm_shelf_aura_->UpdateVisibilityState(); | 321 wm_shelf_->UpdateVisibilityState(); |
| 323 } | 322 } |
| 324 | 323 |
| 325 aura::Window* RootWindowController::GetWindowForFullscreenMode() { | 324 aura::Window* RootWindowController::GetWindowForFullscreenMode() { |
| 326 return WmWindowAura::GetAuraWindow( | 325 return WmWindowAura::GetAuraWindow( |
| 327 wm::GetWindowForFullscreenMode(WmWindowAura::Get(GetRootWindow()))); | 326 wm::GetWindowForFullscreenMode(WmWindowAura::Get(GetRootWindow()))); |
| 328 } | 327 } |
| 329 | 328 |
| 330 void RootWindowController::ActivateKeyboard( | 329 void RootWindowController::ActivateKeyboard( |
| 331 keyboard::KeyboardController* keyboard_controller) { | 330 keyboard::KeyboardController* keyboard_controller) { |
| 332 if (!keyboard::IsKeyboardEnabled() || | 331 if (!keyboard::IsKeyboardEnabled() || |
| 333 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { | 332 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { |
| 334 return; | 333 return; |
| 335 } | 334 } |
| 336 DCHECK(keyboard_controller); | 335 DCHECK(keyboard_controller); |
| 337 keyboard_controller->AddObserver(wm_shelf_aura_->shelf_layout_manager()); | 336 keyboard_controller->AddObserver(wm_shelf_->shelf_layout_manager()); |
| 338 keyboard_controller->AddObserver(panel_layout_manager()); | 337 keyboard_controller->AddObserver(panel_layout_manager()); |
| 339 keyboard_controller->AddObserver(docked_window_layout_manager()); | 338 keyboard_controller->AddObserver(docked_window_layout_manager()); |
| 340 keyboard_controller->AddObserver(workspace_controller()->layout_manager()); | 339 keyboard_controller->AddObserver(workspace_controller()->layout_manager()); |
| 341 keyboard_controller->AddObserver( | 340 keyboard_controller->AddObserver( |
| 342 wm_root_window_controller_->always_on_top_controller() | 341 wm_root_window_controller_->always_on_top_controller() |
| 343 ->GetLayoutManager()); | 342 ->GetLayoutManager()); |
| 344 WmShell::Get()->NotifyVirtualKeyboardActivated(true); | 343 WmShell::Get()->NotifyVirtualKeyboardActivated(true); |
| 345 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); | 344 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); |
| 346 DCHECK(parent); | 345 DCHECK(parent); |
| 347 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); | 346 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); |
| 348 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); | 347 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); |
| 349 parent->AddChild(keyboard_container); | 348 parent->AddChild(keyboard_container); |
| 350 } | 349 } |
| 351 | 350 |
| 352 void RootWindowController::DeactivateKeyboard( | 351 void RootWindowController::DeactivateKeyboard( |
| 353 keyboard::KeyboardController* keyboard_controller) { | 352 keyboard::KeyboardController* keyboard_controller) { |
| 354 if (!keyboard_controller || | 353 if (!keyboard_controller || |
| 355 !keyboard_controller->keyboard_container_initialized()) { | 354 !keyboard_controller->keyboard_container_initialized()) { |
| 356 return; | 355 return; |
| 357 } | 356 } |
| 358 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); | 357 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); |
| 359 if (keyboard_container->GetRootWindow() == GetRootWindow()) { | 358 if (keyboard_container->GetRootWindow() == GetRootWindow()) { |
| 360 aura::Window* parent = | 359 aura::Window* parent = |
| 361 GetContainer(kShellWindowId_ImeWindowParentContainer); | 360 GetContainer(kShellWindowId_ImeWindowParentContainer); |
| 362 DCHECK(parent); | 361 DCHECK(parent); |
| 363 parent->RemoveChild(keyboard_container); | 362 parent->RemoveChild(keyboard_container); |
| 364 // Virtual keyboard may be deactivated while still showing, notify all | 363 // Virtual keyboard may be deactivated while still showing, notify all |
| 365 // observers that keyboard bounds changed to 0 before remove them. | 364 // observers that keyboard bounds changed to 0 before remove them. |
| 366 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect()); | 365 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect()); |
| 367 keyboard_controller->RemoveObserver(wm_shelf_aura_->shelf_layout_manager()); | 366 keyboard_controller->RemoveObserver(wm_shelf_->shelf_layout_manager()); |
| 368 keyboard_controller->RemoveObserver(panel_layout_manager()); | 367 keyboard_controller->RemoveObserver(panel_layout_manager()); |
| 369 keyboard_controller->RemoveObserver(docked_window_layout_manager()); | 368 keyboard_controller->RemoveObserver(docked_window_layout_manager()); |
| 370 keyboard_controller->RemoveObserver( | 369 keyboard_controller->RemoveObserver( |
| 371 workspace_controller()->layout_manager()); | 370 workspace_controller()->layout_manager()); |
| 372 keyboard_controller->RemoveObserver( | 371 keyboard_controller->RemoveObserver( |
| 373 wm_root_window_controller_->always_on_top_controller() | 372 wm_root_window_controller_->always_on_top_controller() |
| 374 ->GetLayoutManager()); | 373 ->GetLayoutManager()); |
| 375 WmShell::Get()->NotifyVirtualKeyboardActivated(false); | 374 WmShell::Get()->NotifyVirtualKeyboardActivated(false); |
| 376 } | 375 } |
| 377 } | 376 } |
| 378 | 377 |
| 379 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { | 378 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { |
| 380 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); | 379 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); |
| 381 return parent ? parent->Contains(window) : false; | 380 return parent ? parent->Contains(window) : false; |
| 382 } | 381 } |
| 383 | 382 |
| 384 void RootWindowController::SetTouchAccessibilityAnchorPoint( | 383 void RootWindowController::SetTouchAccessibilityAnchorPoint( |
| 385 const gfx::Point& anchor_point) { | 384 const gfx::Point& anchor_point) { |
| 386 if (touch_exploration_manager_) | 385 if (touch_exploration_manager_) |
| 387 touch_exploration_manager_->SetTouchAccessibilityAnchorPoint(anchor_point); | 386 touch_exploration_manager_->SetTouchAccessibilityAnchorPoint(anchor_point); |
| 388 } | 387 } |
| 389 | 388 |
| 390 //////////////////////////////////////////////////////////////////////////////// | 389 //////////////////////////////////////////////////////////////////////////////// |
| 391 // RootWindowController, private: | 390 // RootWindowController, private: |
| 392 | 391 |
| 393 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) | 392 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) |
| 394 : ash_host_(ash_host), | 393 : ash_host_(ash_host), |
| 395 wm_shelf_aura_(new WmShelfAura), | 394 wm_shelf_(base::MakeUnique<WmShelf>()), |
| 396 touch_hud_debug_(NULL), | 395 touch_hud_debug_(NULL), |
| 397 touch_hud_projection_(NULL) { | 396 touch_hud_projection_(NULL) { |
| 398 aura::Window* root_window = GetRootWindow(); | 397 aura::Window* root_window = GetRootWindow(); |
| 399 GetRootWindowSettings(root_window)->controller = this; | 398 GetRootWindowSettings(root_window)->controller = this; |
| 400 | 399 |
| 401 // Has to happen after this is set as |controller| of RootWindowSettings. | 400 // Has to happen after this is set as |controller| of RootWindowSettings. |
| 402 wm_root_window_controller_ = WmRootWindowControllerAura::Get(root_window); | 401 wm_root_window_controller_ = WmRootWindowControllerAura::Get(root_window); |
| 403 | 402 |
| 404 stacking_controller_.reset(new StackingController); | 403 stacking_controller_.reset(new StackingController); |
| 405 aura::client::SetWindowParentingClient(root_window, | 404 aura::client::SetWindowParentingClient(root_window, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 443 } |
| 445 | 444 |
| 446 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 445 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 447 switches::kAshDisableTouchExplorationMode)) { | 446 switches::kAshDisableTouchExplorationMode)) { |
| 448 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); | 447 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); |
| 449 } | 448 } |
| 450 } | 449 } |
| 451 | 450 |
| 452 void RootWindowController::InitLayoutManagers() { | 451 void RootWindowController::InitLayoutManagers() { |
| 453 // Create the shelf and status area widgets. | 452 // Create the shelf and status area widgets. |
| 454 DCHECK(!wm_shelf_aura_->shelf_widget()); | 453 DCHECK(!wm_shelf_->shelf_widget()); |
| 455 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); | 454 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); |
| 456 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); | 455 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); |
| 457 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); | 456 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); |
| 458 WmWindow* wm_status_container = WmWindowAura::Get(status_container); | 457 WmWindow* wm_status_container = WmWindowAura::Get(status_container); |
| 459 | 458 |
| 460 wm_root_window_controller_->CreateLayoutManagers(); | 459 wm_root_window_controller_->CreateLayoutManagers(); |
| 461 | 460 |
| 462 // Make it easier to resize windows that partially overlap the shelf. Must | 461 // Make it easier to resize windows that partially overlap the shelf. Must |
| 463 // occur after the ShelfLayoutManager is constructed by ShelfWidget. | 462 // occur after the ShelfLayoutManager is constructed by ShelfWidget. |
| 464 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( | 463 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( |
| 465 wm_shelf_container, wm_shelf_aura_.get())); | 464 wm_shelf_container, wm_shelf_.get())); |
| 466 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( | 465 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( |
| 467 wm_status_container, wm_shelf_aura_.get())); | 466 wm_status_container, wm_shelf_.get())); |
| 468 | 467 |
| 469 panel_container_handler_ = base::MakeUnique<PanelWindowEventHandler>(); | 468 panel_container_handler_ = base::MakeUnique<PanelWindowEventHandler>(); |
| 470 GetContainer(kShellWindowId_PanelContainer) | 469 GetContainer(kShellWindowId_PanelContainer) |
| 471 ->AddPreTargetHandler(panel_container_handler_.get()); | 470 ->AddPreTargetHandler(panel_container_handler_.get()); |
| 472 | 471 |
| 473 // Install an AttachedPanelWindowTargeter on the panel container to make it | 472 // Install an AttachedPanelWindowTargeter on the panel container to make it |
| 474 // easier to correctly target shelf buttons with touch. | 473 // easier to correctly target shelf buttons with touch. |
| 475 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, | 474 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, |
| 476 -kResizeOutsideBoundsSize, | 475 -kResizeOutsideBoundsSize, |
| 477 -kResizeOutsideBoundsSize); | 476 -kResizeOutsideBoundsSize); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 DockedWindowLayoutManager* | 530 DockedWindowLayoutManager* |
| 532 RootWindowController::docked_window_layout_manager() { | 531 RootWindowController::docked_window_layout_manager() { |
| 533 return wm_root_window_controller_->docked_window_layout_manager(); | 532 return wm_root_window_controller_->docked_window_layout_manager(); |
| 534 } | 533 } |
| 535 | 534 |
| 536 PanelLayoutManager* RootWindowController::panel_layout_manager() { | 535 PanelLayoutManager* RootWindowController::panel_layout_manager() { |
| 537 return wm_root_window_controller_->panel_layout_manager(); | 536 return wm_root_window_controller_->panel_layout_manager(); |
| 538 } | 537 } |
| 539 | 538 |
| 540 void RootWindowController::OnLoginStateChanged(LoginStatus status) { | 539 void RootWindowController::OnLoginStateChanged(LoginStatus status) { |
| 541 wm_shelf_aura_->UpdateVisibilityState(); | 540 wm_shelf_->UpdateVisibilityState(); |
| 542 } | 541 } |
| 543 | 542 |
| 544 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { | 543 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
| 545 if (enabled) | 544 if (enabled) |
| 546 EnableTouchHudProjection(); | 545 EnableTouchHudProjection(); |
| 547 else | 546 else |
| 548 DisableTouchHudProjection(); | 547 DisableTouchHudProjection(); |
| 549 } | 548 } |
| 550 | 549 |
| 551 RootWindowController* GetRootWindowController(const aura::Window* root_window) { | 550 RootWindowController* GetRootWindowController(const aura::Window* root_window) { |
| 552 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; | 551 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; |
| 553 } | 552 } |
| 554 | 553 |
| 555 } // namespace ash | 554 } // namespace ash |
| OLD | NEW |