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