| 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 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // An image representation of the contents of the current drag and drop | 68 // An image representation of the contents of the current drag and drop |
| 69 // clipboard. | 69 // clipboard. |
| 70 std::unique_ptr<ash::DragImageView> view; | 70 std::unique_ptr<ash::DragImageView> view; |
| 71 | 71 |
| 72 // The cursor offset of the dragged item. | 72 // The cursor offset of the dragged item. |
| 73 gfx::Vector2d image_offset; | 73 gfx::Vector2d image_offset; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 // TODO: need to register OSExchangeDataProviderMus. http://crbug.com/665077. | 76 // TODO: need to register OSExchangeDataProviderMus. http://crbug.com/665077. |
| 77 WindowManager::WindowManager(service_manager::Connector* connector, | 77 WindowManager::WindowManager(service_manager::Connector* connector, |
| 78 Config config) | 78 Config config, |
| 79 bool show_primary_host_on_connect) |
| 79 : connector_(connector), | 80 : connector_(connector), |
| 80 config_(config), | 81 config_(config), |
| 82 show_primary_host_on_connect_(show_primary_host_on_connect), |
| 81 wm_state_(base::MakeUnique<::wm::WMState>()), | 83 wm_state_(base::MakeUnique<::wm::WMState>()), |
| 82 property_converter_(base::MakeUnique<aura::PropertyConverter>()) { | 84 property_converter_(base::MakeUnique<aura::PropertyConverter>()) { |
| 83 property_converter_->RegisterProperty( | 85 property_converter_->RegisterProperty( |
| 84 kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property, | 86 kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property, |
| 85 aura::PropertyConverter::CreateAcceptAnyValueCallback()); | 87 aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
| 86 property_converter_->RegisterProperty( | 88 property_converter_->RegisterProperty( |
| 87 kRenderTitleAreaProperty, | 89 kRenderTitleAreaProperty, |
| 88 ui::mojom::WindowManager::kRenderParentTitleArea_Property, | 90 ui::mojom::WindowManager::kRenderParentTitleArea_Property, |
| 89 aura::PropertyConverter::CreateAcceptAnyValueCallback()); | 91 aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
| 90 property_converter_->RegisterProperty( | 92 property_converter_->RegisterProperty( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 115 input_device_client_ = base::MakeUnique<ui::InputDeviceClient>(); | 117 input_device_client_ = base::MakeUnique<ui::InputDeviceClient>(); |
| 116 | 118 |
| 117 blocking_pool_ = blocking_pool; | 119 blocking_pool_ = blocking_pool; |
| 118 DCHECK(window_manager_client_); | 120 DCHECK(window_manager_client_); |
| 119 DCHECK(!window_tree_client_); | 121 DCHECK(!window_tree_client_); |
| 120 window_tree_client_ = std::move(window_tree_client); | 122 window_tree_client_ = std::move(window_tree_client); |
| 121 | 123 |
| 122 DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); | 124 DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); |
| 123 ash::Shell::set_window_tree_client(window_tree_client_.get()); | 125 ash::Shell::set_window_tree_client(window_tree_client_.get()); |
| 124 | 126 |
| 125 // |connector_| will be null in some tests. | 127 // TODO(sky): remove and use MUS code. |
| 126 if (connector_) | 128 if (config_ == Config::MASH) { |
| 127 connector_->BindInterface(ui::mojom::kServiceName, &display_controller_); | 129 // |connector_| is null in some tests. |
| 128 | 130 if (connector_) |
| 129 screen_ = base::MakeUnique<ScreenMus>(display_controller_.get()); | 131 connector_->BindInterface(ui::mojom::kServiceName, &display_controller_); |
| 130 display::Screen::SetScreenInstance(screen_.get()); | 132 screen_ = base::MakeUnique<ScreenMus>(display_controller_.get()); |
| 133 display::Screen::SetScreenInstance(screen_.get()); |
| 134 } |
| 131 | 135 |
| 132 pointer_watcher_event_router_ = | 136 pointer_watcher_event_router_ = |
| 133 base::MakeUnique<views::PointerWatcherEventRouter>( | 137 base::MakeUnique<views::PointerWatcherEventRouter>( |
| 134 window_tree_client_.get()); | 138 window_tree_client_.get()); |
| 135 | 139 |
| 136 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = | 140 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = |
| 137 ui::mojom::FrameDecorationValues::New(); | 141 ui::mojom::FrameDecorationValues::New(); |
| 138 const gfx::Insets client_area_insets = | 142 const gfx::Insets client_area_insets = |
| 139 NonClientFrameController::GetPreferredClientAreaInsets(); | 143 NonClientFrameController::GetPreferredClientAreaInsets(); |
| 140 frame_decoration_values->normal_client_area_insets = client_area_insets; | 144 frame_decoration_values->normal_client_area_insets = client_area_insets; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 CreateAndRegisterRootWindowController( | 222 CreateAndRegisterRootWindowController( |
| 219 std::move(window_tree_host), screen_->GetAllDisplays()[0], | 223 std::move(window_tree_host), screen_->GetAllDisplays()[0], |
| 220 RootWindowController::RootWindowType::PRIMARY); | 224 RootWindowController::RootWindowType::PRIMARY); |
| 221 } | 225 } |
| 222 | 226 |
| 223 void WindowManager::CreateShell( | 227 void WindowManager::CreateShell( |
| 224 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | 228 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
| 225 DCHECK(!created_shell_); | 229 DCHECK(!created_shell_); |
| 226 created_shell_ = true; | 230 created_shell_ = true; |
| 227 ShellInitParams init_params; | 231 ShellInitParams init_params; |
| 228 ShellPortMash* shell_port = | 232 ShellPortMash* shell_port = new ShellPortMash( |
| 229 new ShellPortMash(WmWindow::Get(window_tree_host->window()), this, | 233 window_tree_host ? WmWindow::Get(window_tree_host->window()) : nullptr, |
| 230 pointer_watcher_event_router_.get(), | 234 this, pointer_watcher_event_router_.get(), |
| 231 create_session_state_delegate_stub_for_test_); | 235 create_session_state_delegate_stub_for_test_); |
| 232 // Shell::CreateInstance() takes ownership of ShellDelegate. | 236 // Shell::CreateInstance() takes ownership of ShellDelegate. |
| 233 init_params.delegate = shell_delegate_ ? shell_delegate_.release() | 237 init_params.delegate = shell_delegate_ ? shell_delegate_.release() |
| 234 : new ShellDelegateMus(connector_); | 238 : new ShellDelegateMus(connector_); |
| 235 init_params.primary_window_tree_host = window_tree_host.release(); | 239 init_params.primary_window_tree_host = window_tree_host.release(); |
| 236 init_params.shell_port = shell_port; | 240 init_params.shell_port = shell_port; |
| 237 init_params.blocking_pool = blocking_pool_.get(); | 241 init_params.blocking_pool = blocking_pool_.get(); |
| 238 Shell::CreateInstance(init_params); | 242 Shell::CreateInstance(init_params); |
| 239 } | 243 } |
| 240 | 244 |
| 241 void WindowManager::CreateAndRegisterRootWindowController( | 245 void WindowManager::CreateAndRegisterRootWindowController( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 325 |
| 322 aura::PropertyConverter* WindowManager::GetPropertyConverter() { | 326 aura::PropertyConverter* WindowManager::GetPropertyConverter() { |
| 323 return property_converter_.get(); | 327 return property_converter_.get(); |
| 324 } | 328 } |
| 325 | 329 |
| 326 void WindowManager::SetWindowManagerClient(aura::WindowManagerClient* client) { | 330 void WindowManager::SetWindowManagerClient(aura::WindowManagerClient* client) { |
| 327 window_manager_client_ = client; | 331 window_manager_client_ = client; |
| 328 ash::Shell::set_window_manager_client(client); | 332 ash::Shell::set_window_manager_client(client); |
| 329 } | 333 } |
| 330 | 334 |
| 331 void WindowManager::OnWmConnected() {} | 335 void WindowManager::OnWmConnected() { |
| 336 if (config_ != Config::MUS) |
| 337 return; |
| 338 |
| 339 CreateShell(nullptr); |
| 340 if (show_primary_host_on_connect_) |
| 341 Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
| 342 } |
| 332 | 343 |
| 333 void WindowManager::OnWmSetBounds(aura::Window* window, | 344 void WindowManager::OnWmSetBounds(aura::Window* window, |
| 334 const gfx::Rect& bounds) { | 345 const gfx::Rect& bounds) { |
| 335 // TODO(sky): this indirectly sets bounds, which is against what | 346 // TODO(sky): this indirectly sets bounds, which is against what |
| 336 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. | 347 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. |
| 337 WmWindow::Get(window)->SetBounds(bounds); | 348 WmWindow::Get(window)->SetBounds(bounds); |
| 338 } | 349 } |
| 339 | 350 |
| 340 bool WindowManager::OnWmSetProperty( | 351 bool WindowManager::OnWmSetProperty( |
| 341 aura::Window* window, | 352 aura::Window* window, |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 bool WindowManager::IsWindowActive(aura::Window* window) { | 571 bool WindowManager::IsWindowActive(aura::Window* window) { |
| 561 return Shell::Get()->activation_client()->GetActiveWindow() == window; | 572 return Shell::Get()->activation_client()->GetActiveWindow() == window; |
| 562 } | 573 } |
| 563 | 574 |
| 564 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { | 575 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { |
| 565 Shell::Get()->activation_client()->DeactivateWindow(window); | 576 Shell::Get()->activation_client()->DeactivateWindow(window); |
| 566 } | 577 } |
| 567 | 578 |
| 568 } // namespace mus | 579 } // namespace mus |
| 569 } // namespace ash | 580 } // namespace ash |
| OLD | NEW |