| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 input_device_client_ = base::MakeUnique<ui::InputDeviceClient>(); | 119 input_device_client_ = base::MakeUnique<ui::InputDeviceClient>(); |
| 120 | 120 |
| 121 blocking_pool_ = blocking_pool; | 121 blocking_pool_ = blocking_pool; |
| 122 DCHECK(window_manager_client_); | 122 DCHECK(window_manager_client_); |
| 123 DCHECK(!window_tree_client_); | 123 DCHECK(!window_tree_client_); |
| 124 window_tree_client_ = std::move(window_tree_client); | 124 window_tree_client_ = std::move(window_tree_client); |
| 125 | 125 |
| 126 DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); | 126 DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); |
| 127 ash::Shell::set_window_tree_client(window_tree_client_.get()); | 127 ash::Shell::set_window_tree_client(window_tree_client_.get()); |
| 128 | 128 |
| 129 // TODO(sky): remove and use MUS code. | 129 // TODO(sky): remove and use MUS code. This should really be |
| 130 // ShouldEnableSimplifiedDisplayManagement(), but as ShellPort hasn't been |
| 131 // created yet it can't be used here. |
| 130 if (config_ == Config::MASH) { | 132 if (config_ == Config::MASH) { |
| 131 // |connector_| is null in some tests. | 133 // |connector_| is null in some tests. |
| 132 if (connector_) | 134 if (connector_) |
| 133 connector_->BindInterface(ui::mojom::kServiceName, &display_controller_); | 135 connector_->BindInterface(ui::mojom::kServiceName, &display_controller_); |
| 134 screen_ = base::MakeUnique<ScreenMus>(display_controller_.get()); | 136 screen_ = base::MakeUnique<ScreenMus>(display_controller_.get()); |
| 135 display::Screen::SetScreenInstance(screen_.get()); | 137 display::Screen::SetScreenInstance(screen_.get()); |
| 138 InstallFrameDecorationValues(); |
| 136 } | 139 } |
| 137 | 140 |
| 138 pointer_watcher_event_router_ = | 141 pointer_watcher_event_router_ = |
| 139 base::MakeUnique<views::PointerWatcherEventRouter>( | 142 base::MakeUnique<views::PointerWatcherEventRouter>( |
| 140 window_tree_client_.get()); | 143 window_tree_client_.get()); |
| 141 | 144 |
| 142 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = | |
| 143 ui::mojom::FrameDecorationValues::New(); | |
| 144 const gfx::Insets client_area_insets = | |
| 145 NonClientFrameController::GetPreferredClientAreaInsets(); | |
| 146 frame_decoration_values->normal_client_area_insets = client_area_insets; | |
| 147 frame_decoration_values->maximized_client_area_insets = client_area_insets; | |
| 148 frame_decoration_values->max_title_bar_button_width = | |
| 149 NonClientFrameController::GetMaxTitleBarButtonWidth(); | |
| 150 window_manager_client_->SetFrameDecorationValues( | |
| 151 std::move(frame_decoration_values)); | |
| 152 | |
| 153 // Notify PointerWatcherEventRouter and CaptureSynchronizer that the capture | 145 // Notify PointerWatcherEventRouter and CaptureSynchronizer that the capture |
| 154 // client has been set. | 146 // client has been set. |
| 155 aura::client::CaptureClient* capture_client = wm_state_->capture_controller(); | 147 aura::client::CaptureClient* capture_client = wm_state_->capture_controller(); |
| 156 pointer_watcher_event_router_->AttachToCaptureClient(capture_client); | 148 pointer_watcher_event_router_->AttachToCaptureClient(capture_client); |
| 157 window_tree_client_->capture_synchronizer()->AttachToCaptureClient( | 149 window_tree_client_->capture_synchronizer()->AttachToCaptureClient( |
| 158 capture_client); | 150 capture_client); |
| 159 | 151 |
| 160 if (shell_delegate) | 152 if (shell_delegate) |
| 161 shell_delegate_ = std::move(shell_delegate); | 153 shell_delegate_ = std::move(shell_delegate); |
| 162 } | 154 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 RootWindowController::RootWindowType root_window_type) { | 246 RootWindowController::RootWindowType root_window_type) { |
| 255 RootWindowSettings* root_window_settings = | 247 RootWindowSettings* root_window_settings = |
| 256 InitRootWindowSettings(window_tree_host->window()); | 248 InitRootWindowSettings(window_tree_host->window()); |
| 257 root_window_settings->display_id = display.id(); | 249 root_window_settings->display_id = display.id(); |
| 258 std::unique_ptr<RootWindowController> root_window_controller( | 250 std::unique_ptr<RootWindowController> root_window_controller( |
| 259 new RootWindowController(nullptr, window_tree_host.release())); | 251 new RootWindowController(nullptr, window_tree_host.release())); |
| 260 root_window_controller->Init(root_window_type); | 252 root_window_controller->Init(root_window_type); |
| 261 root_window_controllers_.insert(std::move(root_window_controller)); | 253 root_window_controllers_.insert(std::move(root_window_controller)); |
| 262 } | 254 } |
| 263 | 255 |
| 256 void WindowManager::InstallFrameDecorationValues() { |
| 257 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = |
| 258 ui::mojom::FrameDecorationValues::New(); |
| 259 const gfx::Insets client_area_insets = |
| 260 NonClientFrameController::GetPreferredClientAreaInsets(); |
| 261 frame_decoration_values->normal_client_area_insets = client_area_insets; |
| 262 frame_decoration_values->maximized_client_area_insets = client_area_insets; |
| 263 frame_decoration_values->max_title_bar_button_width = |
| 264 NonClientFrameController::GetMaxTitleBarButtonWidth(); |
| 265 window_manager_client_->SetFrameDecorationValues( |
| 266 std::move(frame_decoration_values)); |
| 267 } |
| 268 |
| 264 void WindowManager::DestroyRootWindowController( | 269 void WindowManager::DestroyRootWindowController( |
| 265 RootWindowController* root_window_controller, | 270 RootWindowController* root_window_controller, |
| 266 bool in_shutdown) { | 271 bool in_shutdown) { |
| 267 if (!in_shutdown && root_window_controllers_.size() > 1) { | 272 if (!in_shutdown && root_window_controllers_.size() > 1) { |
| 268 DCHECK_NE(root_window_controller, Shell::GetPrimaryRootWindowController()); | 273 DCHECK_NE(root_window_controller, Shell::GetPrimaryRootWindowController()); |
| 269 root_window_controller->MoveWindowsTo(Shell::GetPrimaryRootWindow()); | 274 root_window_controller->MoveWindowsTo(Shell::GetPrimaryRootWindow()); |
| 270 } | 275 } |
| 271 | 276 |
| 272 root_window_controller->Shutdown(); | 277 root_window_controller->Shutdown(); |
| 273 | 278 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 ash::Shell::set_window_manager_client(client); | 339 ash::Shell::set_window_manager_client(client); |
| 335 } | 340 } |
| 336 | 341 |
| 337 void WindowManager::OnWmConnected() { | 342 void WindowManager::OnWmConnected() { |
| 338 if (config_ != Config::MUS) | 343 if (config_ != Config::MUS) |
| 339 return; | 344 return; |
| 340 | 345 |
| 341 CreateShell(nullptr); | 346 CreateShell(nullptr); |
| 342 if (show_primary_host_on_connect_) | 347 if (show_primary_host_on_connect_) |
| 343 Shell::GetPrimaryRootWindow()->GetHost()->Show(); | 348 Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
| 349 InstallFrameDecorationValues(); |
| 344 } | 350 } |
| 345 | 351 |
| 346 void WindowManager::OnWmSetBounds(aura::Window* window, | 352 void WindowManager::OnWmSetBounds(aura::Window* window, |
| 347 const gfx::Rect& bounds) { | 353 const gfx::Rect& bounds) { |
| 348 // TODO(sky): this indirectly sets bounds, which is against what | 354 // TODO(sky): this indirectly sets bounds, which is against what |
| 349 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. | 355 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. |
| 350 WmWindow::Get(window)->SetBounds(bounds); | 356 WmWindow::Get(window)->SetBounds(bounds); |
| 351 } | 357 } |
| 352 | 358 |
| 353 bool WindowManager::OnWmSetProperty( | 359 bool WindowManager::OnWmSetProperty( |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 bool WindowManager::IsWindowActive(aura::Window* window) { | 577 bool WindowManager::IsWindowActive(aura::Window* window) { |
| 572 return Shell::Get()->activation_client()->GetActiveWindow() == window; | 578 return Shell::Get()->activation_client()->GetActiveWindow() == window; |
| 573 } | 579 } |
| 574 | 580 |
| 575 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { | 581 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { |
| 576 Shell::Get()->activation_client()->DeactivateWindow(window); | 582 Shell::Get()->activation_client()->DeactivateWindow(window); |
| 577 } | 583 } |
| 578 | 584 |
| 579 } // namespace mus | 585 } // namespace mus |
| 580 } // namespace ash | 586 } // namespace ash |
| OLD | NEW |