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

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

Issue 1757403002: More user id tracking for mus: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweaks Created 4 years, 9 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
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/window_tree_host_impl.h" 5 #include "components/mus/ws/window_tree_host_impl.h"
6 6
7 #include "base/debug/debugger.h" 7 #include "base/debug/debugger.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "components/mus/common/types.h" 9 #include "components/mus/common/types.h"
10 #include "components/mus/ws/client_connection.h" 10 #include "components/mus/ws/client_connection.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 display_manager_( 97 display_manager_(
98 DisplayManager::Create(connector, gpu_state, surfaces_state)), 98 DisplayManager::Create(connector, gpu_state, surfaces_state)),
99 tree_awaiting_input_ack_(nullptr), 99 tree_awaiting_input_ack_(nullptr),
100 last_cursor_(0) { 100 last_cursor_(0) {
101 frame_decoration_values_ = mojom::FrameDecorationValues::New(); 101 frame_decoration_values_ = mojom::FrameDecorationValues::New();
102 frame_decoration_values_->normal_client_area_insets = mojo::Insets::New(); 102 frame_decoration_values_->normal_client_area_insets = mojo::Insets::New();
103 frame_decoration_values_->maximized_client_area_insets = mojo::Insets::New(); 103 frame_decoration_values_->maximized_client_area_insets = mojo::Insets::New();
104 frame_decoration_values_->max_title_bar_button_width = 0u; 104 frame_decoration_values_->max_title_bar_button_width = 0u;
105 105
106 display_manager_->Init(this); 106 display_manager_->Init(this);
107
108 connection_manager_->window_manager_factory_registry()->AddObserver(this);
107 } 109 }
108 110
109 WindowTreeHostImpl::~WindowTreeHostImpl() { 111 WindowTreeHostImpl::~WindowTreeHostImpl() {
112 connection_manager_->window_manager_factory_registry()->RemoveObserver(this);
113
110 DestroyFocusController(); 114 DestroyFocusController();
111 for (ServerWindow* window : windows_needing_frame_destruction_) 115 for (ServerWindow* window : windows_needing_frame_destruction_)
112 window->RemoveObserver(this); 116 window->RemoveObserver(this);
113 117
114 // TODO(sky): this may leave the WindowTreeImpls associated with the 118 // Destroy any trees, which triggers destroying the WindowManagerState. Copy
115 // WindowManagerStates still alive. The shutdown ordering is a bit iffy, 119 // off the WindowManagerStates as destruction mutates
116 // figure out what it should be. ConnectionManager::OnConnectionError() 120 // |window_manager_state_map_|.
117 // has a check that effects this too. 121 std::set<WindowManagerState*> states;
122 for (auto& pair : window_manager_state_map_)
123 states.insert(pair.second.get());
124 for (WindowManagerState* state : states)
125 connection_manager_->DestroyTree(state->tree());
118 } 126 }
119 127
120 void WindowTreeHostImpl::Init(scoped_ptr<WindowTreeHostConnection> connection) { 128 void WindowTreeHostImpl::Init(scoped_ptr<WindowTreeHostConnection> connection) {
121 init_called_ = true; 129 init_called_ = true;
122 window_tree_host_connection_ = std::move(connection); 130 window_tree_host_connection_ = std::move(connection);
123 connection_manager_->AddHost(this); 131 connection_manager_->AddHost(this);
124 InitWindowManagersIfNecessary(); 132 InitWindowManagersIfNecessary();
125 } 133 }
126 134
127 void WindowTreeHostImpl::SetFrameDecorationValues( 135 void WindowTreeHostImpl::SetFrameDecorationValues(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 181 }
174 return nullptr; 182 return nullptr;
175 } 183 }
176 184
177 WindowManagerState* WindowTreeHostImpl::GetFirstWindowManagerState() { 185 WindowManagerState* WindowTreeHostImpl::GetFirstWindowManagerState() {
178 return window_manager_state_map_.empty() 186 return window_manager_state_map_.empty()
179 ? nullptr 187 ? nullptr
180 : window_manager_state_map_.begin()->second.get(); 188 : window_manager_state_map_.begin()->second.get();
181 } 189 }
182 190
191 WindowManagerState* WindowTreeHostImpl::GetWindowManagerStateForUser(
192 UserId user_id) {
193 auto iter = window_manager_state_map_.find(user_id);
194 return iter == window_manager_state_map_.end() ? nullptr : iter->second.get();
195 }
196
183 void WindowTreeHostImpl::SetCapture(ServerWindow* window, 197 void WindowTreeHostImpl::SetCapture(ServerWindow* window,
184 bool in_nonclient_area) { 198 bool in_nonclient_area) {
185 ServerWindow* capture_window = event_dispatcher_.capture_window(); 199 ServerWindow* capture_window = event_dispatcher_.capture_window();
186 if (capture_window == window) 200 if (capture_window == window)
187 return; 201 return;
188 event_dispatcher_.SetCaptureWindow(window, in_nonclient_area); 202 event_dispatcher_.SetCaptureWindow(window, in_nonclient_area);
189 } 203 }
190 204
191 mojom::Rotation WindowTreeHostImpl::GetRotation() const { 205 mojom::Rotation WindowTreeHostImpl::GetRotation() const {
192 return display_manager_->GetRotation(); 206 return display_manager_->GetRotation();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 &WindowTreeHostImpl::OnEventAckTimeout); 382 &WindowTreeHostImpl::OnEventAckTimeout);
369 383
370 tree_awaiting_input_ack_ = connection; 384 tree_awaiting_input_ack_ = connection;
371 connection->DispatchInputEvent(target, mojom::Event::From(event)); 385 connection->DispatchInputEvent(target, mojom::Event::From(event));
372 } 386 }
373 387
374 void WindowTreeHostImpl::CreateWindowManagerStatesFromRegistry() { 388 void WindowTreeHostImpl::CreateWindowManagerStatesFromRegistry() {
375 std::vector<WindowManagerFactoryService*> services = 389 std::vector<WindowManagerFactoryService*> services =
376 connection_manager_->window_manager_factory_registry()->GetServices(); 390 connection_manager_->window_manager_factory_registry()->GetServices();
377 for (WindowManagerFactoryService* service : services) { 391 for (WindowManagerFactoryService* service : services) {
378 scoped_ptr<WindowManagerState> wms_ptr( 392 if (service->window_manager_factory())
379 new WindowManagerState(this, service->user_id())); 393 CreateWindowManagerStateFromService(service);
380 WindowManagerState* wms = wms_ptr.get();
381 window_manager_state_map_[service->user_id()] = std::move(wms_ptr);
382 wms->tree_ = connection_manager_->CreateTreeForWindowManager(
383 this, service->window_manager_factory(), wms->root());
384 } 394 }
385 } 395 }
386 396
397 void WindowTreeHostImpl::CreateWindowManagerStateFromService(
398 WindowManagerFactoryService* service) {
399 scoped_ptr<WindowManagerState> wms_ptr(
400 new WindowManagerState(this, service->user_id()));
401 WindowManagerState* wms = wms_ptr.get();
402 window_manager_state_map_[service->user_id()] = std::move(wms_ptr);
403 wms->tree_ = connection_manager_->CreateTreeForWindowManager(
404 this, service->window_manager_factory(), wms->root());
405 }
406
387 void WindowTreeHostImpl::UpdateNativeCursor(int32_t cursor_id) { 407 void WindowTreeHostImpl::UpdateNativeCursor(int32_t cursor_id) {
388 if (cursor_id != last_cursor_) { 408 if (cursor_id != last_cursor_) {
389 display_manager_->SetCursorById(cursor_id); 409 display_manager_->SetCursorById(cursor_id);
390 last_cursor_ = cursor_id; 410 last_cursor_ = cursor_id;
391 } 411 }
392 } 412 }
393 413
394 ServerWindow* WindowTreeHostImpl::GetRootWindow() { 414 ServerWindow* WindowTreeHostImpl::GetRootWindow() {
395 return root_.get(); 415 return root_.get();
396 } 416 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 618 }
599 619
600 DispatchInputEventToWindowImpl(target, in_nonclient_area, event); 620 DispatchInputEventToWindowImpl(target, in_nonclient_area, event);
601 } 621 }
602 622
603 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { 623 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) {
604 windows_needing_frame_destruction_.erase(window); 624 windows_needing_frame_destruction_.erase(window);
605 window->RemoveObserver(this); 625 window->RemoveObserver(this);
606 } 626 }
607 627
628 void WindowTreeHostImpl::OnActiveUserIdChanged(UserId id) {
629 // TODO(sky): this likely needs to cancel any pending events and all that.
630 }
631
632 void WindowTreeHostImpl::OnUserIdAdded(UserId id) {}
633
634 void WindowTreeHostImpl::OnUserIdRemoved(UserId id) {
635 if (window_tree_host_connection_)
636 return;
637
638 WindowManagerState* state = GetWindowManagerStateForUser(id);
639 if (!state)
640 return;
641
642 // DestroyTree() calls back to OnWindowTreeConnectionError() and the
643 // WindowManagerState is destroyed (and removed).
644 connection_manager_->DestroyTree(state->tree());
645 DCHECK_EQ(0u, window_manager_state_map_.count(id));
646 }
647
648 void WindowTreeHostImpl::OnWindowManagerFactorySet(
649 WindowManagerFactoryService* service) {
650 CreateWindowManagerStateFromService(service);
651 }
652
608 } // namespace ws 653 } // namespace ws
609 } // namespace mus 654 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_tree_host_impl.h ('k') | components/mus/ws/window_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698