| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/wm/aura/wm_root_window_controller_aura.h" | 5 #include "ash/wm/aura/wm_root_window_controller_aura.h" |
| 6 | 6 |
| 7 #include "ash/display/window_tree_host_manager.h" | 7 #include "ash/display/window_tree_host_manager.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/aura/wm_globals_aura.h" | 10 #include "ash/wm/aura/wm_globals_aura.h" |
| 11 #include "ash/wm/aura/wm_window_aura.h" | 11 #include "ash/wm/aura/wm_window_aura.h" |
| 12 #include "ash/wm/common/wm_root_window_controller_observer.h" |
| 12 #include "ash/wm/workspace_controller.h" | 13 #include "ash/wm/workspace_controller.h" |
| 13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 14 #include "ui/aura/window_property.h" | 15 #include "ui/aura/window_property.h" |
| 15 | 16 |
| 16 DECLARE_WINDOW_PROPERTY_TYPE(ash::wm::WmRootWindowControllerAura*); | 17 DECLARE_WINDOW_PROPERTY_TYPE(ash::wm::WmRootWindowControllerAura*); |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 namespace wm { | 20 namespace wm { |
| 20 | 21 |
| 21 // TODO(sky): it likely makes more sense to hang this off RootWindowSettings. | 22 // TODO(sky): it likely makes more sense to hang this off RootWindowSettings. |
| 22 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::wm::WmRootWindowControllerAura, | 23 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::wm::WmRootWindowControllerAura, |
| 23 kWmRootWindowControllerKey, | 24 kWmRootWindowControllerKey, |
| 24 nullptr); | 25 nullptr); |
| 25 | 26 |
| 26 // static | 27 // static |
| 27 WmRootWindowController* WmRootWindowController::GetWithDisplayId(int64_t id) { | 28 WmRootWindowController* WmRootWindowController::GetWithDisplayId(int64_t id) { |
| 28 return WmRootWindowControllerAura::Get(Shell::GetInstance() | 29 return WmRootWindowControllerAura::Get(Shell::GetInstance() |
| 29 ->window_tree_host_manager() | 30 ->window_tree_host_manager() |
| 30 ->GetRootWindowForDisplayId(id)); | 31 ->GetRootWindowForDisplayId(id)); |
| 31 } | 32 } |
| 32 | 33 |
| 33 WmRootWindowControllerAura::WmRootWindowControllerAura( | 34 WmRootWindowControllerAura::WmRootWindowControllerAura( |
| 34 RootWindowController* root_window_controller) | 35 RootWindowController* root_window_controller) |
| 35 : root_window_controller_(root_window_controller) { | 36 : root_window_controller_(root_window_controller) { |
| 36 root_window_controller_->GetRootWindow()->SetProperty( | 37 root_window_controller_->GetRootWindow()->SetProperty( |
| 37 kWmRootWindowControllerKey, this); | 38 kWmRootWindowControllerKey, this); |
| 39 Shell::GetInstance()->AddShellObserver(this); |
| 38 } | 40 } |
| 39 | 41 |
| 40 WmRootWindowControllerAura::~WmRootWindowControllerAura() {} | 42 WmRootWindowControllerAura::~WmRootWindowControllerAura() { |
| 43 Shell::GetInstance()->RemoveShellObserver(this); |
| 44 } |
| 41 | 45 |
| 42 // static | 46 // static |
| 43 const WmRootWindowControllerAura* WmRootWindowControllerAura::Get( | 47 const WmRootWindowControllerAura* WmRootWindowControllerAura::Get( |
| 44 const aura::Window* window) { | 48 const aura::Window* window) { |
| 45 if (!window) | 49 if (!window) |
| 46 return nullptr; | 50 return nullptr; |
| 47 | 51 |
| 48 RootWindowController* root_window_controller = | 52 RootWindowController* root_window_controller = |
| 49 GetRootWindowController(window); | 53 GetRootWindowController(window); |
| 50 if (!root_window_controller) | 54 if (!root_window_controller) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 76 return WmWindowAura::Get(root_window_controller_->GetRootWindow()); | 80 return WmWindowAura::Get(root_window_controller_->GetRootWindow()); |
| 77 } | 81 } |
| 78 | 82 |
| 79 void WmRootWindowControllerAura::ConfigureWidgetInitParamsForContainer( | 83 void WmRootWindowControllerAura::ConfigureWidgetInitParamsForContainer( |
| 80 views::Widget* widget, | 84 views::Widget* widget, |
| 81 int shell_container_id, | 85 int shell_container_id, |
| 82 views::Widget::InitParams* init_params) { | 86 views::Widget::InitParams* init_params) { |
| 83 init_params->parent = Shell::GetContainer( | 87 init_params->parent = Shell::GetContainer( |
| 84 root_window_controller_->GetRootWindow(), shell_container_id); | 88 root_window_controller_->GetRootWindow(), shell_container_id); |
| 85 } | 89 } |
| 90 |
| 91 void WmRootWindowControllerAura::AddObserver( |
| 92 WmRootWindowControllerObserver* observer) { |
| 93 observers_.AddObserver(observer); |
| 94 } |
| 95 |
| 96 void WmRootWindowControllerAura::RemoveObserver( |
| 97 WmRootWindowControllerObserver* observer) { |
| 98 observers_.RemoveObserver(observer); |
| 99 } |
| 100 |
| 101 void WmRootWindowControllerAura::OnDisplayWorkAreaInsetsChanged() { |
| 102 FOR_EACH_OBSERVER(WmRootWindowControllerObserver, observers_, |
| 103 OnWorkAreaChanged()); |
| 104 } |
| 105 |
| 106 void WmRootWindowControllerAura::OnFullscreenStateChanged( |
| 107 bool is_fullscreen, |
| 108 aura::Window* root_window) { |
| 109 if (root_window != root_window_controller_->GetRootWindow()) |
| 110 return; |
| 111 |
| 112 FOR_EACH_OBSERVER(WmRootWindowControllerObserver, observers_, |
| 113 OnFullscreenStateChanged(is_fullscreen)); |
| 114 } |
| 115 |
| 116 void WmRootWindowControllerAura::OnShelfAlignmentChanged( |
| 117 aura::Window* root_window) { |
| 118 if (root_window != root_window_controller_->GetRootWindow()) |
| 119 return; |
| 120 |
| 121 FOR_EACH_OBSERVER(WmRootWindowControllerObserver, observers_, |
| 122 OnShelfAlignmentChanged()); |
| 123 } |
| 124 |
| 86 } // namespace wm | 125 } // namespace wm |
| 87 } // namespace ash | 126 } // namespace ash |
| OLD | NEW |