| 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/shell_port_classic.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/accelerators/accelerator_controller.h" | 9 #include "ash/accelerators/accelerator_controller.h" |
| 10 #include "ash/accelerators/accelerator_controller_delegate_aura.h" | 10 #include "ash/accelerators/accelerator_controller_delegate_aura.h" |
| 11 #include "ash/aura/key_event_watcher_aura.h" | 11 #include "ash/aura/key_event_watcher_aura.h" |
| 12 #include "ash/aura/pointer_watcher_adapter.h" | 12 #include "ash/aura/pointer_watcher_adapter.h" |
| 13 #include "ash/display/window_tree_host_manager.h" | 13 #include "ash/display/window_tree_host_manager.h" |
| 14 #include "ash/host/ash_window_tree_host_init_params.h" | 14 #include "ash/host/ash_window_tree_host_init_params.h" |
| 15 #include "ash/keyboard/keyboard_ui.h" | 15 #include "ash/keyboard/keyboard_ui.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 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() {} | 51 ShellPortClassic::ShellPortClassic() {} |
| 52 | 52 |
| 53 WmShellAura::~WmShellAura() {} | 53 ShellPortClassic::~ShellPortClassic() {} |
| 54 | 54 |
| 55 // static | 55 // static |
| 56 WmShellAura* WmShellAura::Get() { | 56 ShellPortClassic* ShellPortClassic::Get() { |
| 57 CHECK(!WmShell::Get()->IsRunningInMash()); | 57 CHECK(!ShellPort::Get()->IsRunningInMash()); |
| 58 return static_cast<WmShellAura*>(WmShell::Get()); | 58 return static_cast<ShellPortClassic*>(ShellPort::Get()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void WmShellAura::Shutdown() { | 61 void ShellPortClassic::Shutdown() { |
| 62 if (added_display_observer_) | 62 if (added_display_observer_) |
| 63 Shell::Get()->window_tree_host_manager()->RemoveObserver(this); | 63 Shell::Get()->window_tree_host_manager()->RemoveObserver(this); |
| 64 | 64 |
| 65 pointer_watcher_adapter_.reset(); | 65 pointer_watcher_adapter_.reset(); |
| 66 | 66 |
| 67 WmShell::Shutdown(); | 67 ShellPort::Shutdown(); |
| 68 | 68 |
| 69 Shell::Get()->window_tree_host_manager()->Shutdown(); | 69 Shell::Get()->window_tree_host_manager()->Shutdown(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool WmShellAura::IsRunningInMash() const { | 72 bool ShellPortClassic::IsRunningInMash() const { |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 | 75 |
| 76 Config WmShellAura::GetAshConfig() const { | 76 Config ShellPortClassic::GetAshConfig() const { |
| 77 return Config::CLASSIC; | 77 return Config::CLASSIC; |
| 78 } | 78 } |
| 79 | 79 |
| 80 WmWindow* WmShellAura::GetPrimaryRootWindow() { | 80 WmWindow* ShellPortClassic::GetPrimaryRootWindow() { |
| 81 return WmWindow::Get( | 81 return WmWindow::Get( |
| 82 Shell::Get()->window_tree_host_manager()->GetPrimaryRootWindow()); | 82 Shell::Get()->window_tree_host_manager()->GetPrimaryRootWindow()); |
| 83 } | 83 } |
| 84 | 84 |
| 85 WmWindow* WmShellAura::GetRootWindowForDisplayId(int64_t display_id) { | 85 WmWindow* ShellPortClassic::GetRootWindowForDisplayId(int64_t display_id) { |
| 86 return WmWindow::Get( | 86 return WmWindow::Get( |
| 87 Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId( | 87 Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId( |
| 88 display_id)); | 88 display_id)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 const display::ManagedDisplayInfo& WmShellAura::GetDisplayInfo( | 91 const display::ManagedDisplayInfo& ShellPortClassic::GetDisplayInfo( |
| 92 int64_t display_id) const { | 92 int64_t display_id) const { |
| 93 return Shell::Get()->display_manager()->GetDisplayInfo(display_id); | 93 return Shell::Get()->display_manager()->GetDisplayInfo(display_id); |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool WmShellAura::IsActiveDisplayId(int64_t display_id) const { | 96 bool ShellPortClassic::IsActiveDisplayId(int64_t display_id) const { |
| 97 return Shell::Get()->display_manager()->IsActiveDisplayId(display_id); | 97 return Shell::Get()->display_manager()->IsActiveDisplayId(display_id); |
| 98 } | 98 } |
| 99 | 99 |
| 100 display::Display WmShellAura::GetFirstDisplay() const { | 100 display::Display ShellPortClassic::GetFirstDisplay() const { |
| 101 return Shell::Get()->display_manager()->software_mirroring_display_list()[0]; | 101 return Shell::Get()->display_manager()->software_mirroring_display_list()[0]; |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool WmShellAura::IsInUnifiedMode() const { | 104 bool ShellPortClassic::IsInUnifiedMode() const { |
| 105 return Shell::Get()->display_manager()->IsInUnifiedMode(); | 105 return Shell::Get()->display_manager()->IsInUnifiedMode(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool WmShellAura::IsInUnifiedModeIgnoreMirroring() const { | 108 bool ShellPortClassic::IsInUnifiedModeIgnoreMirroring() const { |
| 109 return Shell::Get() | 109 return Shell::Get() |
| 110 ->display_manager() | 110 ->display_manager() |
| 111 ->current_default_multi_display_mode() == | 111 ->current_default_multi_display_mode() == |
| 112 display::DisplayManager::UNIFIED; | 112 display::DisplayManager::UNIFIED; |
| 113 } | 113 } |
| 114 | 114 |
| 115 void WmShellAura::SetDisplayWorkAreaInsets(WmWindow* window, | 115 void ShellPortClassic::SetDisplayWorkAreaInsets(WmWindow* window, |
| 116 const gfx::Insets& insets) { | 116 const gfx::Insets& insets) { |
| 117 Shell::Get() | 117 Shell::Get() |
| 118 ->window_tree_host_manager() | 118 ->window_tree_host_manager() |
| 119 ->UpdateWorkAreaOfDisplayNearestWindow(window->aura_window(), insets); | 119 ->UpdateWorkAreaOfDisplayNearestWindow(window->aura_window(), insets); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void WmShellAura::LockCursor() { | 122 void ShellPortClassic::LockCursor() { |
| 123 Shell::Get()->cursor_manager()->LockCursor(); | 123 Shell::Get()->cursor_manager()->LockCursor(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void WmShellAura::UnlockCursor() { | 126 void ShellPortClassic::UnlockCursor() { |
| 127 Shell::Get()->cursor_manager()->UnlockCursor(); | 127 Shell::Get()->cursor_manager()->UnlockCursor(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool WmShellAura::IsMouseEventsEnabled() { | 130 bool ShellPortClassic::IsMouseEventsEnabled() { |
| 131 return Shell::Get()->cursor_manager()->IsMouseEventsEnabled(); | 131 return Shell::Get()->cursor_manager()->IsMouseEventsEnabled(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 std::vector<WmWindow*> WmShellAura::GetAllRootWindows() { | 134 std::vector<WmWindow*> ShellPortClassic::GetAllRootWindows() { |
| 135 aura::Window::Windows root_windows = | 135 aura::Window::Windows root_windows = |
| 136 Shell::Get()->window_tree_host_manager()->GetAllRootWindows(); | 136 Shell::Get()->window_tree_host_manager()->GetAllRootWindows(); |
| 137 std::vector<WmWindow*> wm_windows(root_windows.size()); | 137 std::vector<WmWindow*> wm_windows(root_windows.size()); |
| 138 for (size_t i = 0; i < root_windows.size(); ++i) | 138 for (size_t i = 0; i < root_windows.size(); ++i) |
| 139 wm_windows[i] = WmWindow::Get(root_windows[i]); | 139 wm_windows[i] = WmWindow::Get(root_windows[i]); |
| 140 return wm_windows; | 140 return wm_windows; |
| 141 } | 141 } |
| 142 | 142 |
| 143 void WmShellAura::RecordUserMetricsAction(UserMetricsAction action) { | 143 void ShellPortClassic::RecordUserMetricsAction(UserMetricsAction action) { |
| 144 Shell::Get()->metrics()->RecordUserMetricsAction(action); | 144 Shell::Get()->metrics()->RecordUserMetricsAction(action); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void WmShellAura::RecordGestureAction(GestureActionType action) { | 147 void ShellPortClassic::RecordGestureAction(GestureActionType action) { |
| 148 TouchUMA::GetInstance()->RecordGestureAction(action); | 148 TouchUMA::GetInstance()->RecordGestureAction(action); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void WmShellAura::RecordTaskSwitchMetric(TaskSwitchSource source) { | 151 void ShellPortClassic::RecordTaskSwitchMetric(TaskSwitchSource source) { |
| 152 Shell::Get()->metrics()->task_switch_metrics_recorder().OnTaskSwitch(source); | 152 Shell::Get()->metrics()->task_switch_metrics_recorder().OnTaskSwitch(source); |
| 153 } | 153 } |
| 154 | 154 |
| 155 std::unique_ptr<WindowResizer> WmShellAura::CreateDragWindowResizer( | 155 std::unique_ptr<WindowResizer> ShellPortClassic::CreateDragWindowResizer( |
| 156 std::unique_ptr<WindowResizer> next_window_resizer, | 156 std::unique_ptr<WindowResizer> next_window_resizer, |
| 157 wm::WindowState* window_state) { | 157 wm::WindowState* window_state) { |
| 158 return base::WrapUnique( | 158 return base::WrapUnique( |
| 159 DragWindowResizer::Create(next_window_resizer.release(), window_state)); | 159 DragWindowResizer::Create(next_window_resizer.release(), window_state)); |
| 160 } | 160 } |
| 161 | 161 |
| 162 std::unique_ptr<WindowCycleEventFilter> | 162 std::unique_ptr<WindowCycleEventFilter> |
| 163 WmShellAura::CreateWindowCycleEventFilter() { | 163 ShellPortClassic::CreateWindowCycleEventFilter() { |
| 164 return base::MakeUnique<WindowCycleEventFilterAura>(); | 164 return base::MakeUnique<WindowCycleEventFilterAura>(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 std::unique_ptr<wm::MaximizeModeEventHandler> | 167 std::unique_ptr<wm::MaximizeModeEventHandler> |
| 168 WmShellAura::CreateMaximizeModeEventHandler() { | 168 ShellPortClassic::CreateMaximizeModeEventHandler() { |
| 169 return base::WrapUnique(new wm::MaximizeModeEventHandlerAura); | 169 return base::WrapUnique(new wm::MaximizeModeEventHandlerAura); |
| 170 } | 170 } |
| 171 | 171 |
| 172 std::unique_ptr<WorkspaceEventHandler> WmShellAura::CreateWorkspaceEventHandler( | 172 std::unique_ptr<WorkspaceEventHandler> |
| 173 WmWindow* workspace_window) { | 173 ShellPortClassic::CreateWorkspaceEventHandler(WmWindow* workspace_window) { |
| 174 return base::MakeUnique<WorkspaceEventHandlerAura>(workspace_window); | 174 return base::MakeUnique<WorkspaceEventHandlerAura>(workspace_window); |
| 175 } | 175 } |
| 176 | 176 |
| 177 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> | 177 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> |
| 178 WmShellAura::CreateScopedDisableInternalMouseAndKeyboard() { | 178 ShellPortClassic::CreateScopedDisableInternalMouseAndKeyboard() { |
| 179 #if defined(USE_X11) | 179 #if defined(USE_X11) |
| 180 return base::WrapUnique(new ScopedDisableInternalMouseAndKeyboardX11); | 180 return base::WrapUnique(new ScopedDisableInternalMouseAndKeyboardX11); |
| 181 #elif defined(USE_OZONE) | 181 #elif defined(USE_OZONE) |
| 182 return base::WrapUnique(new ScopedDisableInternalMouseAndKeyboardOzone); | 182 return base::WrapUnique(new ScopedDisableInternalMouseAndKeyboardOzone); |
| 183 #endif | 183 #endif |
| 184 return nullptr; | 184 return nullptr; |
| 185 } | 185 } |
| 186 | 186 |
| 187 std::unique_ptr<ImmersiveFullscreenController> | 187 std::unique_ptr<ImmersiveFullscreenController> |
| 188 WmShellAura::CreateImmersiveFullscreenController() { | 188 ShellPortClassic::CreateImmersiveFullscreenController() { |
| 189 return base::MakeUnique<ImmersiveFullscreenController>(); | 189 return base::MakeUnique<ImmersiveFullscreenController>(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 std::unique_ptr<KeyboardUI> WmShellAura::CreateKeyboardUI() { | 192 std::unique_ptr<KeyboardUI> ShellPortClassic::CreateKeyboardUI() { |
| 193 return KeyboardUI::Create(); | 193 return KeyboardUI::Create(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 std::unique_ptr<KeyEventWatcher> WmShellAura::CreateKeyEventWatcher() { | 196 std::unique_ptr<KeyEventWatcher> ShellPortClassic::CreateKeyEventWatcher() { |
| 197 return base::MakeUnique<KeyEventWatcherAura>(); | 197 return base::MakeUnique<KeyEventWatcherAura>(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 SessionStateDelegate* WmShellAura::GetSessionStateDelegate() { | 200 SessionStateDelegate* ShellPortClassic::GetSessionStateDelegate() { |
| 201 return Shell::Get()->session_state_delegate(); | 201 return Shell::Get()->session_state_delegate(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void WmShellAura::AddDisplayObserver(WmDisplayObserver* observer) { | 204 void ShellPortClassic::AddDisplayObserver(WmDisplayObserver* observer) { |
| 205 if (!added_display_observer_) { | 205 if (!added_display_observer_) { |
| 206 added_display_observer_ = true; | 206 added_display_observer_ = true; |
| 207 Shell::Get()->window_tree_host_manager()->AddObserver(this); | 207 Shell::Get()->window_tree_host_manager()->AddObserver(this); |
| 208 } | 208 } |
| 209 display_observers_.AddObserver(observer); | 209 display_observers_.AddObserver(observer); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void WmShellAura::RemoveDisplayObserver(WmDisplayObserver* observer) { | 212 void ShellPortClassic::RemoveDisplayObserver(WmDisplayObserver* observer) { |
| 213 display_observers_.RemoveObserver(observer); | 213 display_observers_.RemoveObserver(observer); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void WmShellAura::AddPointerWatcher(views::PointerWatcher* watcher, | 216 void ShellPortClassic::AddPointerWatcher( |
| 217 views::PointerWatcherEventTypes events) { | 217 views::PointerWatcher* watcher, |
| 218 views::PointerWatcherEventTypes events) { |
| 218 pointer_watcher_adapter_->AddPointerWatcher(watcher, events); | 219 pointer_watcher_adapter_->AddPointerWatcher(watcher, events); |
| 219 } | 220 } |
| 220 | 221 |
| 221 void WmShellAura::RemovePointerWatcher(views::PointerWatcher* watcher) { | 222 void ShellPortClassic::RemovePointerWatcher(views::PointerWatcher* watcher) { |
| 222 pointer_watcher_adapter_->RemovePointerWatcher(watcher); | 223 pointer_watcher_adapter_->RemovePointerWatcher(watcher); |
| 223 } | 224 } |
| 224 | 225 |
| 225 bool WmShellAura::IsTouchDown() { | 226 bool ShellPortClassic::IsTouchDown() { |
| 226 return aura::Env::GetInstance()->is_touch_down(); | 227 return aura::Env::GetInstance()->is_touch_down(); |
| 227 } | 228 } |
| 228 | 229 |
| 229 void WmShellAura::ToggleIgnoreExternalKeyboard() { | 230 void ShellPortClassic::ToggleIgnoreExternalKeyboard() { |
| 230 Shell::Get()->virtual_keyboard_controller()->ToggleIgnoreExternalKeyboard(); | 231 Shell::Get()->virtual_keyboard_controller()->ToggleIgnoreExternalKeyboard(); |
| 231 } | 232 } |
| 232 | 233 |
| 233 void WmShellAura::SetLaserPointerEnabled(bool enabled) { | 234 void ShellPortClassic::SetLaserPointerEnabled(bool enabled) { |
| 234 Shell::Get()->laser_pointer_controller()->SetEnabled(enabled); | 235 Shell::Get()->laser_pointer_controller()->SetEnabled(enabled); |
| 235 } | 236 } |
| 236 | 237 |
| 237 void WmShellAura::SetPartialMagnifierEnabled(bool enabled) { | 238 void ShellPortClassic::SetPartialMagnifierEnabled(bool enabled) { |
| 238 Shell::Get()->partial_magnification_controller()->SetEnabled(enabled); | 239 Shell::Get()->partial_magnification_controller()->SetEnabled(enabled); |
| 239 } | 240 } |
| 240 | 241 |
| 241 void WmShellAura::CreatePointerWatcherAdapter() { | 242 void ShellPortClassic::CreatePointerWatcherAdapter() { |
| 242 pointer_watcher_adapter_ = base::MakeUnique<PointerWatcherAdapter>(); | 243 pointer_watcher_adapter_ = base::MakeUnique<PointerWatcherAdapter>(); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void WmShellAura::CreatePrimaryHost() { | 246 void ShellPortClassic::CreatePrimaryHost() { |
| 246 Shell::Get()->window_tree_host_manager()->Start(); | 247 Shell::Get()->window_tree_host_manager()->Start(); |
| 247 AshWindowTreeHostInitParams ash_init_params; | 248 AshWindowTreeHostInitParams ash_init_params; |
| 248 Shell::Get()->window_tree_host_manager()->CreatePrimaryHost(ash_init_params); | 249 Shell::Get()->window_tree_host_manager()->CreatePrimaryHost(ash_init_params); |
| 249 } | 250 } |
| 250 | 251 |
| 251 void WmShellAura::InitHosts(const ShellInitParams& init_params) { | 252 void ShellPortClassic::InitHosts(const ShellInitParams& init_params) { |
| 252 Shell::Get()->window_tree_host_manager()->InitHosts(); | 253 Shell::Get()->window_tree_host_manager()->InitHosts(); |
| 253 } | 254 } |
| 254 | 255 |
| 255 std::unique_ptr<AcceleratorController> | 256 std::unique_ptr<AcceleratorController> |
| 256 WmShellAura::CreateAcceleratorController() { | 257 ShellPortClassic::CreateAcceleratorController() { |
| 257 DCHECK(!accelerator_controller_delegate_); | 258 DCHECK(!accelerator_controller_delegate_); |
| 258 accelerator_controller_delegate_ = | 259 accelerator_controller_delegate_ = |
| 259 base::MakeUnique<AcceleratorControllerDelegateAura>(); | 260 base::MakeUnique<AcceleratorControllerDelegateAura>(); |
| 260 return base::MakeUnique<AcceleratorController>( | 261 return base::MakeUnique<AcceleratorController>( |
| 261 accelerator_controller_delegate_.get(), nullptr); | 262 accelerator_controller_delegate_.get(), nullptr); |
| 262 } | 263 } |
| 263 | 264 |
| 264 void WmShellAura::OnDisplayConfigurationChanging() { | 265 void ShellPortClassic::OnDisplayConfigurationChanging() { |
| 265 for (auto& observer : display_observers_) | 266 for (auto& observer : display_observers_) |
| 266 observer.OnDisplayConfigurationChanging(); | 267 observer.OnDisplayConfigurationChanging(); |
| 267 } | 268 } |
| 268 | 269 |
| 269 void WmShellAura::OnDisplayConfigurationChanged() { | 270 void ShellPortClassic::OnDisplayConfigurationChanged() { |
| 270 for (auto& observer : display_observers_) | 271 for (auto& observer : display_observers_) |
| 271 observer.OnDisplayConfigurationChanged(); | 272 observer.OnDisplayConfigurationChanged(); |
| 272 } | 273 } |
| 273 | 274 |
| 274 } // namespace ash | 275 } // namespace ash |
| OLD | NEW |