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

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

Issue 2833093002: WIP: simplified display management in ash (Closed)
Patch Set: x Created 3 years, 8 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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>()) {
86 LOG(WARNING) << "WindowManager!";
84 property_converter_->RegisterProperty( 87 property_converter_->RegisterProperty(
85 kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property, 88 kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property,
86 aura::PropertyConverter::CreateAcceptAnyValueCallback()); 89 aura::PropertyConverter::CreateAcceptAnyValueCallback());
87 property_converter_->RegisterProperty( 90 property_converter_->RegisterProperty(
88 kRenderTitleAreaProperty, 91 kRenderTitleAreaProperty,
89 ui::mojom::WindowManager::kRenderParentTitleArea_Property, 92 ui::mojom::WindowManager::kRenderParentTitleArea_Property,
90 aura::PropertyConverter::CreateAcceptAnyValueCallback()); 93 aura::PropertyConverter::CreateAcceptAnyValueCallback());
91 property_converter_->RegisterProperty( 94 property_converter_->RegisterProperty(
92 kShelfItemTypeKey, ui::mojom::WindowManager::kShelfItemType_Property, 95 kShelfItemTypeKey, ui::mojom::WindowManager::kShelfItemType_Property,
93 base::Bind(&IsValidShelfItemType)); 96 base::Bind(&IsValidShelfItemType));
(...skipping 22 matching lines...) Expand all
116 input_device_client_ = base::MakeUnique<ui::InputDeviceClient>(); 119 input_device_client_ = base::MakeUnique<ui::InputDeviceClient>();
117 120
118 blocking_pool_ = blocking_pool; 121 blocking_pool_ = blocking_pool;
119 DCHECK(window_manager_client_); 122 DCHECK(window_manager_client_);
120 DCHECK(!window_tree_client_); 123 DCHECK(!window_tree_client_);
121 window_tree_client_ = std::move(window_tree_client); 124 window_tree_client_ = std::move(window_tree_client);
122 125
123 DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); 126 DCHECK_EQ(nullptr, ash::Shell::window_tree_client());
124 ash::Shell::set_window_tree_client(window_tree_client_.get()); 127 ash::Shell::set_window_tree_client(window_tree_client_.get());
125 128
126 // |connector_| will be null in some tests. 129 LOG(WARNING) << "config is mash? " << (config_ == Config::MASH);
127 if (connector_)
128 connector_->BindInterface(ui::mojom::kServiceName, &display_controller_);
129 130
130 screen_ = base::MakeUnique<ScreenMus>(display_controller_.get()); 131 // TODO(sky): remove and use MUS code.
131 display::Screen::SetScreenInstance(screen_.get()); 132 if (config_ == Config::MASH) {
133 // |connector_| will be null in some tests.
134 if (connector_)
135 connector_->BindInterface(ui::mojom::kServiceName, &display_controller_);
136 screen_ = base::MakeUnique<ScreenMus>(display_controller_.get());
137 display::Screen::SetScreenInstance(screen_.get());
138 }
132 139
133 pointer_watcher_event_router_ = 140 pointer_watcher_event_router_ =
134 base::MakeUnique<views::PointerWatcherEventRouter>( 141 base::MakeUnique<views::PointerWatcherEventRouter>(
135 window_tree_client_.get()); 142 window_tree_client_.get());
136 143
137 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = 144 ui::mojom::FrameDecorationValuesPtr frame_decoration_values =
138 ui::mojom::FrameDecorationValues::New(); 145 ui::mojom::FrameDecorationValues::New();
139 const gfx::Insets client_area_insets = 146 const gfx::Insets client_area_insets =
140 NonClientFrameController::GetPreferredClientAreaInsets(); 147 NonClientFrameController::GetPreferredClientAreaInsets();
141 frame_decoration_values->normal_client_area_insets = client_area_insets; 148 frame_decoration_values->normal_client_area_insets = client_area_insets;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 CreateAndRegisterRootWindowController( 226 CreateAndRegisterRootWindowController(
220 std::move(window_tree_host), screen_->GetAllDisplays()[0], 227 std::move(window_tree_host), screen_->GetAllDisplays()[0],
221 RootWindowController::RootWindowType::PRIMARY); 228 RootWindowController::RootWindowType::PRIMARY);
222 } 229 }
223 230
224 void WindowManager::CreateShell( 231 void WindowManager::CreateShell(
225 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { 232 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
226 DCHECK(!created_shell_); 233 DCHECK(!created_shell_);
227 created_shell_ = true; 234 created_shell_ = true;
228 ShellInitParams init_params; 235 ShellInitParams init_params;
229 ShellPortMash* shell_port = 236 ShellPortMash* shell_port = new ShellPortMash(
230 new ShellPortMash(WmWindow::Get(window_tree_host->window()), this, 237 window_tree_host ? WmWindow::Get(window_tree_host->window()) : nullptr,
231 pointer_watcher_event_router_.get(), 238 this, pointer_watcher_event_router_.get(),
232 create_session_state_delegate_stub_for_test_); 239 create_session_state_delegate_stub_for_test_);
233 // Shell::CreateInstance() takes ownership of ShellDelegate. 240 // Shell::CreateInstance() takes ownership of ShellDelegate.
234 init_params.delegate = shell_delegate_ ? shell_delegate_.release() 241 init_params.delegate = shell_delegate_ ? shell_delegate_.release()
235 : new ShellDelegateMus(connector_); 242 : new ShellDelegateMus(connector_);
236 init_params.primary_window_tree_host = window_tree_host.release(); 243 init_params.primary_window_tree_host = window_tree_host.release();
237 init_params.shell_port = shell_port; 244 init_params.shell_port = shell_port;
238 init_params.blocking_pool = blocking_pool_.get(); 245 init_params.blocking_pool = blocking_pool_.get();
239 Shell::CreateInstance(init_params); 246 Shell::CreateInstance(init_params);
240 } 247 }
241 248
242 void WindowManager::CreateAndRegisterRootWindowController( 249 void WindowManager::CreateAndRegisterRootWindowController(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 336
330 aura::PropertyConverter* WindowManager::GetPropertyConverter() { 337 aura::PropertyConverter* WindowManager::GetPropertyConverter() {
331 return property_converter_.get(); 338 return property_converter_.get();
332 } 339 }
333 340
334 void WindowManager::SetWindowManagerClient(aura::WindowManagerClient* client) { 341 void WindowManager::SetWindowManagerClient(aura::WindowManagerClient* client) {
335 window_manager_client_ = client; 342 window_manager_client_ = client;
336 ash::Shell::set_window_manager_client(client); 343 ash::Shell::set_window_manager_client(client);
337 } 344 }
338 345
339 void WindowManager::OnWmConnected() {} 346 void WindowManager::OnWmConnected() {
347 if (config_ == Config::MUS) {
348 CreateShell(nullptr);
349 if (show_primary_host_on_connect_)
350 Shell::GetPrimaryRootWindow()->GetHost()->Show();
351 }
352 }
340 353
341 void WindowManager::OnWmSetBounds(aura::Window* window, 354 void WindowManager::OnWmSetBounds(aura::Window* window,
342 const gfx::Rect& bounds) { 355 const gfx::Rect& bounds) {
343 // TODO(sky): this indirectly sets bounds, which is against what 356 // TODO(sky): this indirectly sets bounds, which is against what
344 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. 357 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this.
345 WmWindow::Get(window)->SetBounds(bounds); 358 WmWindow::Get(window)->SetBounds(bounds);
346 } 359 }
347 360
348 bool WindowManager::OnWmSetProperty( 361 bool WindowManager::OnWmSetProperty(
349 aura::Window* window, 362 aura::Window* window,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 DestroyRootWindowController(root_window_controller_ptr.get(), 504 DestroyRootWindowController(root_window_controller_ptr.get(),
492 in_shutdown); 505 in_shutdown);
493 break; 506 break;
494 } 507 }
495 } 508 }
496 } 509 }
497 510
498 void WindowManager::OnWmDisplayModified(const display::Display& display) { 511 void WindowManager::OnWmDisplayModified(const display::Display& display) {
499 // Ash relies on the Display being updated, then the WindowTreeHost's window, 512 // Ash relies on the Display being updated, then the WindowTreeHost's window,
500 // and finally DisplayObservers. 513 // and finally DisplayObservers.
514 // XXX make sure this isn't called for manually_created.
501 display::DisplayList& display_list = screen_->display_list(); 515 display::DisplayList& display_list = screen_->display_list();
502 std::unique_ptr<display::DisplayListObserverLock> display_lock = 516 std::unique_ptr<display::DisplayListObserverLock> display_lock =
503 display_list.SuspendObserverUpdates(); 517 display_list.SuspendObserverUpdates();
504 const bool is_primary = display_list.FindDisplayById(display.id()) == 518 const bool is_primary = display_list.FindDisplayById(display.id()) ==
505 display_list.GetPrimaryDisplayIterator(); 519 display_list.GetPrimaryDisplayIterator();
506 uint32_t display_changed_values = display_list.UpdateDisplay( 520 uint32_t display_changed_values = display_list.UpdateDisplay(
507 display, is_primary ? display::DisplayList::Type::PRIMARY 521 display, is_primary ? display::DisplayList::Type::PRIMARY
508 : display::DisplayList::Type::NOT_PRIMARY); 522 : display::DisplayList::Type::NOT_PRIMARY);
509 RootWindowController* root_window_controller = 523 RootWindowController* root_window_controller =
510 ShellPortMash::Get()->GetRootWindowControllerWithDisplayId(display.id()); 524 ShellPortMash::Get()->GetRootWindowControllerWithDisplayId(display.id());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 bool WindowManager::IsWindowActive(aura::Window* window) { 582 bool WindowManager::IsWindowActive(aura::Window* window) {
569 return Shell::Get()->activation_client()->GetActiveWindow() == window; 583 return Shell::Get()->activation_client()->GetActiveWindow() == window;
570 } 584 }
571 585
572 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { 586 void WindowManager::OnWmDeactivateWindow(aura::Window* window) {
573 Shell::Get()->activation_client()->DeactivateWindow(window); 587 Shell::Get()->activation_client()->DeactivateWindow(window);
574 } 588 }
575 589
576 } // namespace mus 590 } // namespace mus
577 } // namespace ash 591 } // 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