| 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) | |
| 80 : connector_(connector), | 79 : connector_(connector), |
| 81 config_(config), | 80 config_(config), |
| 82 show_primary_host_on_connect_(show_primary_host_on_connect), | |
| 83 wm_state_(base::MakeUnique<::wm::WMState>()), | 81 wm_state_(base::MakeUnique<::wm::WMState>()), |
| 84 property_converter_(base::MakeUnique<aura::PropertyConverter>()) { | 82 property_converter_(base::MakeUnique<aura::PropertyConverter>()) { |
| 85 property_converter_->RegisterProperty( | 83 property_converter_->RegisterProperty( |
| 86 kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property, | 84 kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property, |
| 87 aura::PropertyConverter::CreateAcceptAnyValueCallback()); | 85 aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
| 88 property_converter_->RegisterProperty( | 86 property_converter_->RegisterProperty( |
| 89 kRenderTitleAreaProperty, | 87 kRenderTitleAreaProperty, |
| 90 ui::mojom::WindowManager::kRenderParentTitleArea_Property, | 88 ui::mojom::WindowManager::kRenderParentTitleArea_Property, |
| 91 aura::PropertyConverter::CreateAcceptAnyValueCallback()); | 89 aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
| 92 property_converter_->RegisterProperty( | 90 property_converter_->RegisterProperty( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 117 input_device_client_ = base::MakeUnique<ui::InputDeviceClient>(); | 115 input_device_client_ = base::MakeUnique<ui::InputDeviceClient>(); |
| 118 | 116 |
| 119 blocking_pool_ = blocking_pool; | 117 blocking_pool_ = blocking_pool; |
| 120 DCHECK(window_manager_client_); | 118 DCHECK(window_manager_client_); |
| 121 DCHECK(!window_tree_client_); | 119 DCHECK(!window_tree_client_); |
| 122 window_tree_client_ = std::move(window_tree_client); | 120 window_tree_client_ = std::move(window_tree_client); |
| 123 | 121 |
| 124 DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); | 122 DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); |
| 125 ash::Shell::set_window_tree_client(window_tree_client_.get()); | 123 ash::Shell::set_window_tree_client(window_tree_client_.get()); |
| 126 | 124 |
| 127 // TODO(sky): remove and use MUS code. | 125 // |connector_| will be null in some tests. |
| 128 if (config_ == Config::MASH) { | 126 if (connector_) |
| 129 // |connector_| is null in some tests. | 127 connector_->BindInterface(ui::mojom::kServiceName, &display_controller_); |
| 130 if (connector_) | 128 |
| 131 connector_->BindInterface(ui::mojom::kServiceName, &display_controller_); | 129 screen_ = base::MakeUnique<ScreenMus>(display_controller_.get()); |
| 132 screen_ = base::MakeUnique<ScreenMus>(display_controller_.get()); | 130 display::Screen::SetScreenInstance(screen_.get()); |
| 133 display::Screen::SetScreenInstance(screen_.get()); | |
| 134 } | |
| 135 | 131 |
| 136 pointer_watcher_event_router_ = | 132 pointer_watcher_event_router_ = |
| 137 base::MakeUnique<views::PointerWatcherEventRouter>( | 133 base::MakeUnique<views::PointerWatcherEventRouter>( |
| 138 window_tree_client_.get()); | 134 window_tree_client_.get()); |
| 139 | 135 |
| 140 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = | 136 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = |
| 141 ui::mojom::FrameDecorationValues::New(); | 137 ui::mojom::FrameDecorationValues::New(); |
| 142 const gfx::Insets client_area_insets = | 138 const gfx::Insets client_area_insets = |
| 143 NonClientFrameController::GetPreferredClientAreaInsets(); | 139 NonClientFrameController::GetPreferredClientAreaInsets(); |
| 144 frame_decoration_values->normal_client_area_insets = client_area_insets; | 140 frame_decoration_values->normal_client_area_insets = client_area_insets; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 CreateAndRegisterRootWindowController( | 222 CreateAndRegisterRootWindowController( |
| 227 std::move(window_tree_host), screen_->GetAllDisplays()[0], | 223 std::move(window_tree_host), screen_->GetAllDisplays()[0], |
| 228 RootWindowController::RootWindowType::PRIMARY); | 224 RootWindowController::RootWindowType::PRIMARY); |
| 229 } | 225 } |
| 230 | 226 |
| 231 void WindowManager::CreateShell( | 227 void WindowManager::CreateShell( |
| 232 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | 228 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
| 233 DCHECK(!created_shell_); | 229 DCHECK(!created_shell_); |
| 234 created_shell_ = true; | 230 created_shell_ = true; |
| 235 ShellInitParams init_params; | 231 ShellInitParams init_params; |
| 236 ShellPortMash* shell_port = new ShellPortMash( | 232 ShellPortMash* shell_port = |
| 237 window_tree_host ? WmWindow::Get(window_tree_host->window()) : nullptr, | 233 new ShellPortMash(WmWindow::Get(window_tree_host->window()), this, |
| 238 this, pointer_watcher_event_router_.get(), | 234 pointer_watcher_event_router_.get(), |
| 239 create_session_state_delegate_stub_for_test_); | 235 create_session_state_delegate_stub_for_test_); |
| 240 // Shell::CreateInstance() takes ownership of ShellDelegate. | 236 // Shell::CreateInstance() takes ownership of ShellDelegate. |
| 241 init_params.delegate = shell_delegate_ ? shell_delegate_.release() | 237 init_params.delegate = shell_delegate_ ? shell_delegate_.release() |
| 242 : new ShellDelegateMus(connector_); | 238 : new ShellDelegateMus(connector_); |
| 243 init_params.primary_window_tree_host = window_tree_host.release(); | 239 init_params.primary_window_tree_host = window_tree_host.release(); |
| 244 init_params.shell_port = shell_port; | 240 init_params.shell_port = shell_port; |
| 245 init_params.blocking_pool = blocking_pool_.get(); | 241 init_params.blocking_pool = blocking_pool_.get(); |
| 246 Shell::CreateInstance(init_params); | 242 Shell::CreateInstance(init_params); |
| 247 } | 243 } |
| 248 | 244 |
| 249 void WindowManager::CreateAndRegisterRootWindowController( | 245 void WindowManager::CreateAndRegisterRootWindowController( |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 329 |
| 334 aura::PropertyConverter* WindowManager::GetPropertyConverter() { | 330 aura::PropertyConverter* WindowManager::GetPropertyConverter() { |
| 335 return property_converter_.get(); | 331 return property_converter_.get(); |
| 336 } | 332 } |
| 337 | 333 |
| 338 void WindowManager::SetWindowManagerClient(aura::WindowManagerClient* client) { | 334 void WindowManager::SetWindowManagerClient(aura::WindowManagerClient* client) { |
| 339 window_manager_client_ = client; | 335 window_manager_client_ = client; |
| 340 ash::Shell::set_window_manager_client(client); | 336 ash::Shell::set_window_manager_client(client); |
| 341 } | 337 } |
| 342 | 338 |
| 343 void WindowManager::OnWmConnected() { | 339 void WindowManager::OnWmConnected() {} |
| 344 if (config_ != Config::MUS) | |
| 345 return; | |
| 346 | |
| 347 CreateShell(nullptr); | |
| 348 if (show_primary_host_on_connect_) | |
| 349 Shell::GetPrimaryRootWindow()->GetHost()->Show(); | |
| 350 } | |
| 351 | 340 |
| 352 void WindowManager::OnWmSetBounds(aura::Window* window, | 341 void WindowManager::OnWmSetBounds(aura::Window* window, |
| 353 const gfx::Rect& bounds) { | 342 const gfx::Rect& bounds) { |
| 354 // TODO(sky): this indirectly sets bounds, which is against what | 343 // TODO(sky): this indirectly sets bounds, which is against what |
| 355 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. | 344 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. |
| 356 WmWindow::Get(window)->SetBounds(bounds); | 345 WmWindow::Get(window)->SetBounds(bounds); |
| 357 } | 346 } |
| 358 | 347 |
| 359 bool WindowManager::OnWmSetProperty( | 348 bool WindowManager::OnWmSetProperty( |
| 360 aura::Window* window, | 349 aura::Window* window, |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 bool WindowManager::IsWindowActive(aura::Window* window) { | 568 bool WindowManager::IsWindowActive(aura::Window* window) { |
| 580 return Shell::Get()->activation_client()->GetActiveWindow() == window; | 569 return Shell::Get()->activation_client()->GetActiveWindow() == window; |
| 581 } | 570 } |
| 582 | 571 |
| 583 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { | 572 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { |
| 584 Shell::Get()->activation_client()->DeactivateWindow(window); | 573 Shell::Get()->activation_client()->DeactivateWindow(window); |
| 585 } | 574 } |
| 586 | 575 |
| 587 } // namespace mus | 576 } // namespace mus |
| 588 } // namespace ash | 577 } // namespace ash |
| OLD | NEW |