Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: ash/mus/window_manager.cc

Issue 2840043003: chromeos: Makes mushrome use simplified display management (Closed)
Patch Set: merge Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/mus/window_manager.h ('k') | ash/mus/window_manager_application.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 CreateAndRegisterRootWindowController( 226 CreateAndRegisterRootWindowController(
223 std::move(window_tree_host), screen_->GetAllDisplays()[0], 227 std::move(window_tree_host), screen_->GetAllDisplays()[0],
224 RootWindowController::RootWindowType::PRIMARY); 228 RootWindowController::RootWindowType::PRIMARY);
225 } 229 }
226 230
227 void WindowManager::CreateShell( 231 void WindowManager::CreateShell(
228 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { 232 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
229 DCHECK(!created_shell_); 233 DCHECK(!created_shell_);
230 created_shell_ = true; 234 created_shell_ = true;
231 ShellInitParams init_params; 235 ShellInitParams init_params;
232 ShellPortMash* shell_port = 236 ShellPortMash* shell_port = new ShellPortMash(
233 new ShellPortMash(WmWindow::Get(window_tree_host->window()), this, 237 window_tree_host ? WmWindow::Get(window_tree_host->window()) : nullptr,
234 pointer_watcher_event_router_.get(), 238 this, pointer_watcher_event_router_.get(),
235 create_session_state_delegate_stub_for_test_); 239 create_session_state_delegate_stub_for_test_);
236 // Shell::CreateInstance() takes ownership of ShellDelegate. 240 // Shell::CreateInstance() takes ownership of ShellDelegate.
237 init_params.delegate = shell_delegate_ ? shell_delegate_.release() 241 init_params.delegate = shell_delegate_ ? shell_delegate_.release()
238 : new ShellDelegateMus(connector_); 242 : new ShellDelegateMus(connector_);
239 init_params.primary_window_tree_host = window_tree_host.release(); 243 init_params.primary_window_tree_host = window_tree_host.release();
240 init_params.shell_port = shell_port; 244 init_params.shell_port = shell_port;
241 init_params.blocking_pool = blocking_pool_.get(); 245 init_params.blocking_pool = blocking_pool_.get();
242 Shell::CreateInstance(init_params); 246 Shell::CreateInstance(init_params);
243 } 247 }
244 248
245 void WindowManager::CreateAndRegisterRootWindowController( 249 void WindowManager::CreateAndRegisterRootWindowController(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « ash/mus/window_manager.h ('k') | ash/mus/window_manager_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698