Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: ash/root_window_controller.cc

Issue 2292183003: Moves WorkspaceController to ash/common (Closed)
Patch Set: merge 2 trunk Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/display/display_manager.h" 42 #include "ash/display/display_manager.h"
42 #include "ash/high_contrast/high_contrast_controller.h" 43 #include "ash/high_contrast/high_contrast_controller.h"
43 #include "ash/host/ash_window_tree_host.h" 44 #include "ash/host/ash_window_tree_host.h"
44 #include "ash/root_window_settings.h" 45 #include "ash/root_window_settings.h"
45 #include "ash/shelf/shelf_window_targeter.h" 46 #include "ash/shelf/shelf_window_targeter.h"
46 #include "ash/shell.h" 47 #include "ash/shell.h"
47 #include "ash/touch/touch_hud_debug.h" 48 #include "ash/touch/touch_hud_debug.h"
48 #include "ash/touch/touch_hud_projection.h" 49 #include "ash/touch/touch_hud_projection.h"
49 #include "ash/touch/touch_observer_hud.h" 50 #include "ash/touch/touch_observer_hud.h"
50 #include "ash/wallpaper/wallpaper_widget_controller.h" 51 #include "ash/wallpaper/wallpaper_widget_controller.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_modal_container_layout_manager.h" 56 #include "ash/wm/system_modal_container_layout_manager.h"
56 #include "ash/wm/system_wallpaper_controller.h" 57 #include "ash/wm/system_wallpaper_controller.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
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::SetWallpaperWidgetController( 338 void RootWindowController::SetWallpaperWidgetController(
335 WallpaperWidgetController* controller) { 339 WallpaperWidgetController* controller) {
336 wallpaper_widget_controller_.reset(controller); 340 wallpaper_widget_controller_.reset(controller);
337 } 341 }
338 342
339 void RootWindowController::SetAnimatingWallpaperWidgetController( 343 void RootWindowController::SetAnimatingWallpaperWidgetController(
340 AnimatingWallpaperWidgetController* controller) { 344 AnimatingWallpaperWidgetController* controller) {
341 if (animating_wallpaper_widget_controller_.get()) 345 if (animating_wallpaper_widget_controller_.get())
342 animating_wallpaper_widget_controller_->StopAnimating(); 346 animating_wallpaper_widget_controller_->StopAnimating();
343 animating_wallpaper_widget_controller_.reset(controller); 347 animating_wallpaper_widget_controller_.reset(controller);
(...skipping 22 matching lines...) Expand all
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();
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_wallpaper_.reset(); 386 system_wallpaper_.reset();
384 aura::client::SetScreenPositionClient(root_window, NULL); 387 aura::client::SetScreenPositionClient(root_window, NULL);
385 } 388 }
386 389
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 aura::Window* root_window = GetRootWindow(); 570 aura::Window* root_window = GetRootWindow();
568 aura::client::SetDragDropClient(root_window, NULL); 571 aura::client::SetDragDropClient(root_window, NULL);
569 572
570 if (shelf_widget_) 573 if (shelf_widget_)
571 shelf_widget_->Shutdown(); 574 shelf_widget_->Shutdown();
572 575
573 // Close wallpaper widget first as it depends on tooltip. 576 // Close wallpaper widget first as it depends on tooltip.
574 wallpaper_widget_controller_.reset(); 577 wallpaper_widget_controller_.reset();
575 animating_wallpaper_widget_controller_.reset(); 578 animating_wallpaper_widget_controller_.reset();
576 579
577 workspace_controller_.reset(); 580 root_window_controller_common_->DeleteWorkspaceController();
578 aura::client::SetTooltipClient(root_window, NULL); 581 aura::client::SetTooltipClient(root_window, NULL);
579 582
580 // Explicitly destroy top level windows. We do this as during part of 583 // Explicitly destroy top level windows. We do this as during part of
581 // destruction such windows may query the RootWindow for state. 584 // destruction such windows may query the RootWindow for state.
582 aura::WindowTracker non_toplevel_windows; 585 aura::WindowTracker non_toplevel_windows;
583 non_toplevel_windows.Add(root_window); 586 non_toplevel_windows.Add(root_window);
584 while (!non_toplevel_windows.windows().empty()) { 587 while (!non_toplevel_windows.windows().empty()) {
585 const aura::Window* non_toplevel_window = 588 const aura::Window* non_toplevel_window =
586 *non_toplevel_windows.windows().begin(); 589 *non_toplevel_windows.windows().begin();
587 non_toplevel_windows.Remove(const_cast<aura::Window*>(non_toplevel_window)); 590 non_toplevel_windows.Remove(const_cast<aura::Window*>(non_toplevel_window));
(...skipping 23 matching lines...) Expand all
611 shelf_widget_.reset(); 614 shelf_widget_.reset();
612 // CloseChildWindows may be called twice during the shutdown of ash unittests. 615 // CloseChildWindows may be called twice during the shutdown of ash unittests.
613 // Avoid notifying WmShelf that the Shelf instance has been destroyed twice. 616 // Avoid notifying WmShelf that the Shelf instance has been destroyed twice.
614 if (wm_shelf_aura_->shelf()) 617 if (wm_shelf_aura_->shelf())
615 wm_shelf_aura_->ClearShelf(); 618 wm_shelf_aura_->ClearShelf();
616 shelf_.reset(); 619 shelf_.reset();
617 } 620 }
618 621
619 void RootWindowController::MoveWindowsTo(aura::Window* dst) { 622 void RootWindowController::MoveWindowsTo(aura::Window* dst) {
620 // Clear the workspace controller, so it doesn't incorrectly update the shelf. 623 // Clear the workspace controller, so it doesn't incorrectly update the shelf.
621 workspace_controller_.reset(); 624 root_window_controller_common_->DeleteWorkspaceController();
622 ReparentAllWindows(GetRootWindow(), dst); 625 ReparentAllWindows(GetRootWindow(), dst);
623 } 626 }
624 627
625 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { 628 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
626 return shelf_widget_->shelf_layout_manager(); 629 return shelf_widget_->shelf_layout_manager();
627 } 630 }
628 631
629 SystemTray* RootWindowController::GetSystemTray() { 632 SystemTray* RootWindowController::GetSystemTray() {
630 // We assume in throughout the code that this will not return NULL. If code 633 // We assume in throughout the code that this will not return NULL. If code
631 // triggers this for valid reasons, it should test status_area_widget first. 634 // triggers this for valid reasons, it should test status_area_widget first.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 void RootWindowController::ActivateKeyboard( 674 void RootWindowController::ActivateKeyboard(
672 keyboard::KeyboardController* keyboard_controller) { 675 keyboard::KeyboardController* keyboard_controller) {
673 if (!keyboard::IsKeyboardEnabled() || 676 if (!keyboard::IsKeyboardEnabled() ||
674 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { 677 GetContainer(kShellWindowId_VirtualKeyboardContainer)) {
675 return; 678 return;
676 } 679 }
677 DCHECK(keyboard_controller); 680 DCHECK(keyboard_controller);
678 keyboard_controller->AddObserver(shelf_widget()->shelf_layout_manager()); 681 keyboard_controller->AddObserver(shelf_widget()->shelf_layout_manager());
679 keyboard_controller->AddObserver(panel_layout_manager_); 682 keyboard_controller->AddObserver(panel_layout_manager_);
680 keyboard_controller->AddObserver(docked_layout_manager_); 683 keyboard_controller->AddObserver(docked_layout_manager_);
681 keyboard_controller->AddObserver(workspace_controller_->layout_manager()); 684 keyboard_controller->AddObserver(workspace_controller()->layout_manager());
682 keyboard_controller->AddObserver( 685 keyboard_controller->AddObserver(
683 always_on_top_controller_->GetLayoutManager()); 686 always_on_top_controller_->GetLayoutManager());
684 WmShell::Get()->NotifyVirtualKeyboardActivated(true); 687 WmShell::Get()->NotifyVirtualKeyboardActivated(true);
685 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); 688 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
686 DCHECK(parent); 689 DCHECK(parent);
687 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); 690 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow();
688 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); 691 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer);
689 parent->AddChild(keyboard_container); 692 parent->AddChild(keyboard_container);
690 } 693 }
691 694
692 void RootWindowController::DeactivateKeyboard( 695 void RootWindowController::DeactivateKeyboard(
693 keyboard::KeyboardController* keyboard_controller) { 696 keyboard::KeyboardController* keyboard_controller) {
694 if (!keyboard_controller || 697 if (!keyboard_controller ||
695 !keyboard_controller->keyboard_container_initialized()) { 698 !keyboard_controller->keyboard_container_initialized()) {
696 return; 699 return;
697 } 700 }
698 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); 701 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow();
699 if (keyboard_container->GetRootWindow() == GetRootWindow()) { 702 if (keyboard_container->GetRootWindow() == GetRootWindow()) {
700 aura::Window* parent = 703 aura::Window* parent =
701 GetContainer(kShellWindowId_ImeWindowParentContainer); 704 GetContainer(kShellWindowId_ImeWindowParentContainer);
702 DCHECK(parent); 705 DCHECK(parent);
703 parent->RemoveChild(keyboard_container); 706 parent->RemoveChild(keyboard_container);
704 // Virtual keyboard may be deactivated while still showing, notify all 707 // Virtual keyboard may be deactivated while still showing, notify all
705 // observers that keyboard bounds changed to 0 before remove them. 708 // observers that keyboard bounds changed to 0 before remove them.
706 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect()); 709 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect());
707 keyboard_controller->RemoveObserver(shelf_widget()->shelf_layout_manager()); 710 keyboard_controller->RemoveObserver(shelf_widget()->shelf_layout_manager());
708 keyboard_controller->RemoveObserver(panel_layout_manager_); 711 keyboard_controller->RemoveObserver(panel_layout_manager_);
709 keyboard_controller->RemoveObserver(docked_layout_manager_); 712 keyboard_controller->RemoveObserver(docked_layout_manager_);
710 keyboard_controller->RemoveObserver( 713 keyboard_controller->RemoveObserver(
711 workspace_controller_->layout_manager()); 714 workspace_controller()->layout_manager());
712 keyboard_controller->RemoveObserver( 715 keyboard_controller->RemoveObserver(
713 always_on_top_controller_->GetLayoutManager()); 716 always_on_top_controller_->GetLayoutManager());
714 WmShell::Get()->NotifyVirtualKeyboardActivated(false); 717 WmShell::Get()->NotifyVirtualKeyboardActivated(false);
715 } 718 }
716 } 719 }
717 720
718 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { 721 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) {
719 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); 722 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
720 return parent ? parent->Contains(window) : false; 723 return parent ? parent->Contains(window) : false;
721 } 724 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 root_window->GetChildById(kShellWindowId_LockScreenContainer); 809 root_window->GetChildById(kShellWindowId_LockScreenContainer);
807 DCHECK(lock_container); 810 DCHECK(lock_container);
808 lock_container->SetLayoutManager(new LockLayoutManager(lock_container)); 811 lock_container->SetLayoutManager(new LockLayoutManager(lock_container));
809 812
810 aura::Window* lock_modal_container = 813 aura::Window* lock_modal_container =
811 root_window->GetChildById(kShellWindowId_LockSystemModalContainer); 814 root_window->GetChildById(kShellWindowId_LockSystemModalContainer);
812 DCHECK(lock_modal_container); 815 DCHECK(lock_modal_container);
813 lock_modal_container->SetLayoutManager( 816 lock_modal_container->SetLayoutManager(
814 new SystemModalContainerLayoutManager(lock_modal_container)); 817 new SystemModalContainerLayoutManager(lock_modal_container));
815 818
816 WmWindow* default_container =
817 WmWindowAura::Get(GetContainer(kShellWindowId_DefaultContainer));
818 workspace_controller_.reset(new WorkspaceController(default_container));
819
820 WmWindow* always_on_top_container = 819 WmWindow* always_on_top_container =
821 WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer)); 820 WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer));
822 always_on_top_controller_.reset( 821 always_on_top_controller_.reset(
823 new AlwaysOnTopController(always_on_top_container)); 822 new AlwaysOnTopController(always_on_top_container));
824 823
825 // Create the shelf and status area widgets. 824 // Create the shelf and status area widgets.
826 DCHECK(!shelf_widget_.get()); 825 DCHECK(!shelf_widget_.get());
827 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); 826 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer);
828 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); 827 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer);
829 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); 828 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 aura::Window* primary_root_window = Shell::GetInstance() 952 aura::Window* primary_root_window = Shell::GetInstance()
954 ->window_tree_host_manager() 953 ->window_tree_host_manager()
955 ->GetPrimaryRootWindow(); 954 ->GetPrimaryRootWindow();
956 return GetRootWindowSettings(primary_root_window)->controller; 955 return GetRootWindowSettings(primary_root_window)->controller;
957 } 956 }
958 957
959 return GetRootWindowSettings(root_window)->controller; 958 return GetRootWindowSettings(root_window)->controller;
960 } 959 }
961 960
962 } // namespace ash 961 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698