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