| 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 12 matching lines...) Expand all Loading... |
| 23 #include "ash/common/system/tray/system_tray_delegate.h" | 23 #include "ash/common/system/tray/system_tray_delegate.h" |
| 24 #include "ash/common/wm/always_on_top_controller.h" | 24 #include "ash/common/wm/always_on_top_controller.h" |
| 25 #include "ash/common/wm/container_finder.h" | 25 #include "ash/common/wm/container_finder.h" |
| 26 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 26 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 27 #include "ash/common/wm/fullscreen_window_finder.h" | 27 #include "ash/common/wm/fullscreen_window_finder.h" |
| 28 #include "ash/common/wm/panels/panel_layout_manager.h" | 28 #include "ash/common/wm/panels/panel_layout_manager.h" |
| 29 #include "ash/common/wm/root_window_layout_manager.h" | 29 #include "ash/common/wm/root_window_layout_manager.h" |
| 30 #include "ash/common/wm/switchable_windows.h" | 30 #include "ash/common/wm/switchable_windows.h" |
| 31 #include "ash/common/wm/window_state.h" | 31 #include "ash/common/wm/window_state.h" |
| 32 #include "ash/common/wm/workspace/workspace_layout_manager.h" | 32 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| 33 #include "ash/common/wm/workspace/workspace_layout_manager_delegate.h" | |
| 34 #include "ash/common/wm_shell.h" | 33 #include "ash/common/wm_shell.h" |
| 35 #include "ash/common/wm_window.h" | 34 #include "ash/common/wm_window.h" |
| 36 #include "ash/desktop_background/desktop_background_widget_controller.h" | 35 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| 37 #include "ash/desktop_background/user_wallpaper_delegate.h" | 36 #include "ash/desktop_background/user_wallpaper_delegate.h" |
| 38 #include "ash/display/display_manager.h" | 37 #include "ash/display/display_manager.h" |
| 39 #include "ash/high_contrast/high_contrast_controller.h" | 38 #include "ash/high_contrast/high_contrast_controller.h" |
| 40 #include "ash/host/ash_window_tree_host.h" | 39 #include "ash/host/ash_window_tree_host.h" |
| 41 #include "ash/root_window_settings.h" | 40 #include "ash/root_window_settings.h" |
| 42 #include "ash/shelf/shelf.h" | 41 #include "ash/shelf/shelf.h" |
| 43 #include "ash/shelf/shelf_layout_manager.h" | 42 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 void OnWindowDestroying(aura::Window* window) override {} | 273 void OnWindowDestroying(aura::Window* window) override {} |
| 275 void OnWindowDestroyed(aura::Window* window) override { delete this; } | 274 void OnWindowDestroyed(aura::Window* window) override { delete this; } |
| 276 void OnWindowTargetVisibilityChanged(bool visible) override {} | 275 void OnWindowTargetVisibilityChanged(bool visible) override {} |
| 277 bool HasHitTestMask() const override { return false; } | 276 bool HasHitTestMask() const override { return false; } |
| 278 void GetHitTestMask(gfx::Path* mask) const override {} | 277 void GetHitTestMask(gfx::Path* mask) const override {} |
| 279 | 278 |
| 280 private: | 279 private: |
| 281 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); | 280 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); |
| 282 }; | 281 }; |
| 283 | 282 |
| 284 class WorkspaceLayoutManagerDelegateImpl | |
| 285 : public wm::WorkspaceLayoutManagerDelegate { | |
| 286 public: | |
| 287 explicit WorkspaceLayoutManagerDelegateImpl(aura::Window* root_window) | |
| 288 : root_window_(root_window) {} | |
| 289 ~WorkspaceLayoutManagerDelegateImpl() override = default; | |
| 290 | |
| 291 void set_shelf(ShelfLayoutManager* shelf) { shelf_ = shelf; } | |
| 292 | |
| 293 // WorkspaceLayoutManagerDelegate: | |
| 294 void UpdateShelfVisibility() override { | |
| 295 if (shelf_) | |
| 296 shelf_->UpdateVisibilityState(); | |
| 297 } | |
| 298 void OnFullscreenStateChanged(bool is_fullscreen) override { | |
| 299 if (shelf_) { | |
| 300 Shell::GetInstance()->NotifyFullscreenStateChange( | |
| 301 is_fullscreen, WmWindowAura::Get(root_window_)); | |
| 302 } | |
| 303 } | |
| 304 | |
| 305 private: | |
| 306 aura::Window* root_window_; | |
| 307 ShelfLayoutManager* shelf_ = nullptr; | |
| 308 | |
| 309 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerDelegateImpl); | |
| 310 }; | |
| 311 | |
| 312 } // namespace | 283 } // namespace |
| 313 | 284 |
| 314 void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) { | 285 void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) { |
| 315 RootWindowController* controller = new RootWindowController(host); | 286 RootWindowController* controller = new RootWindowController(host); |
| 316 controller->Init(RootWindowController::PRIMARY, | 287 controller->Init(RootWindowController::PRIMARY, |
| 317 WmShell::Get()->delegate()->IsFirstRunAfterBoot()); | 288 WmShell::Get()->delegate()->IsFirstRunAfterBoot()); |
| 318 } | 289 } |
| 319 | 290 |
| 320 void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) { | 291 void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) { |
| 321 RootWindowController* controller = new RootWindowController(host); | 292 RootWindowController* controller = new RootWindowController(host); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 delete window; | 604 delete window; |
| 634 } else { | 605 } else { |
| 635 root_window->RemoveChild(window); | 606 root_window->RemoveChild(window); |
| 636 } | 607 } |
| 637 } | 608 } |
| 638 | 609 |
| 639 shelf_widget_.reset(); | 610 shelf_widget_.reset(); |
| 640 } | 611 } |
| 641 | 612 |
| 642 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 613 void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
| 643 // Forget the shelf early so that shelf don't update itself using wrong | 614 // Clear the shelf first, so it doesn't update itself with wrong display info. |
| 644 // display info. | |
| 645 workspace_controller_->SetShelf(nullptr); | 615 workspace_controller_->SetShelf(nullptr); |
| 646 workspace_controller_->layout_manager()->DeleteDelegate(); | |
| 647 ReparentAllWindows(GetRootWindow(), dst); | 616 ReparentAllWindows(GetRootWindow(), dst); |
| 648 } | 617 } |
| 649 | 618 |
| 650 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 619 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
| 651 return shelf_widget_->shelf_layout_manager(); | 620 return shelf_widget_->shelf_layout_manager(); |
| 652 } | 621 } |
| 653 | 622 |
| 654 SystemTray* RootWindowController::GetSystemTray() { | 623 SystemTray* RootWindowController::GetSystemTray() { |
| 655 // We assume in throughout the code that this will not return NULL. If code | 624 // We assume in throughout the code that this will not return NULL. If code |
| 656 // triggers this for valid reasons, it should test status_area_widget first. | 625 // triggers this for valid reasons, it should test status_area_widget first. |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 root_window->GetChildById(kShellWindowId_LockScreenContainer); | 804 root_window->GetChildById(kShellWindowId_LockScreenContainer); |
| 836 DCHECK(lock_container); | 805 DCHECK(lock_container); |
| 837 lock_container->SetLayoutManager(new LockLayoutManager(lock_container)); | 806 lock_container->SetLayoutManager(new LockLayoutManager(lock_container)); |
| 838 | 807 |
| 839 aura::Window* lock_modal_container = | 808 aura::Window* lock_modal_container = |
| 840 root_window->GetChildById(kShellWindowId_LockSystemModalContainer); | 809 root_window->GetChildById(kShellWindowId_LockSystemModalContainer); |
| 841 DCHECK(lock_modal_container); | 810 DCHECK(lock_modal_container); |
| 842 lock_modal_container->SetLayoutManager( | 811 lock_modal_container->SetLayoutManager( |
| 843 new SystemModalContainerLayoutManager(lock_modal_container)); | 812 new SystemModalContainerLayoutManager(lock_modal_container)); |
| 844 | 813 |
| 845 WorkspaceLayoutManagerDelegateImpl* workspace_layout_manager_delegate = | 814 workspace_controller_.reset(new WorkspaceController(default_container)); |
| 846 new WorkspaceLayoutManagerDelegateImpl(root_window); | |
| 847 workspace_controller_.reset(new WorkspaceController( | |
| 848 default_container, base::WrapUnique(workspace_layout_manager_delegate))); | |
| 849 | 815 |
| 850 WmWindow* always_on_top_container = | 816 WmWindow* always_on_top_container = |
| 851 WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer)); | 817 WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer)); |
| 852 always_on_top_controller_.reset( | 818 always_on_top_controller_.reset( |
| 853 new AlwaysOnTopController(always_on_top_container)); | 819 new AlwaysOnTopController(always_on_top_container)); |
| 854 | 820 |
| 855 // Create the shelf and status area widgets. | 821 // Create the shelf and status area widgets. |
| 856 DCHECK(!shelf_widget_.get()); | 822 DCHECK(!shelf_widget_.get()); |
| 857 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); | 823 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); |
| 858 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); | 824 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); |
| 859 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); | 825 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); |
| 860 WmWindow* wm_status_container = WmWindowAura::Get(status_container); | 826 WmWindow* wm_status_container = WmWindowAura::Get(status_container); |
| 861 shelf_widget_.reset(new ShelfWidget(wm_shelf_container, wm_status_container, | 827 shelf_widget_.reset(new ShelfWidget(wm_shelf_container, wm_status_container, |
| 862 wm_shelf_aura_.get(), | 828 wm_shelf_aura_.get(), |
| 863 workspace_controller())); | 829 workspace_controller())); |
| 864 // Make it easier to resize windows that partially overlap the shelf. Must | 830 // Make it easier to resize windows that partially overlap the shelf. Must |
| 865 // occur after the ShelfLayoutManager is constructed by ShelfWidget. | 831 // occur after the ShelfLayoutManager is constructed by ShelfWidget. |
| 866 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( | 832 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( |
| 867 wm_shelf_container, wm_shelf_aura_.get())); | 833 wm_shelf_container, wm_shelf_aura_.get())); |
| 868 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( | 834 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( |
| 869 wm_status_container, wm_shelf_aura_.get())); | 835 wm_status_container, wm_shelf_aura_.get())); |
| 870 | 836 |
| 871 workspace_layout_manager_delegate->set_shelf( | |
| 872 shelf_widget_->shelf_layout_manager()); | |
| 873 | |
| 874 if (!WmShell::Get() | 837 if (!WmShell::Get() |
| 875 ->GetSessionStateDelegate() | 838 ->GetSessionStateDelegate() |
| 876 ->IsActiveUserSessionStarted()) { | 839 ->IsActiveUserSessionStarted()) { |
| 877 // This window exists only to be a event target on login screen. | 840 // This window exists only to be a event target on login screen. |
| 878 // It does not have to handle events, nor be visible. | 841 // It does not have to handle events, nor be visible. |
| 879 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); | 842 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); |
| 880 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); | 843 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); |
| 881 | 844 |
| 882 aura::Window* lock_background_container = | 845 aura::Window* lock_background_container = |
| 883 GetContainer(kShellWindowId_LockScreenBackgroundContainer); | 846 GetContainer(kShellWindowId_LockScreenBackgroundContainer); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 aura::Window* primary_root_window = Shell::GetInstance() | 951 aura::Window* primary_root_window = Shell::GetInstance() |
| 989 ->window_tree_host_manager() | 952 ->window_tree_host_manager() |
| 990 ->GetPrimaryRootWindow(); | 953 ->GetPrimaryRootWindow(); |
| 991 return GetRootWindowSettings(primary_root_window)->controller; | 954 return GetRootWindowSettings(primary_root_window)->controller; |
| 992 } | 955 } |
| 993 | 956 |
| 994 return GetRootWindowSettings(root_window)->controller; | 957 return GetRootWindowSettings(root_window)->controller; |
| 995 } | 958 } |
| 996 | 959 |
| 997 } // namespace ash | 960 } // namespace ash |
| OLD | NEW |