| 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" | |
| 8 #include "ash/public/cpp/config.h" | 7 #include "ash/public/cpp/config.h" |
| 9 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 10 #include "ash/shell_port.h" | 9 #include "ash/shell_port.h" |
| 11 #include "ash/system/tray/system_tray_notifier.h" | 10 #include "ash/system/tray/system_tray_notifier.h" |
| 12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 11 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 13 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 14 #include "ui/aura/client/focus_client.h" | 13 #include "ui/aura/client/focus_client.h" |
| 15 #include "ui/display/manager/display_manager.h" | 14 #include "ui/display/manager/display_manager.h" |
| 16 #include "ui/events/devices/input_device_manager.h" | 15 #include "ui/events/devices/input_device_manager.h" |
| 17 #include "ui/wm/public/activation_client.h" | 16 #include "ui/wm/public/activation_client.h" |
| 18 | 17 |
| 19 namespace exo { | 18 namespace exo { |
| 20 | 19 |
| 21 //////////////////////////////////////////////////////////////////////////////// | 20 //////////////////////////////////////////////////////////////////////////////// |
| 22 // WMHelperAsh, public: | 21 // WMHelperAsh, public: |
| 23 | 22 |
| 24 WMHelperAsh::WMHelperAsh() { | 23 WMHelperAsh::WMHelperAsh() { |
| 25 ash::Shell::Get()->AddShellObserver(this); | 24 ash::Shell::Get()->AddShellObserver(this); |
| 26 ash::Shell::Get()->activation_client()->AddObserver(this); | 25 ash::Shell::Get()->activation_client()->AddObserver(this); |
| 27 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. | 26 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. |
| 28 if (ash::ShellPort::Get()->GetAshConfig() != ash::Config::MUS) | 27 if (ash::ShellPort::Get()->GetAshConfig() != ash::Config::MUS) |
| 29 ash::Shell::Get()->cursor_manager()->AddObserver(this); | 28 ash::Shell::Get()->cursor_manager()->AddObserver(this); |
| 30 ash::ShellPort::Get()->AddDisplayObserver(this); | 29 ash::ShellPort::Get()->AddDisplayObserver(this); |
| 31 aura::client::FocusClient* focus_client = | 30 aura::client::FocusClient* focus_client = |
| 32 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); | 31 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); |
| 33 focus_client->AddObserver(this); | 32 focus_client->AddObserver(this); |
| 34 ui::InputDeviceManager::GetInstance()->AddObserver(this); | 33 ui::InputDeviceManager::GetInstance()->AddObserver(this); |
| 35 ash::Shell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); | |
| 36 } | 34 } |
| 37 | 35 |
| 38 WMHelperAsh::~WMHelperAsh() { | 36 WMHelperAsh::~WMHelperAsh() { |
| 39 if (!ash::Shell::HasInstance()) | 37 if (!ash::Shell::HasInstance()) |
| 40 return; | 38 return; |
| 41 aura::client::FocusClient* focus_client = | 39 aura::client::FocusClient* focus_client = |
| 42 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); | 40 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); |
| 43 focus_client->RemoveObserver(this); | 41 focus_client->RemoveObserver(this); |
| 44 ash::ShellPort::Get()->RemoveDisplayObserver(this); | 42 ash::ShellPort::Get()->RemoveDisplayObserver(this); |
| 45 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. | 43 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. |
| 46 if (ash::ShellPort::Get()->GetAshConfig() != ash::Config::MUS) | 44 if (ash::ShellPort::Get()->GetAshConfig() != ash::Config::MUS) |
| 47 ash::Shell::Get()->cursor_manager()->RemoveObserver(this); | 45 ash::Shell::Get()->cursor_manager()->RemoveObserver(this); |
| 48 ash::Shell::Get()->activation_client()->RemoveObserver(this); | 46 ash::Shell::Get()->activation_client()->RemoveObserver(this); |
| 49 ash::Shell::Get()->RemoveShellObserver(this); | 47 ash::Shell::Get()->RemoveShellObserver(this); |
| 50 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); | 48 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); |
| 51 ash::Shell::Get()->system_tray_notifier()->RemoveAccessibilityObserver(this); | |
| 52 } | 49 } |
| 53 | 50 |
| 54 //////////////////////////////////////////////////////////////////////////////// | 51 //////////////////////////////////////////////////////////////////////////////// |
| 55 // WMHelperAsh, private: | 52 // WMHelperAsh, private: |
| 56 | 53 |
| 57 const display::ManagedDisplayInfo WMHelperAsh::GetDisplayInfo( | 54 const display::ManagedDisplayInfo WMHelperAsh::GetDisplayInfo( |
| 58 int64_t display_id) const { | 55 int64_t display_id) const { |
| 59 return ash::Shell::Get()->display_manager()->GetDisplayInfo(display_id); | 56 return ash::Shell::Get()->display_manager()->GetDisplayInfo(display_id); |
| 60 } | 57 } |
| 61 | 58 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 void WMHelperAsh::RemovePostTargetHandler(ui::EventHandler* handler) { | 99 void WMHelperAsh::RemovePostTargetHandler(ui::EventHandler* handler) { |
| 103 ash::Shell::Get()->RemovePostTargetHandler(handler); | 100 ash::Shell::Get()->RemovePostTargetHandler(handler); |
| 104 } | 101 } |
| 105 | 102 |
| 106 bool WMHelperAsh::IsMaximizeModeWindowManagerEnabled() const { | 103 bool WMHelperAsh::IsMaximizeModeWindowManagerEnabled() const { |
| 107 return ash::Shell::Get() | 104 return ash::Shell::Get() |
| 108 ->maximize_mode_controller() | 105 ->maximize_mode_controller() |
| 109 ->IsMaximizeModeWindowManagerEnabled(); | 106 ->IsMaximizeModeWindowManagerEnabled(); |
| 110 } | 107 } |
| 111 | 108 |
| 112 bool WMHelperAsh::IsSpokenFeedbackEnabled() const { | |
| 113 return ash::Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); | |
| 114 } | |
| 115 | |
| 116 void WMHelperAsh::PlayEarcon(int sound_key) const { | |
| 117 return ash::Shell::Get()->accessibility_delegate()->PlayEarcon(sound_key); | |
| 118 } | |
| 119 | |
| 120 void WMHelperAsh::OnWindowActivated( | 109 void WMHelperAsh::OnWindowActivated( |
| 121 aura::client::ActivationChangeObserver::ActivationReason reason, | 110 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 122 aura::Window* gained_active, | 111 aura::Window* gained_active, |
| 123 aura::Window* lost_active) { | 112 aura::Window* lost_active) { |
| 124 NotifyWindowActivated(gained_active, lost_active); | 113 NotifyWindowActivated(gained_active, lost_active); |
| 125 } | 114 } |
| 126 | 115 |
| 127 void WMHelperAsh::OnWindowFocused(aura::Window* gained_focus, | 116 void WMHelperAsh::OnWindowFocused(aura::Window* gained_focus, |
| 128 aura::Window* lost_focus) { | 117 aura::Window* lost_focus) { |
| 129 NotifyWindowFocused(gained_focus, lost_focus); | 118 NotifyWindowFocused(gained_focus, lost_focus); |
| 130 } | 119 } |
| 131 | 120 |
| 132 void WMHelperAsh::OnCursorVisibilityChanged(bool is_visible) { | 121 void WMHelperAsh::OnCursorVisibilityChanged(bool is_visible) { |
| 133 NotifyCursorVisibilityChanged(is_visible); | 122 NotifyCursorVisibilityChanged(is_visible); |
| 134 } | 123 } |
| 135 | 124 |
| 136 void WMHelperAsh::OnCursorSetChanged(ui::CursorSetType cursor_set) { | 125 void WMHelperAsh::OnCursorSetChanged(ui::CursorSetType cursor_set) { |
| 137 NotifyCursorSetChanged(cursor_set); | 126 NotifyCursorSetChanged(cursor_set); |
| 138 } | 127 } |
| 139 | 128 |
| 140 void WMHelperAsh::OnAccessibilityModeChanged( | |
| 141 ash::AccessibilityNotificationVisibility notify) { | |
| 142 NotifyAccessibilityModeChanged(); | |
| 143 } | |
| 144 | |
| 145 void WMHelperAsh::OnMaximizeModeStarted() { | 129 void WMHelperAsh::OnMaximizeModeStarted() { |
| 146 NotifyMaximizeModeStarted(); | 130 NotifyMaximizeModeStarted(); |
| 147 } | 131 } |
| 148 | 132 |
| 149 void WMHelperAsh::OnMaximizeModeEnding() { | 133 void WMHelperAsh::OnMaximizeModeEnding() { |
| 150 NotifyMaximizeModeEnding(); | 134 NotifyMaximizeModeEnding(); |
| 151 } | 135 } |
| 152 | 136 |
| 153 void WMHelperAsh::OnMaximizeModeEnded() { | 137 void WMHelperAsh::OnMaximizeModeEnded() { |
| 154 NotifyMaximizeModeEnded(); | 138 NotifyMaximizeModeEnded(); |
| 155 } | 139 } |
| 156 | 140 |
| 157 void WMHelperAsh::OnDisplayConfigurationChanged() { | 141 void WMHelperAsh::OnDisplayConfigurationChanged() { |
| 158 NotifyDisplayConfigurationChanged(); | 142 NotifyDisplayConfigurationChanged(); |
| 159 } | 143 } |
| 160 | 144 |
| 161 void WMHelperAsh::OnKeyboardDeviceConfigurationChanged() { | 145 void WMHelperAsh::OnKeyboardDeviceConfigurationChanged() { |
| 162 NotifyKeyboardDeviceConfigurationChanged(); | 146 NotifyKeyboardDeviceConfigurationChanged(); |
| 163 } | 147 } |
| 164 | 148 |
| 165 } // namespace exo | 149 } // namespace exo |
| OLD | NEW |