Chromium Code Reviews| 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" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "ash/common/wallpaper/wallpaper_delegate.h" | 29 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 30 #include "ash/common/wm/always_on_top_controller.h" | 30 #include "ash/common/wm/always_on_top_controller.h" |
| 31 #include "ash/common/wm/container_finder.h" | 31 #include "ash/common/wm/container_finder.h" |
| 32 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 32 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 33 #include "ash/common/wm/fullscreen_window_finder.h" | 33 #include "ash/common/wm/fullscreen_window_finder.h" |
| 34 #include "ash/common/wm/panels/panel_layout_manager.h" | 34 #include "ash/common/wm/panels/panel_layout_manager.h" |
| 35 #include "ash/common/wm/root_window_layout_manager.h" | 35 #include "ash/common/wm/root_window_layout_manager.h" |
| 36 #include "ash/common/wm/switchable_windows.h" | 36 #include "ash/common/wm/switchable_windows.h" |
| 37 #include "ash/common/wm/window_state.h" | 37 #include "ash/common/wm/window_state.h" |
| 38 #include "ash/common/wm/workspace/workspace_layout_manager.h" | 38 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| 39 #include "ash/common/wm/workspace_controller.h" | |
| 39 #include "ash/common/wm_shell.h" | 40 #include "ash/common/wm_shell.h" |
| 40 #include "ash/common/wm_window.h" | 41 #include "ash/common/wm_window.h" |
| 41 #include "ash/desktop_background/desktop_background_widget_controller.h" | 42 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| 42 #include "ash/display/display_manager.h" | 43 #include "ash/display/display_manager.h" |
| 43 #include "ash/high_contrast/high_contrast_controller.h" | 44 #include "ash/high_contrast/high_contrast_controller.h" |
| 44 #include "ash/host/ash_window_tree_host.h" | 45 #include "ash/host/ash_window_tree_host.h" |
| 45 #include "ash/root_window_settings.h" | 46 #include "ash/root_window_settings.h" |
| 46 #include "ash/shelf/shelf_window_targeter.h" | 47 #include "ash/shelf/shelf_window_targeter.h" |
| 47 #include "ash/shell.h" | 48 #include "ash/shell.h" |
| 48 #include "ash/touch/touch_hud_debug.h" | 49 #include "ash/touch/touch_hud_debug.h" |
| 49 #include "ash/touch/touch_hud_projection.h" | 50 #include "ash/touch/touch_hud_projection.h" |
| 50 #include "ash/touch/touch_observer_hud.h" | 51 #include "ash/touch/touch_observer_hud.h" |
| 51 #include "ash/wm/lock_layout_manager.h" | 52 #include "ash/wm/lock_layout_manager.h" |
| 52 #include "ash/wm/panels/attached_panel_window_targeter.h" | 53 #include "ash/wm/panels/attached_panel_window_targeter.h" |
| 53 #include "ash/wm/panels/panel_window_event_handler.h" | 54 #include "ash/wm/panels/panel_window_event_handler.h" |
| 54 #include "ash/wm/stacking_controller.h" | 55 #include "ash/wm/stacking_controller.h" |
| 55 #include "ash/wm/system_background_controller.h" | 56 #include "ash/wm/system_background_controller.h" |
| 56 #include "ash/wm/system_modal_container_layout_manager.h" | 57 #include "ash/wm/system_modal_container_layout_manager.h" |
| 57 #include "ash/wm/window_properties.h" | 58 #include "ash/wm/window_properties.h" |
| 58 #include "ash/wm/window_state_aura.h" | 59 #include "ash/wm/window_state_aura.h" |
| 59 #include "ash/wm/window_util.h" | 60 #include "ash/wm/window_util.h" |
| 60 #include "ash/wm/workspace_controller.h" | |
| 61 #include "base/command_line.h" | 61 #include "base/command_line.h" |
| 62 #include "base/macros.h" | 62 #include "base/macros.h" |
| 63 #include "base/memory/ptr_util.h" | 63 #include "base/memory/ptr_util.h" |
| 64 #include "base/time/time.h" | 64 #include "base/time/time.h" |
| 65 #include "ui/aura/client/aura_constants.h" | 65 #include "ui/aura/client/aura_constants.h" |
| 66 #include "ui/aura/client/screen_position_client.h" | 66 #include "ui/aura/client/screen_position_client.h" |
| 67 #include "ui/aura/window.h" | 67 #include "ui/aura/window.h" |
| 68 #include "ui/aura/window_delegate.h" | 68 #include "ui/aura/window_delegate.h" |
| 69 #include "ui/aura/window_event_dispatcher.h" | 69 #include "ui/aura/window_event_dispatcher.h" |
| 70 #include "ui/aura/window_observer.h" | 70 #include "ui/aura/window_observer.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 } | 324 } |
| 325 | 325 |
| 326 aura::Window* RootWindowController::GetRootWindow() { | 326 aura::Window* RootWindowController::GetRootWindow() { |
| 327 return GetHost()->window(); | 327 return GetHost()->window(); |
| 328 } | 328 } |
| 329 | 329 |
| 330 const aura::Window* RootWindowController::GetRootWindow() const { | 330 const aura::Window* RootWindowController::GetRootWindow() const { |
| 331 return GetHost()->window(); | 331 return GetHost()->window(); |
| 332 } | 332 } |
| 333 | 333 |
| 334 WorkspaceController* RootWindowController::workspace_controller() { | |
| 335 return root_window_controller_common_->workspace_controller(); | |
| 336 } | |
| 337 | |
| 334 void RootWindowController::SetWallpaperController( | 338 void RootWindowController::SetWallpaperController( |
| 335 DesktopBackgroundWidgetController* controller) { | 339 DesktopBackgroundWidgetController* controller) { |
| 336 wallpaper_controller_.reset(controller); | 340 wallpaper_controller_.reset(controller); |
| 337 } | 341 } |
| 338 | 342 |
| 339 void RootWindowController::SetAnimatingWallpaperController( | 343 void RootWindowController::SetAnimatingWallpaperController( |
| 340 AnimatingDesktopController* controller) { | 344 AnimatingDesktopController* controller) { |
| 341 if (animating_wallpaper_controller_.get()) | 345 if (animating_wallpaper_controller_.get()) |
| 342 animating_wallpaper_controller_->StopAnimating(); | 346 animating_wallpaper_controller_->StopAnimating(); |
| 343 animating_wallpaper_controller_.reset(controller); | 347 animating_wallpaper_controller_.reset(controller); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 366 if (shell->GetRootWindowForNewWindows() == root_shutting_down) { | 370 if (shell->GetRootWindowForNewWindows() == root_shutting_down) { |
| 367 // The root window for new windows is being destroyed. Switch to the primary | 371 // The root window for new windows is being destroyed. Switch to the primary |
| 368 // root window if possible. | 372 // root window if possible. |
| 369 WmWindow* primary_root = shell->GetPrimaryRootWindow(); | 373 WmWindow* primary_root = shell->GetPrimaryRootWindow(); |
| 370 shell->set_root_window_for_new_windows( | 374 shell->set_root_window_for_new_windows( |
| 371 primary_root == root_shutting_down ? nullptr : primary_root); | 375 primary_root == root_shutting_down ? nullptr : primary_root); |
| 372 } | 376 } |
| 373 | 377 |
| 374 CloseChildWindows(); | 378 CloseChildWindows(); |
| 375 GetRootWindowSettings(root_window)->controller = NULL; | 379 GetRootWindowSettings(root_window)->controller = NULL; |
| 376 workspace_controller_.reset(); | |
|
msw
2016/08/30 17:46:20
nice (called in CloseChildWindows)
| |
| 377 // Forget with the display ID so that display lookup | 380 // Forget with the display ID so that display lookup |
| 378 // ends up with invalid display. | 381 // ends up with invalid display. |
| 379 GetRootWindowSettings(root_window)->display_id = | 382 GetRootWindowSettings(root_window)->display_id = |
| 380 display::Display::kInvalidDisplayID; | 383 display::Display::kInvalidDisplayID; |
| 381 ash_host_->PrepareForShutdown(); | 384 ash_host_->PrepareForShutdown(); |
| 382 | 385 |
| 383 system_background_.reset(); | 386 system_background_.reset(); |
| 384 aura::client::SetScreenPositionClient(root_window, NULL); | 387 aura::client::SetScreenPositionClient(root_window, NULL); |
| 385 } | 388 } |
| 386 | 389 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 aura::Window* root_window = GetRootWindow(); | 573 aura::Window* root_window = GetRootWindow(); |
| 571 aura::client::SetDragDropClient(root_window, NULL); | 574 aura::client::SetDragDropClient(root_window, NULL); |
| 572 | 575 |
| 573 if (shelf_widget_) | 576 if (shelf_widget_) |
| 574 shelf_widget_->Shutdown(); | 577 shelf_widget_->Shutdown(); |
| 575 | 578 |
| 576 // Close background widget first as it depends on tooltip. | 579 // Close background widget first as it depends on tooltip. |
| 577 wallpaper_controller_.reset(); | 580 wallpaper_controller_.reset(); |
| 578 animating_wallpaper_controller_.reset(); | 581 animating_wallpaper_controller_.reset(); |
| 579 | 582 |
| 580 workspace_controller_.reset(); | 583 root_window_controller_common_->DeleteWorkspaceController(); |
| 581 aura::client::SetTooltipClient(root_window, NULL); | 584 aura::client::SetTooltipClient(root_window, NULL); |
| 582 | 585 |
| 583 // Explicitly destroy top level windows. We do this as during part of | 586 // Explicitly destroy top level windows. We do this as during part of |
| 584 // destruction such windows may query the RootWindow for state. | 587 // destruction such windows may query the RootWindow for state. |
| 585 aura::WindowTracker non_toplevel_windows; | 588 aura::WindowTracker non_toplevel_windows; |
| 586 non_toplevel_windows.Add(root_window); | 589 non_toplevel_windows.Add(root_window); |
| 587 while (!non_toplevel_windows.windows().empty()) { | 590 while (!non_toplevel_windows.windows().empty()) { |
| 588 const aura::Window* non_toplevel_window = | 591 const aura::Window* non_toplevel_window = |
| 589 *non_toplevel_windows.windows().begin(); | 592 *non_toplevel_windows.windows().begin(); |
| 590 non_toplevel_windows.Remove(const_cast<aura::Window*>(non_toplevel_window)); | 593 non_toplevel_windows.Remove(const_cast<aura::Window*>(non_toplevel_window)); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 614 shelf_widget_.reset(); | 617 shelf_widget_.reset(); |
| 615 // CloseChildWindows may be called twice during the shutdown of ash unittests. | 618 // CloseChildWindows may be called twice during the shutdown of ash unittests. |
| 616 // Avoid notifying WmShelf that the Shelf instance has been destroyed twice. | 619 // Avoid notifying WmShelf that the Shelf instance has been destroyed twice. |
| 617 if (wm_shelf_aura_->shelf()) | 620 if (wm_shelf_aura_->shelf()) |
| 618 wm_shelf_aura_->ClearShelf(); | 621 wm_shelf_aura_->ClearShelf(); |
| 619 shelf_.reset(); | 622 shelf_.reset(); |
| 620 } | 623 } |
| 621 | 624 |
| 622 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 625 void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
| 623 // Clear the workspace controller, so it doesn't incorrectly update the shelf. | 626 // Clear the workspace controller, so it doesn't incorrectly update the shelf. |
| 624 workspace_controller_.reset(); | 627 root_window_controller_common_->DeleteWorkspaceController(); |
| 625 ReparentAllWindows(GetRootWindow(), dst); | 628 ReparentAllWindows(GetRootWindow(), dst); |
| 626 } | 629 } |
| 627 | 630 |
| 628 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 631 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
| 629 return shelf_widget_->shelf_layout_manager(); | 632 return shelf_widget_->shelf_layout_manager(); |
| 630 } | 633 } |
| 631 | 634 |
| 632 SystemTray* RootWindowController::GetSystemTray() { | 635 SystemTray* RootWindowController::GetSystemTray() { |
| 633 // We assume in throughout the code that this will not return NULL. If code | 636 // We assume in throughout the code that this will not return NULL. If code |
| 634 // triggers this for valid reasons, it should test status_area_widget first. | 637 // triggers this for valid reasons, it should test status_area_widget first. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 674 void RootWindowController::ActivateKeyboard( | 677 void RootWindowController::ActivateKeyboard( |
| 675 keyboard::KeyboardController* keyboard_controller) { | 678 keyboard::KeyboardController* keyboard_controller) { |
| 676 if (!keyboard::IsKeyboardEnabled() || | 679 if (!keyboard::IsKeyboardEnabled() || |
| 677 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { | 680 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { |
| 678 return; | 681 return; |
| 679 } | 682 } |
| 680 DCHECK(keyboard_controller); | 683 DCHECK(keyboard_controller); |
| 681 keyboard_controller->AddObserver(shelf_widget()->shelf_layout_manager()); | 684 keyboard_controller->AddObserver(shelf_widget()->shelf_layout_manager()); |
| 682 keyboard_controller->AddObserver(panel_layout_manager_); | 685 keyboard_controller->AddObserver(panel_layout_manager_); |
| 683 keyboard_controller->AddObserver(docked_layout_manager_); | 686 keyboard_controller->AddObserver(docked_layout_manager_); |
| 684 keyboard_controller->AddObserver(workspace_controller_->layout_manager()); | 687 keyboard_controller->AddObserver(workspace_controller()->layout_manager()); |
| 685 keyboard_controller->AddObserver( | 688 keyboard_controller->AddObserver( |
| 686 always_on_top_controller_->GetLayoutManager()); | 689 always_on_top_controller_->GetLayoutManager()); |
| 687 WmShell::Get()->NotifyVirtualKeyboardActivated(true); | 690 WmShell::Get()->NotifyVirtualKeyboardActivated(true); |
| 688 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); | 691 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); |
| 689 DCHECK(parent); | 692 DCHECK(parent); |
| 690 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); | 693 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); |
| 691 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); | 694 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); |
| 692 parent->AddChild(keyboard_container); | 695 parent->AddChild(keyboard_container); |
| 693 } | 696 } |
| 694 | 697 |
| 695 void RootWindowController::DeactivateKeyboard( | 698 void RootWindowController::DeactivateKeyboard( |
| 696 keyboard::KeyboardController* keyboard_controller) { | 699 keyboard::KeyboardController* keyboard_controller) { |
| 697 if (!keyboard_controller || | 700 if (!keyboard_controller || |
| 698 !keyboard_controller->keyboard_container_initialized()) { | 701 !keyboard_controller->keyboard_container_initialized()) { |
| 699 return; | 702 return; |
| 700 } | 703 } |
| 701 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); | 704 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); |
| 702 if (keyboard_container->GetRootWindow() == GetRootWindow()) { | 705 if (keyboard_container->GetRootWindow() == GetRootWindow()) { |
| 703 aura::Window* parent = | 706 aura::Window* parent = |
| 704 GetContainer(kShellWindowId_ImeWindowParentContainer); | 707 GetContainer(kShellWindowId_ImeWindowParentContainer); |
| 705 DCHECK(parent); | 708 DCHECK(parent); |
| 706 parent->RemoveChild(keyboard_container); | 709 parent->RemoveChild(keyboard_container); |
| 707 // Virtual keyboard may be deactivated while still showing, notify all | 710 // Virtual keyboard may be deactivated while still showing, notify all |
| 708 // observers that keyboard bounds changed to 0 before remove them. | 711 // observers that keyboard bounds changed to 0 before remove them. |
| 709 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect()); | 712 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect()); |
| 710 keyboard_controller->RemoveObserver(shelf_widget()->shelf_layout_manager()); | 713 keyboard_controller->RemoveObserver(shelf_widget()->shelf_layout_manager()); |
| 711 keyboard_controller->RemoveObserver(panel_layout_manager_); | 714 keyboard_controller->RemoveObserver(panel_layout_manager_); |
| 712 keyboard_controller->RemoveObserver(docked_layout_manager_); | 715 keyboard_controller->RemoveObserver(docked_layout_manager_); |
| 713 keyboard_controller->RemoveObserver( | 716 keyboard_controller->RemoveObserver( |
| 714 workspace_controller_->layout_manager()); | 717 workspace_controller()->layout_manager()); |
| 715 keyboard_controller->RemoveObserver( | 718 keyboard_controller->RemoveObserver( |
| 716 always_on_top_controller_->GetLayoutManager()); | 719 always_on_top_controller_->GetLayoutManager()); |
| 717 WmShell::Get()->NotifyVirtualKeyboardActivated(false); | 720 WmShell::Get()->NotifyVirtualKeyboardActivated(false); |
| 718 } | 721 } |
| 719 } | 722 } |
| 720 | 723 |
| 721 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { | 724 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { |
| 722 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); | 725 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); |
| 723 return parent ? parent->Contains(window) : false; | 726 return parent ? parent->Contains(window) : false; |
| 724 } | 727 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 809 root_window->GetChildById(kShellWindowId_LockScreenContainer); | 812 root_window->GetChildById(kShellWindowId_LockScreenContainer); |
| 810 DCHECK(lock_container); | 813 DCHECK(lock_container); |
| 811 lock_container->SetLayoutManager(new LockLayoutManager(lock_container)); | 814 lock_container->SetLayoutManager(new LockLayoutManager(lock_container)); |
| 812 | 815 |
| 813 aura::Window* lock_modal_container = | 816 aura::Window* lock_modal_container = |
| 814 root_window->GetChildById(kShellWindowId_LockSystemModalContainer); | 817 root_window->GetChildById(kShellWindowId_LockSystemModalContainer); |
| 815 DCHECK(lock_modal_container); | 818 DCHECK(lock_modal_container); |
| 816 lock_modal_container->SetLayoutManager( | 819 lock_modal_container->SetLayoutManager( |
| 817 new SystemModalContainerLayoutManager(lock_modal_container)); | 820 new SystemModalContainerLayoutManager(lock_modal_container)); |
| 818 | 821 |
| 819 WmWindow* default_container = | |
| 820 WmWindowAura::Get(GetContainer(kShellWindowId_DefaultContainer)); | |
| 821 workspace_controller_.reset(new WorkspaceController(default_container)); | |
| 822 | |
| 823 WmWindow* always_on_top_container = | 822 WmWindow* always_on_top_container = |
| 824 WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer)); | 823 WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer)); |
| 825 always_on_top_controller_.reset( | 824 always_on_top_controller_.reset( |
| 826 new AlwaysOnTopController(always_on_top_container)); | 825 new AlwaysOnTopController(always_on_top_container)); |
| 827 | 826 |
| 828 // Create the shelf and status area widgets. | 827 // Create the shelf and status area widgets. |
| 829 DCHECK(!shelf_widget_.get()); | 828 DCHECK(!shelf_widget_.get()); |
| 830 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); | 829 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); |
| 831 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); | 830 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); |
| 832 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); | 831 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 957 aura::Window* primary_root_window = Shell::GetInstance() | 956 aura::Window* primary_root_window = Shell::GetInstance() |
| 958 ->window_tree_host_manager() | 957 ->window_tree_host_manager() |
| 959 ->GetPrimaryRootWindow(); | 958 ->GetPrimaryRootWindow(); |
| 960 return GetRootWindowSettings(primary_root_window)->controller; | 959 return GetRootWindowSettings(primary_root_window)->controller; |
| 961 } | 960 } |
| 962 | 961 |
| 963 return GetRootWindowSettings(root_window)->controller; | 962 return GetRootWindowSettings(root_window)->controller; |
| 964 } | 963 } |
| 965 | 964 |
| 966 } // namespace ash | 965 } // namespace ash |
| OLD | NEW |