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

Side by Side Diff: components/mus/ws/display.cc

Issue 2072343002: Changes how window manager obtains WindowTree from mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include Created 4 years, 6 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 | « components/mus/ws/display.h ('k') | components/mus/ws/display_unittest.cc » ('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 "components/mus/ws/display.h" 5 #include "components/mus/ws/display.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/debug/debugger.h" 10 #include "base/debug/debugger.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "components/mus/common/types.h" 12 #include "components/mus/common/types.h"
13 #include "components/mus/ws/display_binding.h" 13 #include "components/mus/ws/display_binding.h"
14 #include "components/mus/ws/display_manager.h" 14 #include "components/mus/ws/display_manager.h"
15 #include "components/mus/ws/focus_controller.h" 15 #include "components/mus/ws/focus_controller.h"
16 #include "components/mus/ws/platform_display.h" 16 #include "components/mus/ws/platform_display.h"
17 #include "components/mus/ws/platform_display_init_params.h" 17 #include "components/mus/ws/platform_display_init_params.h"
18 #include "components/mus/ws/window_manager_factory_service.h"
19 #include "components/mus/ws/window_manager_state.h" 18 #include "components/mus/ws/window_manager_state.h"
19 #include "components/mus/ws/window_manager_window_tree_factory.h"
20 #include "components/mus/ws/window_server.h" 20 #include "components/mus/ws/window_server.h"
21 #include "components/mus/ws/window_server_delegate.h" 21 #include "components/mus/ws/window_server_delegate.h"
22 #include "components/mus/ws/window_tree.h" 22 #include "components/mus/ws/window_tree.h"
23 #include "components/mus/ws/window_tree_binding.h" 23 #include "components/mus/ws/window_tree_binding.h"
24 #include "mojo/common/common_type_converters.h" 24 #include "mojo/common/common_type_converters.h"
25 #include "services/shell/public/interfaces/connector.mojom.h" 25 #include "services/shell/public/interfaces/connector.mojom.h"
26 #include "ui/base/cursor/cursor.h" 26 #include "ui/base/cursor/cursor.h"
27 27
28 namespace mus { 28 namespace mus {
29 namespace ws { 29 namespace ws {
30 30
31 Display::Display(WindowServer* window_server, 31 Display::Display(WindowServer* window_server,
32 const PlatformDisplayInitParams& platform_display_init_params) 32 const PlatformDisplayInitParams& platform_display_init_params)
33 : id_(window_server->display_manager()->GetAndAdvanceNextDisplayId()), 33 : id_(window_server->display_manager()->GetAndAdvanceNextDisplayId()),
34 window_server_(window_server), 34 window_server_(window_server),
35 platform_display_(PlatformDisplay::Create(platform_display_init_params)), 35 platform_display_(PlatformDisplay::Create(platform_display_init_params)),
36 last_cursor_(ui::kCursorNone) { 36 last_cursor_(ui::kCursorNone) {
37 platform_display_->Init(this); 37 platform_display_->Init(this);
38 38
39 window_server_->window_manager_factory_registry()->AddObserver(this); 39 window_server_->window_manager_window_tree_factory_set()->AddObserver(this);
40 window_server_->user_id_tracker()->AddObserver(this); 40 window_server_->user_id_tracker()->AddObserver(this);
41 } 41 }
42 42
43 Display::~Display() { 43 Display::~Display() {
44 window_server_->user_id_tracker()->RemoveObserver(this); 44 window_server_->user_id_tracker()->RemoveObserver(this);
45 45
46 window_server_->window_manager_factory_registry()->RemoveObserver(this); 46 window_server_->window_manager_window_tree_factory_set()->RemoveObserver(
47 this);
47 48
48 if (!focus_controller_) { 49 if (!focus_controller_) {
49 focus_controller_->RemoveObserver(this); 50 focus_controller_->RemoveObserver(this);
50 focus_controller_.reset(); 51 focus_controller_.reset();
51 } 52 }
52 53
53 for (ServerWindow* window : windows_needing_frame_destruction_) 54 for (ServerWindow* window : windows_needing_frame_destruction_)
54 window->RemoveObserver(this); 55 window->RemoveObserver(this);
55 56
56 // Destroy any trees, which triggers destroying the WindowManagerState. Copy 57 // Destroy any trees, which triggers destroying the WindowManagerState. Copy
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 display_manager()->OnDisplayAcceleratedWidgetAvailable(this); 225 display_manager()->OnDisplayAcceleratedWidgetAvailable(this);
225 if (binding_) { 226 if (binding_) {
226 std::unique_ptr<WindowManagerState> wms_ptr( 227 std::unique_ptr<WindowManagerState> wms_ptr(
227 new WindowManagerState(this, platform_display_.get())); 228 new WindowManagerState(this, platform_display_.get()));
228 WindowManagerState* wms = wms_ptr.get(); 229 WindowManagerState* wms = wms_ptr.get();
229 // For this case we never create additional WindowManagerStates, so any 230 // For this case we never create additional WindowManagerStates, so any
230 // id works. 231 // id works.
231 window_manager_state_map_[shell::mojom::kRootUserID] = std::move(wms_ptr); 232 window_manager_state_map_[shell::mojom::kRootUserID] = std::move(wms_ptr);
232 wms->tree_ = binding_->CreateWindowTree(wms->root()); 233 wms->tree_ = binding_->CreateWindowTree(wms->root());
233 } else { 234 } else {
234 CreateWindowManagerStatesFromRegistry(); 235 CreateWindowManagerStatesFromFactories();
235 } 236 }
236 } 237 }
237 238
238 void Display::CreateWindowManagerStatesFromRegistry() { 239 void Display::CreateWindowManagerStatesFromFactories() {
239 std::vector<WindowManagerFactoryService*> services = 240 std::vector<WindowManagerWindowTreeFactory*> factories =
240 window_server_->window_manager_factory_registry()->GetServices(); 241 window_server_->window_manager_window_tree_factory_set()->GetFactories();
241 for (WindowManagerFactoryService* service : services) { 242 for (WindowManagerWindowTreeFactory* factory : factories) {
242 if (service->window_manager_factory()) 243 if (factory->window_tree())
243 CreateWindowManagerStateFromService(service); 244 CreateWindowManagerStateFromFactory(factory);
244 } 245 }
245 } 246 }
246 247
247 void Display::CreateWindowManagerStateFromService( 248 void Display::CreateWindowManagerStateFromFactory(
248 WindowManagerFactoryService* service) { 249 WindowManagerWindowTreeFactory* factory) {
249 std::unique_ptr<WindowManagerState> wms_ptr(new WindowManagerState( 250 std::unique_ptr<WindowManagerState> wms_ptr(new WindowManagerState(
250 this, platform_display_.get(), service->user_id())); 251 this, platform_display_.get(), factory->user_id()));
251 WindowManagerState* wms = wms_ptr.get(); 252 WindowManagerState* wms = wms_ptr.get();
252 window_manager_state_map_[service->user_id()] = std::move(wms_ptr); 253 window_manager_state_map_[factory->user_id()] = std::move(wms_ptr);
253 wms->tree_ = window_server_->CreateTreeForWindowManager( 254 wms->tree_ = factory->window_tree();
254 this, service->window_manager_factory(), wms->root(), service->user_id());
255 if (!binding_) { 255 if (!binding_) {
256 const bool is_active = 256 const bool is_active =
257 service->user_id() == window_server_->user_id_tracker()->active_id(); 257 factory->user_id() == window_server_->user_id_tracker()->active_id();
258 wms->root()->SetVisible(is_active); 258 wms->root()->SetVisible(is_active);
259 wms->tree_->AddRootForWindowManager(wms->root());
259 } 260 }
260 } 261 }
261 262
262 ServerWindow* Display::GetRootWindow() { 263 ServerWindow* Display::GetRootWindow() {
263 return root_.get(); 264 return root_.get();
264 } 265 }
265 266
266 void Display::OnEvent(const ui::Event& event) { 267 void Display::OnEvent(const ui::Event& event) {
267 WindowManagerState* wms = GetActiveWindowManagerState(); 268 WindowManagerState* wms = GetActiveWindowManagerState();
268 if (wms) 269 if (wms)
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 WindowManagerState* state = GetWindowManagerStateForUser(id); 438 WindowManagerState* state = GetWindowManagerStateForUser(id);
438 if (!state) 439 if (!state)
439 return; 440 return;
440 441
441 // DestroyTree() calls back to OnWillDestroyTree() and the WindowManagerState 442 // DestroyTree() calls back to OnWillDestroyTree() and the WindowManagerState
442 // is destroyed (and removed). 443 // is destroyed (and removed).
443 window_server_->DestroyTree(state->tree()); 444 window_server_->DestroyTree(state->tree());
444 DCHECK_EQ(0u, window_manager_state_map_.count(id)); 445 DCHECK_EQ(0u, window_manager_state_map_.count(id));
445 } 446 }
446 447
447 void Display::OnWindowManagerFactorySet(WindowManagerFactoryService* service) { 448 void Display::OnWindowManagerWindowTreeFactoryReady(
449 WindowManagerWindowTreeFactory* factory) {
448 if (!binding_) 450 if (!binding_)
449 CreateWindowManagerStateFromService(service); 451 CreateWindowManagerStateFromFactory(factory);
450 } 452 }
451 453
452 } // namespace ws 454 } // namespace ws
453 } // namespace mus 455 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/display.h ('k') | components/mus/ws/display_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698