| 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/mus/bridge/shell_port_mash.h" | 5 #include "ash/mus/bridge/shell_port_mash.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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "ash/wm/maximize_mode/maximize_mode_event_handler.h" | 42 #include "ash/wm/maximize_mode/maximize_mode_event_handler.h" |
| 43 #include "ash/wm/maximize_mode/maximize_mode_event_handler_aura.h" | 43 #include "ash/wm/maximize_mode/maximize_mode_event_handler_aura.h" |
| 44 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.h" | 44 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.h" |
| 45 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.
h" | 45 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.
h" |
| 46 #include "ash/wm/mru_window_tracker.h" | 46 #include "ash/wm/mru_window_tracker.h" |
| 47 #include "ash/wm/window_cycle_event_filter.h" | 47 #include "ash/wm/window_cycle_event_filter.h" |
| 48 #include "ash/wm/window_cycle_event_filter_aura.h" | 48 #include "ash/wm/window_cycle_event_filter_aura.h" |
| 49 #include "ash/wm/window_resizer.h" | 49 #include "ash/wm/window_resizer.h" |
| 50 #include "ash/wm/window_util.h" | 50 #include "ash/wm/window_util.h" |
| 51 #include "ash/wm/workspace/workspace_event_handler_aura.h" | 51 #include "ash/wm/workspace/workspace_event_handler_aura.h" |
| 52 #include "ash/wm_display_observer.h" |
| 52 #include "ash/wm_window.h" | 53 #include "ash/wm_window.h" |
| 53 #include "base/command_line.h" | 54 #include "base/command_line.h" |
| 54 #include "base/memory/ptr_util.h" | 55 #include "base/memory/ptr_util.h" |
| 55 #include "components/user_manager/user_info_impl.h" | 56 #include "components/user_manager/user_info_impl.h" |
| 56 #include "services/ui/public/interfaces/constants.mojom.h" | 57 #include "services/ui/public/interfaces/constants.mojom.h" |
| 57 #include "ui/aura/env.h" | 58 #include "ui/aura/env.h" |
| 58 #include "ui/aura/mus/focus_synchronizer.h" | 59 #include "ui/aura/mus/focus_synchronizer.h" |
| 59 #include "ui/aura/mus/window_tree_client.h" | 60 #include "ui/aura/mus/window_tree_client.h" |
| 60 #include "ui/aura/mus/window_tree_host_mus.h" | 61 #include "ui/aura/mus/window_tree_host_mus.h" |
| 61 #include "ui/aura/mus/window_tree_host_mus_init_params.h" | 62 #include "ui/aura/mus/window_tree_host_mus_init_params.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return root_window_controller; | 153 return root_window_controller; |
| 153 } | 154 } |
| 154 return nullptr; | 155 return nullptr; |
| 155 } | 156 } |
| 156 | 157 |
| 157 aura::WindowTreeClient* ShellPortMash::window_tree_client() { | 158 aura::WindowTreeClient* ShellPortMash::window_tree_client() { |
| 158 return window_manager_->window_tree_client(); | 159 return window_manager_->window_tree_client(); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void ShellPortMash::Shutdown() { | 162 void ShellPortMash::Shutdown() { |
| 163 if (added_display_observer_) |
| 164 Shell::Get()->window_tree_host_manager()->RemoveObserver(this); |
| 165 |
| 162 if (mus_state_) | 166 if (mus_state_) |
| 163 mus_state_->pointer_watcher_adapter.reset(); | 167 mus_state_->pointer_watcher_adapter.reset(); |
| 164 | 168 |
| 165 ShellPort::Shutdown(); | 169 ShellPort::Shutdown(); |
| 166 | 170 |
| 167 // TODO(sky): Config::MASH should use WindowTreeHostManager too. | 171 // TODO(sky): Config::MASH should use WindowTreeHostManager too. |
| 168 if (GetAshConfig() == Config::MUS) | 172 if (GetAshConfig() == Config::MUS) |
| 169 Shell::Get()->window_tree_host_manager()->Shutdown(); | 173 Shell::Get()->window_tree_host_manager()->Shutdown(); |
| 170 else | 174 else |
| 171 window_manager_->DeleteAllRootWindowControllers(); | 175 window_manager_->DeleteAllRootWindowControllers(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 193 } | 197 } |
| 194 RootWindowController* root_window_controller = | 198 RootWindowController* root_window_controller = |
| 195 GetRootWindowControllerWithDisplayId(display_id); | 199 GetRootWindowControllerWithDisplayId(display_id); |
| 196 return root_window_controller | 200 return root_window_controller |
| 197 ? WmWindow::Get(root_window_controller->GetRootWindow()) | 201 ? WmWindow::Get(root_window_controller->GetRootWindow()) |
| 198 : nullptr; | 202 : nullptr; |
| 199 } | 203 } |
| 200 | 204 |
| 201 const display::ManagedDisplayInfo& ShellPortMash::GetDisplayInfo( | 205 const display::ManagedDisplayInfo& ShellPortMash::GetDisplayInfo( |
| 202 int64_t display_id) const { | 206 int64_t display_id) const { |
| 207 // TODO(sky): mash should use this too http://crbug.com/718860. |
| 208 if (GetAshConfig() == Config::MUS) |
| 209 return Shell::Get()->display_manager()->GetDisplayInfo(display_id); |
| 210 |
| 203 // TODO(mash): implement http://crbug.com/622480. | 211 // TODO(mash): implement http://crbug.com/622480. |
| 204 NOTIMPLEMENTED(); | 212 NOTIMPLEMENTED(); |
| 205 static display::ManagedDisplayInfo fake_info; | 213 static display::ManagedDisplayInfo fake_info; |
| 206 return fake_info; | 214 return fake_info; |
| 207 } | 215 } |
| 208 | 216 |
| 209 bool ShellPortMash::IsActiveDisplayId(int64_t display_id) const { | 217 bool ShellPortMash::IsActiveDisplayId(int64_t display_id) const { |
| 218 // TODO(sky): mash should use this too http://crbug.com/718860. |
| 219 if (GetAshConfig() == Config::MUS) |
| 220 return Shell::Get()->display_manager()->IsActiveDisplayId(display_id); |
| 221 |
| 210 // TODO(mash): implement http://crbug.com/622480. | 222 // TODO(mash): implement http://crbug.com/622480. |
| 211 NOTIMPLEMENTED(); | 223 NOTIMPLEMENTED(); |
| 212 return true; | 224 return true; |
| 213 } | 225 } |
| 214 | 226 |
| 215 display::Display ShellPortMash::GetFirstDisplay() const { | 227 display::Display ShellPortMash::GetFirstDisplay() const { |
| 228 // TODO(sky): mash should use this too http://crbug.com/718860. |
| 229 if (GetAshConfig() == Config::MUS) { |
| 230 return Shell::Get() |
| 231 ->display_manager() |
| 232 ->software_mirroring_display_list()[0]; |
| 233 } |
| 234 |
| 216 // TODO(mash): implement http://crbug.com/622480. | 235 // TODO(mash): implement http://crbug.com/622480. |
| 217 NOTIMPLEMENTED(); | 236 NOTIMPLEMENTED(); |
| 218 return display::Screen::GetScreen()->GetPrimaryDisplay(); | 237 return display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 219 } | 238 } |
| 220 | 239 |
| 221 bool ShellPortMash::IsInUnifiedMode() const { | 240 bool ShellPortMash::IsInUnifiedMode() const { |
| 241 // TODO(sky): mash should use this too http://crbug.com/718860. |
| 242 if (GetAshConfig() == Config::MUS) |
| 243 return Shell::Get()->display_manager()->IsInUnifiedMode(); |
| 244 |
| 222 // TODO(mash): implement http://crbug.com/622480. | 245 // TODO(mash): implement http://crbug.com/622480. |
| 223 NOTIMPLEMENTED(); | 246 NOTIMPLEMENTED(); |
| 224 return false; | 247 return false; |
| 225 } | 248 } |
| 226 | 249 |
| 227 bool ShellPortMash::IsInUnifiedModeIgnoreMirroring() const { | 250 bool ShellPortMash::IsInUnifiedModeIgnoreMirroring() const { |
| 251 // TODO(sky): mash should use this too http://crbug.com/718860. |
| 252 if (GetAshConfig() == Config::MUS) { |
| 253 return Shell::Get() |
| 254 ->display_manager() |
| 255 ->current_default_multi_display_mode() == |
| 256 display::DisplayManager::UNIFIED; |
| 257 } |
| 258 |
| 228 // TODO(mash): implement http://crbug.com/622480. | 259 // TODO(mash): implement http://crbug.com/622480. |
| 229 NOTIMPLEMENTED(); | 260 NOTIMPLEMENTED(); |
| 230 return false; | 261 return false; |
| 231 } | 262 } |
| 232 | 263 |
| 233 void ShellPortMash::SetDisplayWorkAreaInsets(WmWindow* window, | 264 void ShellPortMash::SetDisplayWorkAreaInsets(WmWindow* window, |
| 234 const gfx::Insets& insets) { | 265 const gfx::Insets& insets) { |
| 235 if (GetAshConfig() == Config::MUS) { | 266 if (GetAshConfig() == Config::MUS) { |
| 236 Shell::Get() | 267 Shell::Get() |
| 237 ->window_tree_host_manager() | 268 ->window_tree_host_manager() |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 NOTIMPLEMENTED(); | 411 NOTIMPLEMENTED(); |
| 381 return std::unique_ptr<KeyEventWatcher>(); | 412 return std::unique_ptr<KeyEventWatcher>(); |
| 382 } | 413 } |
| 383 | 414 |
| 384 SessionStateDelegate* ShellPortMash::GetSessionStateDelegate() { | 415 SessionStateDelegate* ShellPortMash::GetSessionStateDelegate() { |
| 385 return session_state_delegate_ ? session_state_delegate_.get() | 416 return session_state_delegate_ ? session_state_delegate_.get() |
| 386 : Shell::Get()->session_state_delegate(); | 417 : Shell::Get()->session_state_delegate(); |
| 387 } | 418 } |
| 388 | 419 |
| 389 void ShellPortMash::AddDisplayObserver(WmDisplayObserver* observer) { | 420 void ShellPortMash::AddDisplayObserver(WmDisplayObserver* observer) { |
| 390 // TODO: need WmDisplayObserver support for mus. http://crbug.com/705831. | 421 // TODO(sky): mash should use the same code as mus/classic and |
| 391 NOTIMPLEMENTED(); | 422 // WmDisplayObserver should be removed; http://crbug.com/718860. |
| 423 if (GetAshConfig() == Config::MASH) { |
| 424 NOTIMPLEMENTED(); |
| 425 return; |
| 426 } |
| 427 if (!added_display_observer_) { |
| 428 added_display_observer_ = true; |
| 429 Shell::Get()->window_tree_host_manager()->AddObserver(this); |
| 430 } |
| 431 display_observers_.AddObserver(observer); |
| 392 } | 432 } |
| 393 | 433 |
| 394 void ShellPortMash::RemoveDisplayObserver(WmDisplayObserver* observer) { | 434 void ShellPortMash::RemoveDisplayObserver(WmDisplayObserver* observer) { |
| 395 // TODO: need WmDisplayObserver support for mus. http://crbug.com/705831. | 435 // TODO(sky): mash should use the same code as mus/classic and |
| 396 NOTIMPLEMENTED(); | 436 // WmDisplayObserver should be removed; http://crbug.com/718860. |
| 437 if (GetAshConfig() == Config::MASH) { |
| 438 NOTIMPLEMENTED(); |
| 439 return; |
| 440 } |
| 441 display_observers_.RemoveObserver(observer); |
| 397 } | 442 } |
| 398 | 443 |
| 399 void ShellPortMash::AddPointerWatcher(views::PointerWatcher* watcher, | 444 void ShellPortMash::AddPointerWatcher(views::PointerWatcher* watcher, |
| 400 views::PointerWatcherEventTypes events) { | 445 views::PointerWatcherEventTypes events) { |
| 401 if (GetAshConfig() == Config::MUS) { | 446 if (GetAshConfig() == Config::MUS) { |
| 402 mus_state_->pointer_watcher_adapter->AddPointerWatcher(watcher, events); | 447 mus_state_->pointer_watcher_adapter->AddPointerWatcher(watcher, events); |
| 403 return; | 448 return; |
| 404 } | 449 } |
| 405 | 450 |
| 406 // TODO: implement drags for mus pointer watcher, http://crbug.com/641164. | 451 // TODO: implement drags for mus pointer watcher, http://crbug.com/641164. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 mash_state_->accelerator_controller_delegate = | 608 mash_state_->accelerator_controller_delegate = |
| 564 base::MakeUnique<AcceleratorControllerDelegateMus>(window_manager_); | 609 base::MakeUnique<AcceleratorControllerDelegateMus>(window_manager_); |
| 565 mash_state_->accelerator_controller_registrar = | 610 mash_state_->accelerator_controller_registrar = |
| 566 base ::MakeUnique<AcceleratorControllerRegistrar>( | 611 base ::MakeUnique<AcceleratorControllerRegistrar>( |
| 567 window_manager_, accelerator_namespace_id); | 612 window_manager_, accelerator_namespace_id); |
| 568 return base::MakeUnique<AcceleratorController>( | 613 return base::MakeUnique<AcceleratorController>( |
| 569 mash_state_->accelerator_controller_delegate.get(), | 614 mash_state_->accelerator_controller_delegate.get(), |
| 570 mash_state_->accelerator_controller_registrar.get()); | 615 mash_state_->accelerator_controller_registrar.get()); |
| 571 } | 616 } |
| 572 | 617 |
| 618 void ShellPortMash::OnDisplayConfigurationChanging() { |
| 619 for (auto& observer : display_observers_) |
| 620 observer.OnDisplayConfigurationChanging(); |
| 621 } |
| 622 |
| 623 void ShellPortMash::OnDisplayConfigurationChanged() { |
| 624 for (auto& observer : display_observers_) |
| 625 observer.OnDisplayConfigurationChanged(); |
| 626 } |
| 627 |
| 573 } // namespace mus | 628 } // namespace mus |
| 574 } // namespace ash | 629 } // namespace ash |
| OLD | NEW |