| 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/aura/wm_root_window_controller_aura.h" | 5 #include "ash/aura/wm_root_window_controller_aura.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_shelf_aura.h" | 7 #include "ash/aura/wm_shelf_aura.h" |
| 8 #include "ash/aura/wm_shell_aura.h" | 8 #include "ash/aura/wm_shell_aura.h" |
| 9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
| 10 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" | 10 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" |
| 11 #include "ash/common/wm_root_window_controller_observer.h" | 11 #include "ash/common/wm_root_window_controller_observer.h" |
| 12 #include "ash/display/window_tree_host_manager.h" | 12 #include "ash/display/window_tree_host_manager.h" |
| 13 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
| 14 #include "ash/shelf/shelf.h" | 14 #include "ash/shelf/shelf.h" |
| 15 #include "ash/shelf/shelf_widget.h" | 15 #include "ash/shelf/shelf_widget.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/wm/workspace_controller.h" | 17 #include "ash/wm/workspace_controller.h" |
| 18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_property.h" | 19 #include "ui/aura/window_property.h" |
| 20 |
| 21 #include "ui/aura/window_tree_host.h" |
| 22 #include "ui/display/screen.h" |
| 23 |
| 20 #include "ui/events/event_targeter.h" | 24 #include "ui/events/event_targeter.h" |
| 21 #include "ui/events/event_utils.h" | 25 #include "ui/events/event_utils.h" |
| 22 | 26 |
| 23 DECLARE_WINDOW_PROPERTY_TYPE(ash::WmRootWindowControllerAura*); | 27 DECLARE_WINDOW_PROPERTY_TYPE(ash::WmRootWindowControllerAura*); |
| 24 | 28 |
| 25 namespace ash { | 29 namespace ash { |
| 26 | 30 |
| 27 // TODO(sky): it likely makes more sense to hang this off RootWindowSettings. | 31 // TODO(sky): it likely makes more sense to hang this off RootWindowSettings. |
| 28 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::WmRootWindowControllerAura, | 32 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::WmRootWindowControllerAura, |
| 29 kWmRootWindowControllerKey, | 33 kWmRootWindowControllerKey, |
| 30 nullptr); | 34 nullptr); |
| 31 | 35 |
| 32 WmRootWindowControllerAura::WmRootWindowControllerAura( | 36 WmRootWindowControllerAura::WmRootWindowControllerAura( |
| 33 RootWindowController* root_window_controller) | 37 RootWindowController* root_window_controller) |
| 34 : root_window_controller_(root_window_controller) { | 38 : root_window_controller_(root_window_controller) { |
| 35 root_window_controller_->GetRootWindow()->SetProperty( | 39 root_window_controller_->GetRootWindow()->SetProperty( |
| 36 kWmRootWindowControllerKey, this); | 40 kWmRootWindowControllerKey, this); |
| 37 WmShell::Get()->AddShellObserver(this); | 41 WmShell::Get()->AddShellObserver(this); |
| 42 display::Screen::GetScreen()->AddObserver(this); |
| 38 } | 43 } |
| 39 | 44 |
| 40 WmRootWindowControllerAura::~WmRootWindowControllerAura() { | 45 WmRootWindowControllerAura::~WmRootWindowControllerAura() { |
| 41 WmShell::Get()->RemoveShellObserver(this); | 46 WmShell::Get()->RemoveShellObserver(this); |
| 47 display::Screen::GetScreen()->RemoveObserver(this); |
| 42 } | 48 } |
| 43 | 49 |
| 44 // static | 50 // static |
| 45 const WmRootWindowControllerAura* WmRootWindowControllerAura::Get( | 51 const WmRootWindowControllerAura* WmRootWindowControllerAura::Get( |
| 46 const aura::Window* window) { | 52 const aura::Window* window) { |
| 47 if (!window) | 53 if (!window) |
| 48 return nullptr; | 54 return nullptr; |
| 49 | 55 |
| 50 RootWindowController* root_window_controller = | 56 RootWindowController* root_window_controller = |
| 51 GetRootWindowController(window); | 57 GetRootWindowController(window); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void WmRootWindowControllerAura::AddObserver( | 123 void WmRootWindowControllerAura::AddObserver( |
| 118 WmRootWindowControllerObserver* observer) { | 124 WmRootWindowControllerObserver* observer) { |
| 119 observers_.AddObserver(observer); | 125 observers_.AddObserver(observer); |
| 120 } | 126 } |
| 121 | 127 |
| 122 void WmRootWindowControllerAura::RemoveObserver( | 128 void WmRootWindowControllerAura::RemoveObserver( |
| 123 WmRootWindowControllerObserver* observer) { | 129 WmRootWindowControllerObserver* observer) { |
| 124 observers_.RemoveObserver(observer); | 130 observers_.RemoveObserver(observer); |
| 125 } | 131 } |
| 126 | 132 |
| 127 void WmRootWindowControllerAura::OnDisplayWorkAreaInsetsChanged() { | |
| 128 FOR_EACH_OBSERVER(WmRootWindowControllerObserver, observers_, | |
| 129 OnWorkAreaChanged()); | |
| 130 } | |
| 131 | |
| 132 void WmRootWindowControllerAura::OnFullscreenStateChanged( | 133 void WmRootWindowControllerAura::OnFullscreenStateChanged( |
| 133 bool is_fullscreen, | 134 bool is_fullscreen, |
| 134 WmWindow* root_window) { | 135 WmWindow* root_window) { |
| 135 if (WmWindowAura::GetAuraWindow(root_window) != | 136 if (WmWindowAura::GetAuraWindow(root_window) != |
| 136 root_window_controller_->GetRootWindow()) | 137 root_window_controller_->GetRootWindow()) |
| 137 return; | 138 return; |
| 138 | 139 |
| 139 FOR_EACH_OBSERVER(WmRootWindowControllerObserver, observers_, | 140 FOR_EACH_OBSERVER(WmRootWindowControllerObserver, observers_, |
| 140 OnFullscreenStateChanged(is_fullscreen)); | 141 OnFullscreenStateChanged(is_fullscreen)); |
| 141 } | 142 } |
| 142 | 143 |
| 143 void WmRootWindowControllerAura::OnShelfAlignmentChanged( | 144 void WmRootWindowControllerAura::OnShelfAlignmentChanged( |
| 144 WmWindow* root_window) { | 145 WmWindow* root_window) { |
| 145 if (WmWindowAura::GetAuraWindow(root_window) != | 146 if (WmWindowAura::GetAuraWindow(root_window) != |
| 146 root_window_controller_->GetRootWindow()) | 147 root_window_controller_->GetRootWindow()) |
| 147 return; | 148 return; |
| 148 | 149 |
| 149 FOR_EACH_OBSERVER(WmRootWindowControllerObserver, observers_, | 150 FOR_EACH_OBSERVER(WmRootWindowControllerObserver, observers_, |
| 150 OnShelfAlignmentChanged()); | 151 OnShelfAlignmentChanged()); |
| 151 } | 152 } |
| 152 | 153 |
| 154 void WmRootWindowControllerAura::OnDisplayAdded( |
| 155 const display::Display& display) {} |
| 156 |
| 157 void WmRootWindowControllerAura::OnDisplayRemoved( |
| 158 const display::Display& display) {} |
| 159 |
| 160 void WmRootWindowControllerAura::OnDisplayMetricsChanged( |
| 161 const display::Display& display, |
| 162 uint32_t metrics) { |
| 163 FOR_EACH_OBSERVER(WmRootWindowControllerObserver, observers_, |
| 164 OnWorkAreaChanged()); |
| 165 } |
| 166 |
| 153 } // namespace ash | 167 } // namespace ash |
| OLD | NEW |