| 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_shell_aura.h" | 5 #include "ash/aura/wm_shell_aura.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/aura/key_event_watcher_aura.h" | 9 #include "ash/aura/key_event_watcher_aura.h" |
| 10 #include "ash/aura/pointer_watcher_adapter.h" | 10 #include "ash/aura/pointer_watcher_adapter.h" |
| 11 #include "ash/common/session/session_state_delegate.h" | 11 #include "ash/common/session/session_state_delegate.h" |
| 12 #include "ash/common/shell_delegate.h" | 12 #include "ash/common/shell_delegate.h" |
| 13 #include "ash/common/shell_observer.h" | 13 #include "ash/common/shell_observer.h" |
| 14 #include "ash/common/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard
.h" | 14 #include "ash/common/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard
.h" |
| 15 #include "ash/common/wm/mru_window_tracker.h" | 15 #include "ash/common/wm/mru_window_tracker.h" |
| 16 #include "ash/common/wm/overview/window_selector_controller.h" | 16 #include "ash/common/wm/overview/window_selector_controller.h" |
| 17 #include "ash/common/wm_activation_observer.h" | 17 #include "ash/common/wm_activation_observer.h" |
| 18 #include "ash/common/wm_display_observer.h" | 18 #include "ash/common/wm_display_observer.h" |
| 19 #include "ash/common/wm_window.h" | 19 #include "ash/common/wm_window.h" |
| 20 #include "ash/display/window_tree_host_manager.h" | 20 #include "ash/display/window_tree_host_manager.h" |
| 21 #include "ash/host/ash_window_tree_host_init_params.h" |
| 21 #include "ash/laser/laser_pointer_controller.h" | 22 #include "ash/laser/laser_pointer_controller.h" |
| 22 #include "ash/metrics/task_switch_metrics_recorder.h" | 23 #include "ash/metrics/task_switch_metrics_recorder.h" |
| 23 #include "ash/shared/immersive_fullscreen_controller.h" | 24 #include "ash/shared/immersive_fullscreen_controller.h" |
| 24 #include "ash/shell.h" | 25 #include "ash/shell.h" |
| 25 #include "ash/touch/touch_uma.h" | 26 #include "ash/touch/touch_uma.h" |
| 26 #include "ash/virtual_keyboard_controller.h" | 27 #include "ash/virtual_keyboard_controller.h" |
| 27 #include "ash/wm/drag_window_resizer.h" | 28 #include "ash/wm/drag_window_resizer.h" |
| 28 #include "ash/wm/lock_state_controller.h" | 29 #include "ash/wm/lock_state_controller.h" |
| 29 #include "ash/wm/maximize_mode/maximize_mode_event_handler_aura.h" | 30 #include "ash/wm/maximize_mode/maximize_mode_event_handler_aura.h" |
| 30 #include "ash/wm/screen_pinning_controller.h" | 31 #include "ash/wm/screen_pinning_controller.h" |
| 31 #include "ash/wm/window_cycle_event_filter_aura.h" | 32 #include "ash/wm/window_cycle_event_filter_aura.h" |
| 32 #include "ash/wm/window_util.h" | 33 #include "ash/wm/window_util.h" |
| 33 #include "ash/wm/workspace/workspace_event_handler_aura.h" | 34 #include "ash/wm/workspace/workspace_event_handler_aura.h" |
| 34 #include "base/memory/ptr_util.h" | 35 #include "base/memory/ptr_util.h" |
| 35 #include "ui/aura/client/capture_client.h" | 36 #include "ui/aura/client/capture_client.h" |
| 36 #include "ui/aura/client/focus_client.h" | 37 #include "ui/aura/client/focus_client.h" |
| 37 #include "ui/aura/env.h" | 38 #include "ui/aura/env.h" |
| 38 #include "ui/display/manager/display_manager.h" | 39 #include "ui/display/manager/display_manager.h" |
| 39 #include "ui/wm/public/activation_client.h" | |
| 40 | 40 |
| 41 #if defined(USE_X11) | 41 #if defined(USE_X11) |
| 42 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h" | 42 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h" |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 #if defined(USE_OZONE) | 45 #if defined(USE_OZONE) |
| 46 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.
h" | 46 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.
h" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 namespace ash { | 49 namespace ash { |
| 50 | 50 |
| 51 WmShellAura::WmShellAura(std::unique_ptr<ShellDelegate> shell_delegate) | 51 WmShellAura::WmShellAura(std::unique_ptr<ShellDelegate> shell_delegate) |
| 52 : WmShell(std::move(shell_delegate)) { | 52 : WmShell(std::move(shell_delegate)) { |
| 53 WmShell::Set(this); | 53 WmShell::Set(this); |
| 54 } | 54 } |
| 55 | 55 |
| 56 WmShellAura::~WmShellAura() { | 56 WmShellAura::~WmShellAura() { |
| 57 WmShell::Set(nullptr); | 57 WmShell::Set(nullptr); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void WmShellAura::CreatePointerWatcherAdapter() { | |
| 61 // Must occur after Shell has installed its early pre-target handlers (for | |
| 62 // example, WindowModalityController). | |
| 63 pointer_watcher_adapter_.reset(new PointerWatcherAdapter); | |
| 64 } | |
| 65 | |
| 66 void WmShellAura::Shutdown() { | 60 void WmShellAura::Shutdown() { |
| 67 if (added_activation_observer_) | |
| 68 Shell::GetInstance()->activation_client()->RemoveObserver(this); | |
| 69 | |
| 70 if (added_display_observer_) | 61 if (added_display_observer_) |
| 71 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); | 62 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); |
| 72 | 63 |
| 73 pointer_watcher_adapter_.reset(); | 64 pointer_watcher_adapter_.reset(); |
| 74 | 65 |
| 75 WmShell::Shutdown(); | 66 WmShell::Shutdown(); |
| 67 |
| 68 Shell::GetInstance()->window_tree_host_manager()->Shutdown(); |
| 76 } | 69 } |
| 77 | 70 |
| 78 bool WmShellAura::IsRunningInMash() const { | 71 bool WmShellAura::IsRunningInMash() const { |
| 79 return false; | 72 return false; |
| 80 } | 73 } |
| 81 | 74 |
| 82 WmWindow* WmShellAura::NewWindow(ui::wm::WindowType window_type, | 75 WmWindow* WmShellAura::NewWindow(ui::wm::WindowType window_type, |
| 83 ui::LayerType layer_type) { | 76 ui::LayerType layer_type) { |
| 84 aura::Window* aura_window = new aura::Window(nullptr); | 77 aura::Window* aura_window = new aura::Window(nullptr); |
| 85 aura_window->SetType(window_type); | 78 aura_window->SetType(window_type); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 98 } | 91 } |
| 99 | 92 |
| 100 WmWindow* WmShellAura::GetCaptureWindow() { | 93 WmWindow* WmShellAura::GetCaptureWindow() { |
| 101 // Ash shares capture client among all RootWindowControllers, so we need only | 94 // Ash shares capture client among all RootWindowControllers, so we need only |
| 102 // check the primary root. | 95 // check the primary root. |
| 103 return WmWindow::Get( | 96 return WmWindow::Get( |
| 104 aura::client::GetCaptureWindow(Shell::GetPrimaryRootWindow())); | 97 aura::client::GetCaptureWindow(Shell::GetPrimaryRootWindow())); |
| 105 } | 98 } |
| 106 | 99 |
| 107 WmWindow* WmShellAura::GetPrimaryRootWindow() { | 100 WmWindow* WmShellAura::GetPrimaryRootWindow() { |
| 108 return WmWindow::Get(Shell::GetPrimaryRootWindow()); | 101 return WmWindow::Get( |
| 102 Shell::GetInstance()->window_tree_host_manager()->GetPrimaryRootWindow()); |
| 109 } | 103 } |
| 110 | 104 |
| 111 WmWindow* WmShellAura::GetRootWindowForDisplayId(int64_t display_id) { | 105 WmWindow* WmShellAura::GetRootWindowForDisplayId(int64_t display_id) { |
| 112 return WmWindow::Get(Shell::GetInstance() | 106 return WmWindow::Get(Shell::GetInstance() |
| 113 ->window_tree_host_manager() | 107 ->window_tree_host_manager() |
| 114 ->GetRootWindowForDisplayId(display_id)); | 108 ->GetRootWindowForDisplayId(display_id)); |
| 115 } | 109 } |
| 116 | 110 |
| 117 const display::ManagedDisplayInfo& WmShellAura::GetDisplayInfo( | 111 const display::ManagedDisplayInfo& WmShellAura::GetDisplayInfo( |
| 118 int64_t display_id) const { | 112 int64_t display_id) const { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 159 |
| 166 void WmShellAura::UnlockCursor() { | 160 void WmShellAura::UnlockCursor() { |
| 167 Shell::GetInstance()->cursor_manager()->UnlockCursor(); | 161 Shell::GetInstance()->cursor_manager()->UnlockCursor(); |
| 168 } | 162 } |
| 169 | 163 |
| 170 bool WmShellAura::IsMouseEventsEnabled() { | 164 bool WmShellAura::IsMouseEventsEnabled() { |
| 171 return Shell::GetInstance()->cursor_manager()->IsMouseEventsEnabled(); | 165 return Shell::GetInstance()->cursor_manager()->IsMouseEventsEnabled(); |
| 172 } | 166 } |
| 173 | 167 |
| 174 std::vector<WmWindow*> WmShellAura::GetAllRootWindows() { | 168 std::vector<WmWindow*> WmShellAura::GetAllRootWindows() { |
| 175 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 169 aura::Window::Windows root_windows = |
| 170 Shell::GetInstance()->window_tree_host_manager()->GetAllRootWindows(); |
| 176 std::vector<WmWindow*> wm_windows(root_windows.size()); | 171 std::vector<WmWindow*> wm_windows(root_windows.size()); |
| 177 for (size_t i = 0; i < root_windows.size(); ++i) | 172 for (size_t i = 0; i < root_windows.size(); ++i) |
| 178 wm_windows[i] = WmWindow::Get(root_windows[i]); | 173 wm_windows[i] = WmWindow::Get(root_windows[i]); |
| 179 return wm_windows; | 174 return wm_windows; |
| 180 } | 175 } |
| 181 | 176 |
| 182 void WmShellAura::RecordUserMetricsAction(UserMetricsAction action) { | 177 void WmShellAura::RecordUserMetricsAction(UserMetricsAction action) { |
| 183 Shell::GetInstance()->metrics()->RecordUserMetricsAction(action); | 178 Shell::GetInstance()->metrics()->RecordUserMetricsAction(action); |
| 184 } | 179 } |
| 185 | 180 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 235 |
| 241 void WmShellAura::OnOverviewModeEnded() { | 236 void WmShellAura::OnOverviewModeEnded() { |
| 242 for (auto& observer : *shell_observers()) | 237 for (auto& observer : *shell_observers()) |
| 243 observer.OnOverviewModeEnded(); | 238 observer.OnOverviewModeEnded(); |
| 244 } | 239 } |
| 245 | 240 |
| 246 SessionStateDelegate* WmShellAura::GetSessionStateDelegate() { | 241 SessionStateDelegate* WmShellAura::GetSessionStateDelegate() { |
| 247 return Shell::GetInstance()->session_state_delegate(); | 242 return Shell::GetInstance()->session_state_delegate(); |
| 248 } | 243 } |
| 249 | 244 |
| 250 void WmShellAura::AddActivationObserver(WmActivationObserver* observer) { | |
| 251 if (!added_activation_observer_) { | |
| 252 added_activation_observer_ = true; | |
| 253 Shell::GetInstance()->activation_client()->AddObserver(this); | |
| 254 } | |
| 255 activation_observers_.AddObserver(observer); | |
| 256 } | |
| 257 | |
| 258 void WmShellAura::RemoveActivationObserver(WmActivationObserver* observer) { | |
| 259 activation_observers_.RemoveObserver(observer); | |
| 260 } | |
| 261 | |
| 262 void WmShellAura::AddDisplayObserver(WmDisplayObserver* observer) { | 245 void WmShellAura::AddDisplayObserver(WmDisplayObserver* observer) { |
| 263 if (!added_display_observer_) { | 246 if (!added_display_observer_) { |
| 264 added_display_observer_ = true; | 247 added_display_observer_ = true; |
| 265 Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); | 248 Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); |
| 266 } | 249 } |
| 267 display_observers_.AddObserver(observer); | 250 display_observers_.AddObserver(observer); |
| 268 } | 251 } |
| 269 | 252 |
| 270 void WmShellAura::RemoveDisplayObserver(WmDisplayObserver* observer) { | 253 void WmShellAura::RemoveDisplayObserver(WmDisplayObserver* observer) { |
| 271 display_observers_.RemoveObserver(observer); | 254 display_observers_.RemoveObserver(observer); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 291 void WmShellAura::ToggleIgnoreExternalKeyboard() { | 274 void WmShellAura::ToggleIgnoreExternalKeyboard() { |
| 292 Shell::GetInstance() | 275 Shell::GetInstance() |
| 293 ->virtual_keyboard_controller() | 276 ->virtual_keyboard_controller() |
| 294 ->ToggleIgnoreExternalKeyboard(); | 277 ->ToggleIgnoreExternalKeyboard(); |
| 295 } | 278 } |
| 296 | 279 |
| 297 void WmShellAura::SetLaserPointerEnabled(bool enabled) { | 280 void WmShellAura::SetLaserPointerEnabled(bool enabled) { |
| 298 Shell::GetInstance()->laser_pointer_controller()->SetEnabled(enabled); | 281 Shell::GetInstance()->laser_pointer_controller()->SetEnabled(enabled); |
| 299 } | 282 } |
| 300 | 283 |
| 301 void WmShellAura::OnWindowActivated( | 284 void WmShellAura::CreatePointerWatcherAdapter() { |
| 302 aura::client::ActivationChangeObserver::ActivationReason reason, | 285 pointer_watcher_adapter_ = base::MakeUnique<PointerWatcherAdapter>(); |
| 303 aura::Window* gained_active, | |
| 304 aura::Window* lost_active) { | |
| 305 WmWindow* gained_active_wm = WmWindow::Get(gained_active); | |
| 306 WmWindow* lost_active_wm = WmWindow::Get(lost_active); | |
| 307 if (gained_active_wm) | |
| 308 set_root_window_for_new_windows(gained_active_wm->GetRootWindow()); | |
| 309 for (auto& observer : activation_observers_) | |
| 310 observer.OnWindowActivated(gained_active_wm, lost_active_wm); | |
| 311 } | 286 } |
| 312 | 287 |
| 313 void WmShellAura::OnAttemptToReactivateWindow(aura::Window* request_active, | 288 void WmShellAura::CreatePrimaryHost() { |
| 314 aura::Window* actual_active) { | 289 Shell::GetInstance()->window_tree_host_manager()->Start(); |
| 315 for (auto& observer : activation_observers_) { | 290 AshWindowTreeHostInitParams ash_init_params; |
| 316 observer.OnAttemptToReactivateWindow(WmWindow::Get(request_active), | 291 Shell::GetInstance()->window_tree_host_manager()->CreatePrimaryHost( |
| 317 WmWindow::Get(actual_active)); | 292 ash_init_params); |
| 318 } | 293 } |
| 294 |
| 295 void WmShellAura::InitHosts(const ShellInitParams& init_params) { |
| 296 Shell::GetInstance()->window_tree_host_manager()->InitHosts(); |
| 319 } | 297 } |
| 320 | 298 |
| 321 void WmShellAura::SessionStateChanged(session_manager::SessionState state) { | 299 void WmShellAura::SessionStateChanged(session_manager::SessionState state) { |
| 322 // Create the shelf if necessary. | 300 // Create the shelf if necessary. |
| 323 WmShell::SessionStateChanged(state); | 301 WmShell::SessionStateChanged(state); |
| 324 | 302 |
| 325 // Recreate the keyboard after initial login and after multiprofile login. | 303 // Recreate the keyboard after initial login and after multiprofile login. |
| 326 if (state == session_manager::SessionState::ACTIVE) | 304 if (state == session_manager::SessionState::ACTIVE) |
| 327 Shell::GetInstance()->CreateKeyboard(); | 305 Shell::GetInstance()->CreateKeyboard(); |
| 328 } | 306 } |
| 329 | 307 |
| 330 void WmShellAura::OnDisplayConfigurationChanging() { | 308 void WmShellAura::OnDisplayConfigurationChanging() { |
| 331 for (auto& observer : display_observers_) | 309 for (auto& observer : display_observers_) |
| 332 observer.OnDisplayConfigurationChanging(); | 310 observer.OnDisplayConfigurationChanging(); |
| 333 } | 311 } |
| 334 | 312 |
| 335 void WmShellAura::OnDisplayConfigurationChanged() { | 313 void WmShellAura::OnDisplayConfigurationChanged() { |
| 336 for (auto& observer : display_observers_) | 314 for (auto& observer : display_observers_) |
| 337 observer.OnDisplayConfigurationChanged(); | 315 observer.OnDisplayConfigurationChanged(); |
| 338 } | 316 } |
| 339 | 317 |
| 340 } // namespace ash | 318 } // namespace ash |
| OLD | NEW |