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/ash_constants.h" | 10 #include "ash/ash_constants.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "ash/shell_factory.h" | 26 #include "ash/shell_factory.h" |
| 27 #include "ash/shell_window_ids.h" | 27 #include "ash/shell_window_ids.h" |
| 28 #include "ash/switchable_windows.h" | 28 #include "ash/switchable_windows.h" |
| 29 #include "ash/system/status_area_widget.h" | 29 #include "ash/system/status_area_widget.h" |
| 30 #include "ash/system/tray/system_tray_delegate.h" | 30 #include "ash/system/tray/system_tray_delegate.h" |
| 31 #include "ash/system/tray/system_tray_notifier.h" | 31 #include "ash/system/tray/system_tray_notifier.h" |
| 32 #include "ash/touch/touch_hud_debug.h" | 32 #include "ash/touch/touch_hud_debug.h" |
| 33 #include "ash/touch/touch_hud_projection.h" | 33 #include "ash/touch/touch_hud_projection.h" |
| 34 #include "ash/touch/touch_observer_hud.h" | 34 #include "ash/touch/touch_observer_hud.h" |
| 35 #include "ash/wm/always_on_top_controller.h" | 35 #include "ash/wm/always_on_top_controller.h" |
| 36 #include "ash/wm/common/workspace/workspace_layout_manager_delegate.h" | |
| 36 #include "ash/wm/dock/docked_window_layout_manager.h" | 37 #include "ash/wm/dock/docked_window_layout_manager.h" |
| 37 #include "ash/wm/lock_layout_manager.h" | 38 #include "ash/wm/lock_layout_manager.h" |
| 38 #include "ash/wm/panels/attached_panel_window_targeter.h" | 39 #include "ash/wm/panels/attached_panel_window_targeter.h" |
| 39 #include "ash/wm/panels/panel_layout_manager.h" | 40 #include "ash/wm/panels/panel_layout_manager.h" |
| 40 #include "ash/wm/panels/panel_window_event_handler.h" | 41 #include "ash/wm/panels/panel_window_event_handler.h" |
| 41 #include "ash/wm/root_window_layout_manager.h" | 42 #include "ash/wm/root_window_layout_manager.h" |
| 42 #include "ash/wm/stacking_controller.h" | 43 #include "ash/wm/stacking_controller.h" |
| 43 #include "ash/wm/status_area_layout_manager.h" | 44 #include "ash/wm/status_area_layout_manager.h" |
| 44 #include "ash/wm/system_background_controller.h" | 45 #include "ash/wm/system_background_controller.h" |
| 45 #include "ash/wm/system_modal_container_layout_manager.h" | 46 #include "ash/wm/system_modal_container_layout_manager.h" |
| 46 #include "ash/wm/window_properties.h" | 47 #include "ash/wm/window_properties.h" |
| 47 #include "ash/wm/window_state.h" | 48 #include "ash/wm/window_state.h" |
| 48 #include "ash/wm/window_util.h" | 49 #include "ash/wm/window_util.h" |
| 49 #include "ash/wm/workspace/workspace_layout_manager.h" | 50 #include "ash/wm/workspace/workspace_layout_manager.h" |
| 50 #include "ash/wm/workspace_controller.h" | 51 #include "ash/wm/workspace_controller.h" |
| 51 #include "base/command_line.h" | 52 #include "base/command_line.h" |
| 53 #include "base/memory/ptr_util.h" | |
| 52 #include "base/time/time.h" | 54 #include "base/time/time.h" |
| 53 #include "ui/aura/client/aura_constants.h" | 55 #include "ui/aura/client/aura_constants.h" |
| 54 #include "ui/aura/client/screen_position_client.h" | 56 #include "ui/aura/client/screen_position_client.h" |
| 55 #include "ui/aura/window.h" | 57 #include "ui/aura/window.h" |
| 56 #include "ui/aura/window_delegate.h" | 58 #include "ui/aura/window_delegate.h" |
| 57 #include "ui/aura/window_event_dispatcher.h" | 59 #include "ui/aura/window_event_dispatcher.h" |
| 58 #include "ui/aura/window_observer.h" | 60 #include "ui/aura/window_observer.h" |
| 59 #include "ui/aura/window_tracker.h" | 61 #include "ui/aura/window_tracker.h" |
| 60 #include "ui/base/hit_test.h" | 62 #include "ui/base/hit_test.h" |
| 61 #include "ui/base/models/menu_model.h" | 63 #include "ui/base/models/menu_model.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 void OnWindowDestroying(aura::Window* window) override {} | 255 void OnWindowDestroying(aura::Window* window) override {} |
| 254 void OnWindowDestroyed(aura::Window* window) override { delete this; } | 256 void OnWindowDestroyed(aura::Window* window) override { delete this; } |
| 255 void OnWindowTargetVisibilityChanged(bool visible) override {} | 257 void OnWindowTargetVisibilityChanged(bool visible) override {} |
| 256 bool HasHitTestMask() const override { return false; } | 258 bool HasHitTestMask() const override { return false; } |
| 257 void GetHitTestMask(gfx::Path* mask) const override {} | 259 void GetHitTestMask(gfx::Path* mask) const override {} |
| 258 | 260 |
| 259 private: | 261 private: |
| 260 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); | 262 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); |
| 261 }; | 263 }; |
| 262 | 264 |
| 265 class WorkspaceLayoutManagerDelegateImpl | |
| 266 : public wm::WorkspaceLayoutManagerDelegate { | |
| 267 public: | |
| 268 explicit WorkspaceLayoutManagerDelegateImpl(aura::Window* root_window) | |
| 269 : root_window_(root_window) {} | |
| 270 ~WorkspaceLayoutManagerDelegateImpl() override {} | |
|
oshima
2016/04/14 19:12:55
nit: = defualt;
| |
| 271 | |
| 272 void set_shelf(ShelfLayoutManager* shelf) { shelf_ = shelf; } | |
| 273 | |
| 274 // WorkspaceLayoutManagerDelegate: | |
| 275 void UpdateShelfVisibility() override { | |
| 276 if (shelf_) | |
| 277 shelf_->UpdateVisibilityState(); | |
| 278 } | |
| 279 void OnFullscreenStateChanged(bool is_fullscreen) override { | |
| 280 if (shelf_) { | |
| 281 ash::Shell::GetInstance()->NotifyFullscreenStateChange(is_fullscreen, | |
| 282 root_window_); | |
| 283 } | |
| 284 } | |
| 285 | |
| 286 private: | |
| 287 aura::Window* root_window_; | |
| 288 ShelfLayoutManager* shelf_ = nullptr; | |
| 289 | |
| 290 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerDelegateImpl); | |
| 291 }; | |
| 292 | |
| 263 } // namespace | 293 } // namespace |
| 264 | 294 |
| 265 void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) { | 295 void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) { |
| 266 RootWindowController* controller = new RootWindowController(host); | 296 RootWindowController* controller = new RootWindowController(host); |
| 267 controller->Init(RootWindowController::PRIMARY, | 297 controller->Init(RootWindowController::PRIMARY, |
| 268 Shell::GetInstance()->delegate()->IsFirstRunAfterBoot()); | 298 Shell::GetInstance()->delegate()->IsFirstRunAfterBoot()); |
| 269 } | 299 } |
| 270 | 300 |
| 271 void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) { | 301 void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) { |
| 272 RootWindowController* controller = new RootWindowController(host); | 302 RootWindowController* controller = new RootWindowController(host); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 root_window->RemoveChild(window); | 564 root_window->RemoveChild(window); |
| 535 } | 565 } |
| 536 } | 566 } |
| 537 | 567 |
| 538 shelf_.reset(); | 568 shelf_.reset(); |
| 539 } | 569 } |
| 540 | 570 |
| 541 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 571 void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
| 542 // Forget the shelf early so that shelf don't update itself using wrong | 572 // Forget the shelf early so that shelf don't update itself using wrong |
| 543 // display info. | 573 // display info. |
| 544 workspace_controller_->SetShelf(NULL); | 574 workspace_controller_->SetShelf(nullptr); |
| 575 workspace_controller_->layout_manager()->DeleteDelegate(); | |
| 545 ReparentAllWindows(GetRootWindow(), dst); | 576 ReparentAllWindows(GetRootWindow(), dst); |
| 546 } | 577 } |
| 547 | 578 |
| 548 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 579 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
| 549 return shelf_->shelf_layout_manager(); | 580 return shelf_->shelf_layout_manager(); |
| 550 } | 581 } |
| 551 | 582 |
| 552 SystemTray* RootWindowController::GetSystemTray() { | 583 SystemTray* RootWindowController::GetSystemTray() { |
| 553 // We assume in throughout the code that this will not return NULL. If code | 584 // We assume in throughout the code that this will not return NULL. If code |
| 554 // triggers this for valid reasons, it should test status_area_widget first. | 585 // triggers this for valid reasons, it should test status_area_widget first. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 736 } | 767 } |
| 737 | 768 |
| 738 void RootWindowController::InitLayoutManagers() { | 769 void RootWindowController::InitLayoutManagers() { |
| 739 aura::Window* root_window = GetRootWindow(); | 770 aura::Window* root_window = GetRootWindow(); |
| 740 root_window_layout_ = new RootWindowLayoutManager(root_window); | 771 root_window_layout_ = new RootWindowLayoutManager(root_window); |
| 741 root_window->SetLayoutManager(root_window_layout_); | 772 root_window->SetLayoutManager(root_window_layout_); |
| 742 | 773 |
| 743 aura::Window* default_container = | 774 aura::Window* default_container = |
| 744 GetContainer(kShellWindowId_DefaultContainer); | 775 GetContainer(kShellWindowId_DefaultContainer); |
| 745 // Workspace manager has its own layout managers. | 776 // Workspace manager has its own layout managers. |
| 746 workspace_controller_.reset( | 777 |
| 747 new WorkspaceController(default_container)); | 778 WorkspaceLayoutManagerDelegateImpl* workspace_layout_manager_delegate = |
| 779 new WorkspaceLayoutManagerDelegateImpl(root_window); | |
| 780 workspace_controller_.reset(new WorkspaceController( | |
| 781 default_container, base::WrapUnique(workspace_layout_manager_delegate))); | |
| 748 | 782 |
| 749 aura::Window* always_on_top_container = | 783 aura::Window* always_on_top_container = |
| 750 GetContainer(kShellWindowId_AlwaysOnTopContainer); | 784 GetContainer(kShellWindowId_AlwaysOnTopContainer); |
| 751 always_on_top_controller_.reset( | 785 always_on_top_controller_.reset( |
| 752 new AlwaysOnTopController(always_on_top_container)); | 786 new AlwaysOnTopController(always_on_top_container)); |
| 753 | 787 |
| 754 DCHECK(!shelf_.get()); | 788 DCHECK(!shelf_.get()); |
| 755 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); | 789 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); |
| 756 // TODO(harrym): Remove when status area is view. | 790 // TODO(harrym): Remove when status area is view. |
| 757 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); | 791 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); |
| 758 shelf_.reset(new ShelfWidget( | 792 shelf_.reset(new ShelfWidget( |
| 759 shelf_container, status_container, workspace_controller())); | 793 shelf_container, status_container, workspace_controller())); |
| 794 workspace_layout_manager_delegate->set_shelf(shelf_->shelf_layout_manager()); | |
| 760 | 795 |
| 761 if (!Shell::GetInstance()->session_state_delegate()-> | 796 if (!Shell::GetInstance()->session_state_delegate()-> |
| 762 IsActiveUserSessionStarted()) { | 797 IsActiveUserSessionStarted()) { |
| 763 // This window exists only to be a event target on login screen. | 798 // This window exists only to be a event target on login screen. |
| 764 // It does not have to handle events, nor be visible. | 799 // It does not have to handle events, nor be visible. |
| 765 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); | 800 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); |
| 766 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); | 801 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); |
| 767 | 802 |
| 768 aura::Window* lock_background_container = | 803 aura::Window* lock_background_container = |
| 769 GetContainer(kShellWindowId_LockScreenBackgroundContainer); | 804 GetContainer(kShellWindowId_LockScreenBackgroundContainer); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1047 else | 1082 else |
| 1048 DisableTouchHudProjection(); | 1083 DisableTouchHudProjection(); |
| 1049 } | 1084 } |
| 1050 | 1085 |
| 1051 RootWindowController* GetRootWindowController( | 1086 RootWindowController* GetRootWindowController( |
| 1052 const aura::Window* root_window) { | 1087 const aura::Window* root_window) { |
| 1053 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; | 1088 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
| 1054 } | 1089 } |
| 1055 | 1090 |
| 1056 } // namespace ash | 1091 } // namespace ash |
| OLD | NEW |