Chromium Code Reviews| 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 "components/exo/wm_helper_ash.h" | 5 #include "components/exo/wm_helper_ash.h" |
| 6 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/public/cpp/config.h" | 8 #include "ash/public/cpp/config.h" |
| 9 #include "ash/root_window_controller.h" | |
| 9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 10 #include "ash/system/tray/system_tray_notifier.h" | 11 #include "ash/system/tray/system_tray_notifier.h" |
| 12 #include "ash/wm/ash_native_cursor_manager.h" | |
| 11 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 12 #include "ash/wm_shell.h" | 14 #include "ash/wm_shell.h" |
| 13 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 14 #include "ui/aura/client/focus_client.h" | 16 #include "ui/aura/client/focus_client.h" |
| 15 #include "ui/display/manager/display_manager.h" | 17 #include "ui/display/manager/display_manager.h" |
| 16 #include "ui/events/devices/device_data_manager.h" | 18 #include "ui/events/devices/device_data_manager.h" |
| 17 #include "ui/wm/public/activation_client.h" | 19 #include "ui/wm/public/activation_client.h" |
| 18 | 20 |
| 19 namespace exo { | 21 namespace exo { |
| 20 | 22 |
| 21 //////////////////////////////////////////////////////////////////////////////// | 23 //////////////////////////////////////////////////////////////////////////////// |
| 22 // WMHelperAsh, public: | 24 // WMHelperAsh, public: |
| 23 | 25 |
| 24 WMHelperAsh::WMHelperAsh() { | 26 WMHelperAsh::WMHelperAsh() { |
| 25 ash::Shell::Get()->AddShellObserver(this); | 27 ash::Shell::Get()->AddShellObserver(this); |
| 26 ash::Shell::Get()->activation_client()->AddObserver(this); | 28 ash::Shell::Get()->activation_client()->AddObserver(this); |
| 27 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. | 29 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. |
| 28 if (ash::WmShell::Get()->GetAshConfig() != ash::Config::MUS) | 30 if (ash::WmShell::Get()->GetAshConfig() != ash::Config::MUS) { |
| 29 ash::Shell::Get()->cursor_manager()->AddObserver(this); | 31 ash::Shell::Get()->cursor_manager()->AddObserver(this); |
| 32 ash::Shell::Get()->native_cursor_manager()->AddObserver(this); | |
| 33 } | |
| 30 ash::WmShell::Get()->AddDisplayObserver(this); | 34 ash::WmShell::Get()->AddDisplayObserver(this); |
| 31 aura::client::FocusClient* focus_client = | 35 aura::client::FocusClient* focus_client = |
| 32 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); | 36 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); |
| 33 focus_client->AddObserver(this); | 37 focus_client->AddObserver(this); |
| 34 // TODO(crbug.com/709225): Mushrome doesn't have a DeviceDataManager. | 38 // TODO(crbug.com/709225): Mushrome doesn't have a DeviceDataManager. |
| 35 if (ash::WmShell::Get()->GetAshConfig() != ash::Config::MUS) | 39 if (ash::WmShell::Get()->GetAshConfig() != ash::Config::MUS) |
| 36 ui::DeviceDataManager::GetInstance()->AddObserver(this); | 40 ui::DeviceDataManager::GetInstance()->AddObserver(this); |
| 37 ash::Shell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); | 41 ash::Shell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); |
| 38 } | 42 } |
| 39 | 43 |
| 40 WMHelperAsh::~WMHelperAsh() { | 44 WMHelperAsh::~WMHelperAsh() { |
| 41 if (!ash::Shell::HasInstance()) | 45 if (!ash::Shell::HasInstance()) |
| 42 return; | 46 return; |
| 43 aura::client::FocusClient* focus_client = | 47 aura::client::FocusClient* focus_client = |
| 44 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); | 48 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); |
| 45 focus_client->RemoveObserver(this); | 49 focus_client->RemoveObserver(this); |
| 46 ash::WmShell::Get()->RemoveDisplayObserver(this); | 50 ash::WmShell::Get()->RemoveDisplayObserver(this); |
| 47 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. | 51 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. |
| 48 if (ash::WmShell::Get()->GetAshConfig() != ash::Config::MUS) | 52 if (ash::WmShell::Get()->GetAshConfig() != ash::Config::MUS) { |
| 49 ash::Shell::Get()->cursor_manager()->RemoveObserver(this); | 53 ash::Shell::Get()->cursor_manager()->RemoveObserver(this); |
| 54 ash::Shell::Get()->native_cursor_manager()->RemoveObserver(this); | |
| 55 } | |
| 50 ash::Shell::Get()->activation_client()->RemoveObserver(this); | 56 ash::Shell::Get()->activation_client()->RemoveObserver(this); |
| 51 ash::Shell::Get()->RemoveShellObserver(this); | 57 ash::Shell::Get()->RemoveShellObserver(this); |
| 52 // TODO(crbug.com/709225): Mushrome doesn't have a DeviceDataManager. | 58 // TODO(crbug.com/709225): Mushrome doesn't have a DeviceDataManager. |
| 53 if (ash::WmShell::Get()->GetAshConfig() != ash::Config::MUS) | 59 if (ash::WmShell::Get()->GetAshConfig() != ash::Config::MUS) |
| 54 ui::DeviceDataManager::GetInstance()->RemoveObserver(this); | 60 ui::DeviceDataManager::GetInstance()->RemoveObserver(this); |
| 55 ash::Shell::Get()->system_tray_notifier()->RemoveAccessibilityObserver(this); | 61 ash::Shell::Get()->system_tray_notifier()->RemoveAccessibilityObserver(this); |
| 56 } | 62 } |
| 57 | 63 |
| 58 //////////////////////////////////////////////////////////////////////////////// | 64 //////////////////////////////////////////////////////////////////////////////// |
| 59 // WMHelperAsh, private: | 65 // WMHelperAsh, private: |
| 60 | 66 |
| 61 const display::ManagedDisplayInfo WMHelperAsh::GetDisplayInfo( | 67 const display::ManagedDisplayInfo WMHelperAsh::GetDisplayInfo( |
| 62 int64_t display_id) const { | 68 int64_t display_id) const { |
| 63 return ash::Shell::Get()->display_manager()->GetDisplayInfo(display_id); | 69 return ash::Shell::Get()->display_manager()->GetDisplayInfo(display_id); |
| 64 } | 70 } |
| 65 | 71 |
| 66 aura::Window* WMHelperAsh::GetContainer(int container_id) { | 72 aura::Window* WMHelperAsh::GetContainer(int64_t display_id, int container_id) { |
| 67 return ash::Shell::GetContainer(ash::Shell::GetRootWindowForNewWindows(), | 73 ash::RootWindowController* controller = |
| 68 container_id); | 74 ash::Shell::GetRootWindowControllerWithDisplayId(display_id); |
| 75 return ash::Shell::GetContainer( | |
| 76 controller ? controller->GetRootWindow() | |
|
reveman
2017/04/10 21:47:13
when is controller null?
Dominik Laskowski
2017/04/11 04:42:55
When a display with |display_id| does not exist.
reveman
2017/04/11 19:25:13
and why does it need to be valid behavior to call
Dominik Laskowski
2017/04/11 20:40:37
To retain the old behavior as an option, but YAGNI
| |
| 77 : ash::Shell::GetRootWindowForNewWindows(), | |
| 78 container_id); | |
| 69 } | 79 } |
| 70 | 80 |
| 71 aura::Window* WMHelperAsh::GetActiveWindow() const { | 81 aura::Window* WMHelperAsh::GetActiveWindow() const { |
| 72 return ash::Shell::Get()->activation_client()->GetActiveWindow(); | 82 return ash::Shell::Get()->activation_client()->GetActiveWindow(); |
| 73 } | 83 } |
| 74 | 84 |
| 75 aura::Window* WMHelperAsh::GetFocusedWindow() const { | 85 aura::Window* WMHelperAsh::GetFocusedWindow() const { |
| 76 aura::client::FocusClient* focus_client = | 86 aura::client::FocusClient* focus_client = |
| 77 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); | 87 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); |
| 78 return focus_client->GetFocusedWindow(); | 88 return focus_client->GetFocusedWindow(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 } | 142 } |
| 133 | 143 |
| 134 void WMHelperAsh::OnCursorVisibilityChanged(bool is_visible) { | 144 void WMHelperAsh::OnCursorVisibilityChanged(bool is_visible) { |
| 135 NotifyCursorVisibilityChanged(is_visible); | 145 NotifyCursorVisibilityChanged(is_visible); |
| 136 } | 146 } |
| 137 | 147 |
| 138 void WMHelperAsh::OnCursorSetChanged(ui::CursorSetType cursor_set) { | 148 void WMHelperAsh::OnCursorSetChanged(ui::CursorSetType cursor_set) { |
| 139 NotifyCursorSetChanged(cursor_set); | 149 NotifyCursorSetChanged(cursor_set); |
| 140 } | 150 } |
| 141 | 151 |
| 152 void WMHelperAsh::OnCursorDisplayChanging(const display::Display& display) { | |
| 153 NotifyCursorDisplayChanging(display); | |
| 154 } | |
| 155 | |
| 142 void WMHelperAsh::OnAccessibilityModeChanged( | 156 void WMHelperAsh::OnAccessibilityModeChanged( |
| 143 ash::AccessibilityNotificationVisibility notify) { | 157 ash::AccessibilityNotificationVisibility notify) { |
| 144 NotifyAccessibilityModeChanged(); | 158 NotifyAccessibilityModeChanged(); |
| 145 } | 159 } |
| 146 | 160 |
| 147 void WMHelperAsh::OnMaximizeModeStarted() { | 161 void WMHelperAsh::OnMaximizeModeStarted() { |
| 148 NotifyMaximizeModeStarted(); | 162 NotifyMaximizeModeStarted(); |
| 149 } | 163 } |
| 150 | 164 |
| 151 void WMHelperAsh::OnMaximizeModeEnding() { | 165 void WMHelperAsh::OnMaximizeModeEnding() { |
| 152 NotifyMaximizeModeEnding(); | 166 NotifyMaximizeModeEnding(); |
| 153 } | 167 } |
| 154 | 168 |
| 155 void WMHelperAsh::OnMaximizeModeEnded() { | 169 void WMHelperAsh::OnMaximizeModeEnded() { |
| 156 NotifyMaximizeModeEnded(); | 170 NotifyMaximizeModeEnded(); |
| 157 } | 171 } |
| 158 | 172 |
| 159 void WMHelperAsh::OnDisplayConfigurationChanged() { | 173 void WMHelperAsh::OnDisplayConfigurationChanged() { |
| 160 NotifyDisplayConfigurationChanged(); | 174 NotifyDisplayConfigurationChanged(); |
| 161 } | 175 } |
| 162 | 176 |
| 163 void WMHelperAsh::OnKeyboardDeviceConfigurationChanged() { | 177 void WMHelperAsh::OnKeyboardDeviceConfigurationChanged() { |
| 164 NotifyKeyboardDeviceConfigurationChanged(); | 178 NotifyKeyboardDeviceConfigurationChanged(); |
| 165 } | 179 } |
| 166 | 180 |
| 167 } // namespace exo | 181 } // namespace exo |
| OLD | NEW |