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>()) { |
| 85 LOG(WARNING) << "WindowManager!"; |
83 property_converter_->RegisterProperty( | 86 property_converter_->RegisterProperty( |
84 kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property, | 87 kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property, |
85 aura::PropertyConverter::CreateAcceptAnyValueCallback()); | 88 aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
86 property_converter_->RegisterProperty( | 89 property_converter_->RegisterProperty( |
87 kRenderTitleAreaProperty, | 90 kRenderTitleAreaProperty, |
88 ui::mojom::WindowManager::kRenderParentTitleArea_Property, | 91 ui::mojom::WindowManager::kRenderParentTitleArea_Property, |
89 aura::PropertyConverter::CreateAcceptAnyValueCallback()); | 92 aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
90 property_converter_->RegisterProperty( | 93 property_converter_->RegisterProperty( |
91 kShelfItemTypeKey, ui::mojom::WindowManager::kShelfItemType_Property, | 94 kShelfItemTypeKey, ui::mojom::WindowManager::kShelfItemType_Property, |
92 base::Bind(&IsValidShelfItemType)); | 95 base::Bind(&IsValidShelfItemType)); |
(...skipping 17 matching lines...) Expand all Loading... |
110 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool, | 113 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool, |
111 std::unique_ptr<ShellDelegate> shell_delegate) { | 114 std::unique_ptr<ShellDelegate> shell_delegate) { |
112 blocking_pool_ = blocking_pool; | 115 blocking_pool_ = blocking_pool; |
113 DCHECK(window_manager_client_); | 116 DCHECK(window_manager_client_); |
114 DCHECK(!window_tree_client_); | 117 DCHECK(!window_tree_client_); |
115 window_tree_client_ = std::move(window_tree_client); | 118 window_tree_client_ = std::move(window_tree_client); |
116 | 119 |
117 DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); | 120 DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); |
118 ash::Shell::set_window_tree_client(window_tree_client_.get()); | 121 ash::Shell::set_window_tree_client(window_tree_client_.get()); |
119 | 122 |
120 // |connector_| will be null in some tests. | 123 LOG(WARNING) << "config is mash? " << (config_ == Config::MASH); |
121 if (connector_) | |
122 connector_->BindInterface(ui::mojom::kServiceName, &display_controller_); | |
123 | 124 |
124 screen_ = base::MakeUnique<ScreenMus>(display_controller_.get()); | 125 // TODO(sky): remove and use MUS code. |
125 display::Screen::SetScreenInstance(screen_.get()); | 126 if (config_ == Config::MASH) { |
| 127 // |connector_| will be null in some tests. |
| 128 if (connector_) |
| 129 connector_->BindInterface(ui::mojom::kServiceName, &display_controller_); |
| 130 screen_ = base::MakeUnique<ScreenMus>(display_controller_.get()); |
| 131 display::Screen::SetScreenInstance(screen_.get()); |
| 132 } |
126 | 133 |
127 pointer_watcher_event_router_ = | 134 pointer_watcher_event_router_ = |
128 base::MakeUnique<views::PointerWatcherEventRouter>( | 135 base::MakeUnique<views::PointerWatcherEventRouter>( |
129 window_tree_client_.get()); | 136 window_tree_client_.get()); |
130 | 137 |
131 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = | 138 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = |
132 ui::mojom::FrameDecorationValues::New(); | 139 ui::mojom::FrameDecorationValues::New(); |
133 const gfx::Insets client_area_insets = | 140 const gfx::Insets client_area_insets = |
134 NonClientFrameController::GetPreferredClientAreaInsets(); | 141 NonClientFrameController::GetPreferredClientAreaInsets(); |
135 frame_decoration_values->normal_client_area_insets = client_area_insets; | 142 frame_decoration_values->normal_client_area_insets = client_area_insets; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 CreateAndRegisterRootWindowController( | 220 CreateAndRegisterRootWindowController( |
214 std::move(window_tree_host), screen_->GetAllDisplays()[0], | 221 std::move(window_tree_host), screen_->GetAllDisplays()[0], |
215 RootWindowController::RootWindowType::PRIMARY); | 222 RootWindowController::RootWindowType::PRIMARY); |
216 } | 223 } |
217 | 224 |
218 void WindowManager::CreateShell( | 225 void WindowManager::CreateShell( |
219 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | 226 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
220 DCHECK(!created_shell_); | 227 DCHECK(!created_shell_); |
221 created_shell_ = true; | 228 created_shell_ = true; |
222 ShellInitParams init_params; | 229 ShellInitParams init_params; |
223 ShellPortMash* shell_port = | 230 ShellPortMash* shell_port = new ShellPortMash( |
224 new ShellPortMash(WmWindow::Get(window_tree_host->window()), this, | 231 window_tree_host ? WmWindow::Get(window_tree_host->window()) : nullptr, |
225 pointer_watcher_event_router_.get(), | 232 this, pointer_watcher_event_router_.get(), |
226 create_session_state_delegate_stub_for_test_); | 233 create_session_state_delegate_stub_for_test_); |
227 // Shell::CreateInstance() takes ownership of ShellDelegate. | 234 // Shell::CreateInstance() takes ownership of ShellDelegate. |
228 init_params.delegate = shell_delegate_ ? shell_delegate_.release() | 235 init_params.delegate = shell_delegate_ ? shell_delegate_.release() |
229 : new ShellDelegateMus(connector_); | 236 : new ShellDelegateMus(connector_); |
230 init_params.primary_window_tree_host = window_tree_host.release(); | 237 init_params.primary_window_tree_host = window_tree_host.release(); |
231 init_params.shell_port = shell_port; | 238 init_params.shell_port = shell_port; |
232 init_params.blocking_pool = blocking_pool_.get(); | 239 init_params.blocking_pool = blocking_pool_.get(); |
233 Shell::CreateInstance(init_params); | 240 Shell::CreateInstance(init_params); |
234 } | 241 } |
235 | 242 |
236 void WindowManager::CreateAndRegisterRootWindowController( | 243 void WindowManager::CreateAndRegisterRootWindowController( |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 330 |
324 aura::PropertyConverter* WindowManager::GetPropertyConverter() { | 331 aura::PropertyConverter* WindowManager::GetPropertyConverter() { |
325 return property_converter_.get(); | 332 return property_converter_.get(); |
326 } | 333 } |
327 | 334 |
328 void WindowManager::SetWindowManagerClient(aura::WindowManagerClient* client) { | 335 void WindowManager::SetWindowManagerClient(aura::WindowManagerClient* client) { |
329 window_manager_client_ = client; | 336 window_manager_client_ = client; |
330 ash::Shell::set_window_manager_client(client); | 337 ash::Shell::set_window_manager_client(client); |
331 } | 338 } |
332 | 339 |
333 void WindowManager::OnWmConnected() {} | 340 void WindowManager::OnWmConnected() { |
| 341 if (config_ == Config::MUS) { |
| 342 CreateShell(nullptr); |
| 343 if (show_primary_host_on_connect_) |
| 344 Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
| 345 } |
| 346 } |
334 | 347 |
335 void WindowManager::OnWmSetBounds(aura::Window* window, | 348 void WindowManager::OnWmSetBounds(aura::Window* window, |
336 const gfx::Rect& bounds) { | 349 const gfx::Rect& bounds) { |
337 // TODO(sky): this indirectly sets bounds, which is against what | 350 // TODO(sky): this indirectly sets bounds, which is against what |
338 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. | 351 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. |
339 WmWindow::Get(window)->SetBounds(bounds); | 352 WmWindow::Get(window)->SetBounds(bounds); |
340 } | 353 } |
341 | 354 |
342 bool WindowManager::OnWmSetProperty( | 355 bool WindowManager::OnWmSetProperty( |
343 aura::Window* window, | 356 aura::Window* window, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 DestroyRootWindowController(root_window_controller_ptr.get(), | 498 DestroyRootWindowController(root_window_controller_ptr.get(), |
486 in_shutdown); | 499 in_shutdown); |
487 break; | 500 break; |
488 } | 501 } |
489 } | 502 } |
490 } | 503 } |
491 | 504 |
492 void WindowManager::OnWmDisplayModified(const display::Display& display) { | 505 void WindowManager::OnWmDisplayModified(const display::Display& display) { |
493 // Ash relies on the Display being updated, then the WindowTreeHost's window, | 506 // Ash relies on the Display being updated, then the WindowTreeHost's window, |
494 // and finally DisplayObservers. | 507 // and finally DisplayObservers. |
| 508 // XXX make sure this isn't called for manually_created. |
495 display::DisplayList& display_list = screen_->display_list(); | 509 display::DisplayList& display_list = screen_->display_list(); |
496 std::unique_ptr<display::DisplayListObserverLock> display_lock = | 510 std::unique_ptr<display::DisplayListObserverLock> display_lock = |
497 display_list.SuspendObserverUpdates(); | 511 display_list.SuspendObserverUpdates(); |
498 const bool is_primary = display_list.FindDisplayById(display.id()) == | 512 const bool is_primary = display_list.FindDisplayById(display.id()) == |
499 display_list.GetPrimaryDisplayIterator(); | 513 display_list.GetPrimaryDisplayIterator(); |
500 uint32_t display_changed_values = display_list.UpdateDisplay( | 514 uint32_t display_changed_values = display_list.UpdateDisplay( |
501 display, is_primary ? display::DisplayList::Type::PRIMARY | 515 display, is_primary ? display::DisplayList::Type::PRIMARY |
502 : display::DisplayList::Type::NOT_PRIMARY); | 516 : display::DisplayList::Type::NOT_PRIMARY); |
503 RootWindowController* root_window_controller = | 517 RootWindowController* root_window_controller = |
504 ShellPortMash::Get()->GetRootWindowControllerWithDisplayId(display.id()); | 518 ShellPortMash::Get()->GetRootWindowControllerWithDisplayId(display.id()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 bool WindowManager::IsWindowActive(aura::Window* window) { | 576 bool WindowManager::IsWindowActive(aura::Window* window) { |
563 return Shell::Get()->activation_client()->GetActiveWindow() == window; | 577 return Shell::Get()->activation_client()->GetActiveWindow() == window; |
564 } | 578 } |
565 | 579 |
566 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { | 580 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { |
567 Shell::Get()->activation_client()->DeactivateWindow(window); | 581 Shell::Get()->activation_client()->DeactivateWindow(window); |
568 } | 582 } |
569 | 583 |
570 } // namespace mus | 584 } // namespace mus |
571 } // namespace ash | 585 } // namespace ash |
OLD | NEW |