| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/window_manager.h" | 5 #include "ash/mus/window_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "ash/common/drag_drop/drag_image_view.h" | 11 #include "ash/common/drag_drop/drag_image_view.h" |
| 12 #include "ash/common/session/session_controller.h" | 12 #include "ash/common/session/session_controller.h" |
| 13 #include "ash/common/wm/container_finder.h" | 13 #include "ash/common/wm/container_finder.h" |
| 14 #include "ash/common/wm/window_state.h" | 14 #include "ash/common/wm/window_state.h" |
| 15 #include "ash/common/wm_window.h" | 15 #include "ash/common/wm_window.h" |
| 16 #include "ash/mus/accelerators/accelerator_handler.h" | 16 #include "ash/mus/accelerators/accelerator_handler.h" |
| 17 #include "ash/mus/accelerators/accelerator_ids.h" | 17 #include "ash/mus/accelerators/accelerator_ids.h" |
| 18 #include "ash/mus/bridge/wm_shell_mus.h" | 18 #include "ash/mus/bridge/wm_shell_mus.h" |
| 19 #include "ash/mus/move_event_handler.h" | 19 #include "ash/mus/move_event_handler.h" |
| 20 #include "ash/mus/non_client_frame_controller.h" | 20 #include "ash/mus/non_client_frame_controller.h" |
| 21 #include "ash/mus/property_util.h" | 21 #include "ash/mus/property_util.h" |
| 22 #include "ash/mus/screen_mus.h" | 22 #include "ash/mus/screen_mus.h" |
| 23 #include "ash/mus/shell_delegate_mus.h" | 23 #include "ash/mus/shell_delegate_mus.h" |
| 24 #include "ash/mus/top_level_window_factory.h" | 24 #include "ash/mus/top_level_window_factory.h" |
| 25 #include "ash/mus/window_properties.h" | 25 #include "ash/mus/window_properties.h" |
| 26 #include "ash/public/cpp/config.h" |
| 26 #include "ash/public/cpp/shelf_types.h" | 27 #include "ash/public/cpp/shelf_types.h" |
| 27 #include "ash/public/cpp/shell_window_ids.h" | 28 #include "ash/public/cpp/shell_window_ids.h" |
| 28 #include "ash/public/cpp/window_properties.h" | 29 #include "ash/public/cpp/window_properties.h" |
| 29 #include "ash/root_window_controller.h" | 30 #include "ash/root_window_controller.h" |
| 30 #include "ash/root_window_settings.h" | 31 #include "ash/root_window_settings.h" |
| 31 #include "ash/shell.h" | 32 #include "ash/shell.h" |
| 32 #include "ash/shell_init_params.h" | 33 #include "ash/shell_init_params.h" |
| 33 #include "ash/wm/ash_focus_rules.h" | 34 #include "ash/wm/ash_focus_rules.h" |
| 34 #include "base/memory/ptr_util.h" | 35 #include "base/memory/ptr_util.h" |
| 35 #include "base/threading/sequenced_worker_pool.h" | 36 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 64 struct WindowManager::DragState { | 65 struct WindowManager::DragState { |
| 65 // An image representation of the contents of the current drag and drop | 66 // An image representation of the contents of the current drag and drop |
| 66 // clipboard. | 67 // clipboard. |
| 67 std::unique_ptr<ash::DragImageView> view; | 68 std::unique_ptr<ash::DragImageView> view; |
| 68 | 69 |
| 69 // The cursor offset of the dragged item. | 70 // The cursor offset of the dragged item. |
| 70 gfx::Vector2d image_offset; | 71 gfx::Vector2d image_offset; |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 // TODO: need to register OSExchangeDataProviderMus. http://crbug.com/665077. | 74 // TODO: need to register OSExchangeDataProviderMus. http://crbug.com/665077. |
| 74 WindowManager::WindowManager(service_manager::Connector* connector) | 75 WindowManager::WindowManager(service_manager::Connector* connector, |
| 76 Config config) |
| 75 : connector_(connector), | 77 : connector_(connector), |
| 78 config_(config), |
| 76 wm_state_(base::MakeUnique<::wm::WMState>()), | 79 wm_state_(base::MakeUnique<::wm::WMState>()), |
| 77 property_converter_(base::MakeUnique<aura::PropertyConverter>()) { | 80 property_converter_(base::MakeUnique<aura::PropertyConverter>()) { |
| 78 property_converter_->RegisterProperty( | 81 property_converter_->RegisterProperty( |
| 79 kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property, | 82 kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property, |
| 80 aura::PropertyConverter::CreateAcceptAnyValueCallback()); | 83 aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
| 81 property_converter_->RegisterProperty( | 84 property_converter_->RegisterProperty( |
| 82 kRenderTitleAreaProperty, | 85 kRenderTitleAreaProperty, |
| 83 ui::mojom::WindowManager::kRenderParentTitleArea_Property, | 86 ui::mojom::WindowManager::kRenderParentTitleArea_Property, |
| 84 aura::PropertyConverter::CreateAcceptAnyValueCallback()); | 87 aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
| 85 property_converter_->RegisterProperty( | 88 property_converter_->RegisterProperty( |
| 86 kShelfItemTypeKey, ui::mojom::WindowManager::kShelfItemType_Property, | 89 kShelfItemTypeKey, ui::mojom::WindowManager::kShelfItemType_Property, |
| 87 base::Bind(&IsValidShelfItemType)); | 90 base::Bind(&IsValidShelfItemType)); |
| 88 property_converter_->RegisterProperty( | 91 property_converter_->RegisterProperty( |
| 89 ::wm::kShadowElevationKey, | 92 ::wm::kShadowElevationKey, |
| 90 ui::mojom::WindowManager::kShadowElevation_Property, | 93 ui::mojom::WindowManager::kShadowElevation_Property, |
| 91 base::Bind(&::wm::IsValidShadowElevation)); | 94 base::Bind(&::wm::IsValidShadowElevation)); |
| 92 } | 95 } |
| 93 | 96 |
| 94 WindowManager::~WindowManager() { | 97 WindowManager::~WindowManager() { |
| 95 Shutdown(); | 98 Shutdown(); |
| 96 ash::Shell::set_window_tree_client(nullptr); | 99 ash::Shell::set_window_tree_client(nullptr); |
| 97 ash::Shell::set_window_manager_client(nullptr); | 100 ash::Shell::set_window_manager_client(nullptr); |
| 98 } | 101 } |
| 99 | 102 |
| 100 void WindowManager::Init( | 103 void WindowManager::Init( |
| 101 std::unique_ptr<aura::WindowTreeClient> window_tree_client, | 104 std::unique_ptr<aura::WindowTreeClient> window_tree_client, |
| 102 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) { | 105 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool, |
| 106 std::unique_ptr<ShellDelegate> shell_delegate) { |
| 103 blocking_pool_ = blocking_pool; | 107 blocking_pool_ = blocking_pool; |
| 104 DCHECK(window_manager_client_); | 108 DCHECK(window_manager_client_); |
| 105 DCHECK(!window_tree_client_); | 109 DCHECK(!window_tree_client_); |
| 106 window_tree_client_ = std::move(window_tree_client); | 110 window_tree_client_ = std::move(window_tree_client); |
| 107 | 111 |
| 108 DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); | 112 DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); |
| 109 ash::Shell::set_window_tree_client(window_tree_client_.get()); | 113 ash::Shell::set_window_tree_client(window_tree_client_.get()); |
| 110 | 114 |
| 111 // |connector_| will be null in some tests. | 115 // |connector_| will be null in some tests. |
| 112 if (connector_) | 116 if (connector_) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 129 NonClientFrameController::GetMaxTitleBarButtonWidth(); | 133 NonClientFrameController::GetMaxTitleBarButtonWidth(); |
| 130 window_manager_client_->SetFrameDecorationValues( | 134 window_manager_client_->SetFrameDecorationValues( |
| 131 std::move(frame_decoration_values)); | 135 std::move(frame_decoration_values)); |
| 132 | 136 |
| 133 // Notify PointerWatcherEventRouter and CaptureSynchronizer that the capture | 137 // Notify PointerWatcherEventRouter and CaptureSynchronizer that the capture |
| 134 // client has been set. | 138 // client has been set. |
| 135 aura::client::CaptureClient* capture_client = wm_state_->capture_controller(); | 139 aura::client::CaptureClient* capture_client = wm_state_->capture_controller(); |
| 136 pointer_watcher_event_router_->AttachToCaptureClient(capture_client); | 140 pointer_watcher_event_router_->AttachToCaptureClient(capture_client); |
| 137 window_tree_client_->capture_synchronizer()->AttachToCaptureClient( | 141 window_tree_client_->capture_synchronizer()->AttachToCaptureClient( |
| 138 capture_client); | 142 capture_client); |
| 143 |
| 144 if (shell_delegate) |
| 145 shell_delegate_ = std::move(shell_delegate); |
| 146 } |
| 147 |
| 148 bool WindowManager::WaitForInitialDisplays() { |
| 149 return window_manager_client_->WaitForInitialDisplays(); |
| 139 } | 150 } |
| 140 | 151 |
| 141 void WindowManager::DeleteAllRootWindowControllers() { | 152 void WindowManager::DeleteAllRootWindowControllers() { |
| 142 // Primary RootWindowController must be destroyed last. | 153 // Primary RootWindowController must be destroyed last. |
| 143 RootWindowController* primary_root_window_controller = | 154 RootWindowController* primary_root_window_controller = |
| 144 GetPrimaryRootWindowController(); | 155 GetPrimaryRootWindowController(); |
| 145 std::set<RootWindowController*> secondary_root_window_controllers; | 156 std::set<RootWindowController*> secondary_root_window_controllers; |
| 146 for (auto& root_window_controller_ptr : root_window_controllers_) { | 157 for (auto& root_window_controller_ptr : root_window_controllers_) { |
| 147 if (root_window_controller_ptr.get() != primary_root_window_controller) { | 158 if (root_window_controller_ptr.get() != primary_root_window_controller) { |
| 148 secondary_root_window_controllers.insert( | 159 secondary_root_window_controllers.insert( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 void WindowManager::CreateShell( | 213 void WindowManager::CreateShell( |
| 203 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | 214 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
| 204 DCHECK(!created_shell_); | 215 DCHECK(!created_shell_); |
| 205 created_shell_ = true; | 216 created_shell_ = true; |
| 206 ShellInitParams init_params; | 217 ShellInitParams init_params; |
| 207 WmShellMus* wm_shell = new WmShellMus( | 218 WmShellMus* wm_shell = new WmShellMus( |
| 208 WmWindow::Get(window_tree_host->window()), | 219 WmWindow::Get(window_tree_host->window()), |
| 209 this, pointer_watcher_event_router_.get(), | 220 this, pointer_watcher_event_router_.get(), |
| 210 create_session_state_delegate_stub_for_test_); | 221 create_session_state_delegate_stub_for_test_); |
| 211 // Shell::CreateInstance() takes ownership of ShellDelegate. | 222 // Shell::CreateInstance() takes ownership of ShellDelegate. |
| 212 init_params.delegate = shell_delegate_for_test_ | 223 init_params.delegate = shell_delegate_ ? shell_delegate_.release() |
| 213 ? shell_delegate_for_test_.release() | 224 : new ShellDelegateMus(connector_); |
| 214 : new ShellDelegateMus(connector_); | |
| 215 init_params.primary_window_tree_host = window_tree_host.release(); | 225 init_params.primary_window_tree_host = window_tree_host.release(); |
| 216 init_params.wm_shell = wm_shell; | 226 init_params.wm_shell = wm_shell; |
| 217 init_params.blocking_pool = blocking_pool_.get(); | 227 init_params.blocking_pool = blocking_pool_.get(); |
| 218 Shell::CreateInstance(init_params); | 228 Shell::CreateInstance(init_params); |
| 219 } | 229 } |
| 220 | 230 |
| 221 void WindowManager::CreateAndRegisterRootWindowController( | 231 void WindowManager::CreateAndRegisterRootWindowController( |
| 222 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, | 232 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, |
| 223 const display::Display& display, | 233 const display::Display& display, |
| 224 RootWindowController::RootWindowType root_window_type) { | 234 RootWindowController::RootWindowType root_window_type) { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 bool WindowManager::IsWindowActive(aura::Window* window) { | 541 bool WindowManager::IsWindowActive(aura::Window* window) { |
| 532 return Shell::GetInstance()->activation_client()->GetActiveWindow() == window; | 542 return Shell::GetInstance()->activation_client()->GetActiveWindow() == window; |
| 533 } | 543 } |
| 534 | 544 |
| 535 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { | 545 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { |
| 536 Shell::GetInstance()->activation_client()->DeactivateWindow(window); | 546 Shell::GetInstance()->activation_client()->DeactivateWindow(window); |
| 537 } | 547 } |
| 538 | 548 |
| 539 } // namespace mus | 549 } // namespace mus |
| 540 } // namespace ash | 550 } // namespace ash |
| OLD | NEW |