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 "components/mus/ws/display.h" | 5 #include "components/mus/ws/display.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/connection_manager.h" | 10 #include "components/mus/ws/connection_manager.h" |
11 #include "components/mus/ws/connection_manager_delegate.h" | 11 #include "components/mus/ws/connection_manager_delegate.h" |
12 #include "components/mus/ws/display_binding.h" | 12 #include "components/mus/ws/display_binding.h" |
13 #include "components/mus/ws/focus_controller.h" | 13 #include "components/mus/ws/focus_controller.h" |
14 #include "components/mus/ws/platform_display.h" | 14 #include "components/mus/ws/platform_display.h" |
15 #include "components/mus/ws/window_manager_factory_service.h" | 15 #include "components/mus/ws/window_manager_factory_service.h" |
16 #include "components/mus/ws/window_manager_state.h" | 16 #include "components/mus/ws/window_manager_state.h" |
17 #include "components/mus/ws/window_tree.h" | 17 #include "components/mus/ws/window_tree.h" |
18 #include "components/mus/ws/window_tree_binding.h" | 18 #include "components/mus/ws/window_tree_binding.h" |
19 #include "mojo/common/common_type_converters.h" | 19 #include "mojo/common/common_type_converters.h" |
20 #include "mojo/converters/geometry/geometry_type_converters.h" | 20 #include "mojo/converters/geometry/geometry_type_converters.h" |
21 #include "mojo/converters/input_events/input_events_type_converters.h" | 21 #include "mojo/converters/input_events/input_events_type_converters.h" |
| 22 #include "mojo/shell/public/interfaces/connector.mojom.h" |
22 | 23 |
23 namespace mus { | 24 namespace mus { |
24 namespace ws { | 25 namespace ws { |
25 namespace { | 26 namespace { |
26 | 27 |
27 base::TimeDelta GetDefaultAckTimerDelay() { | 28 base::TimeDelta GetDefaultAckTimerDelay() { |
28 #if defined(NDEBUG) | 29 #if defined(NDEBUG) |
29 return base::TimeDelta::FromMilliseconds(100); | 30 return base::TimeDelta::FromMilliseconds(100); |
30 #else | 31 #else |
31 return base::TimeDelta::FromMilliseconds(1000); | 32 return base::TimeDelta::FromMilliseconds(1000); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 180 } |
180 return nullptr; | 181 return nullptr; |
181 } | 182 } |
182 | 183 |
183 WindowManagerState* Display::GetFirstWindowManagerState() { | 184 WindowManagerState* Display::GetFirstWindowManagerState() { |
184 return window_manager_state_map_.empty() | 185 return window_manager_state_map_.empty() |
185 ? nullptr | 186 ? nullptr |
186 : window_manager_state_map_.begin()->second.get(); | 187 : window_manager_state_map_.begin()->second.get(); |
187 } | 188 } |
188 | 189 |
189 WindowManagerState* Display::GetWindowManagerStateForUser(UserId user_id) { | 190 WindowManagerState* Display::GetWindowManagerStateForUser( |
| 191 const UserId& user_id) { |
190 auto iter = window_manager_state_map_.find(user_id); | 192 auto iter = window_manager_state_map_.find(user_id); |
191 return iter == window_manager_state_map_.end() ? nullptr : iter->second.get(); | 193 return iter == window_manager_state_map_.end() ? nullptr : iter->second.get(); |
192 } | 194 } |
193 | 195 |
194 void Display::SetCapture(ServerWindow* window, bool in_nonclient_area) { | 196 void Display::SetCapture(ServerWindow* window, bool in_nonclient_area) { |
195 ServerWindow* capture_window = event_dispatcher_.capture_window(); | 197 ServerWindow* capture_window = event_dispatcher_.capture_window(); |
196 if (capture_window == window) | 198 if (capture_window == window) |
197 return; | 199 return; |
198 event_dispatcher_.SetCaptureWindow(window, in_nonclient_area); | 200 event_dispatcher_.SetCaptureWindow(window, in_nonclient_area); |
199 } | 201 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 void Display::InitWindowManagersIfNecessary() { | 297 void Display::InitWindowManagersIfNecessary() { |
296 if (!init_called_ || !root_) | 298 if (!init_called_ || !root_) |
297 return; | 299 return; |
298 | 300 |
299 connection_manager_->OnDisplayAcceleratedWidgetAvailable(this); | 301 connection_manager_->OnDisplayAcceleratedWidgetAvailable(this); |
300 if (binding_) { | 302 if (binding_) { |
301 scoped_ptr<WindowManagerState> wms_ptr(new WindowManagerState(this)); | 303 scoped_ptr<WindowManagerState> wms_ptr(new WindowManagerState(this)); |
302 WindowManagerState* wms = wms_ptr.get(); | 304 WindowManagerState* wms = wms_ptr.get(); |
303 // For this case we never create additional WindowManagerStates, so any | 305 // For this case we never create additional WindowManagerStates, so any |
304 // id works. | 306 // id works. |
305 window_manager_state_map_[0u] = std::move(wms_ptr); | 307 window_manager_state_map_[mojo::shell::mojom::kRootUserID] = |
| 308 std::move(wms_ptr); |
306 wms->tree_ = binding_->CreateWindowTree(wms->root()); | 309 wms->tree_ = binding_->CreateWindowTree(wms->root()); |
307 } else { | 310 } else { |
308 CreateWindowManagerStatesFromRegistry(); | 311 CreateWindowManagerStatesFromRegistry(); |
309 } | 312 } |
310 } | 313 } |
311 | 314 |
312 void Display::OnEventAckTimeout() { | 315 void Display::OnEventAckTimeout() { |
313 // TODO(sad): Figure out what we should do. | 316 // TODO(sad): Figure out what we should do. |
314 NOTIMPLEMENTED() << "Event ACK timed out."; | 317 NOTIMPLEMENTED() << "Event ACK timed out."; |
315 OnEventAck(tree_awaiting_input_ack_); | 318 OnEventAck(tree_awaiting_input_ack_); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 } | 610 } |
608 | 611 |
609 DispatchInputEventToWindowImpl(target, in_nonclient_area, event); | 612 DispatchInputEventToWindowImpl(target, in_nonclient_area, event); |
610 } | 613 } |
611 | 614 |
612 void Display::OnWindowDestroyed(ServerWindow* window) { | 615 void Display::OnWindowDestroyed(ServerWindow* window) { |
613 windows_needing_frame_destruction_.erase(window); | 616 windows_needing_frame_destruction_.erase(window); |
614 window->RemoveObserver(this); | 617 window->RemoveObserver(this); |
615 } | 618 } |
616 | 619 |
617 void Display::OnActiveUserIdChanged(UserId id) { | 620 void Display::OnActiveUserIdChanged(const UserId& id) { |
618 // TODO(sky): this likely needs to cancel any pending events and all that. | 621 // TODO(sky): this likely needs to cancel any pending events and all that. |
619 } | 622 } |
620 | 623 |
621 void Display::OnUserIdAdded(UserId id) {} | 624 void Display::OnUserIdAdded(const UserId& id) {} |
622 | 625 |
623 void Display::OnUserIdRemoved(UserId id) { | 626 void Display::OnUserIdRemoved(const UserId& id) { |
624 if (binding_) | 627 if (binding_) |
625 return; | 628 return; |
626 | 629 |
627 WindowManagerState* state = GetWindowManagerStateForUser(id); | 630 WindowManagerState* state = GetWindowManagerStateForUser(id); |
628 if (!state) | 631 if (!state) |
629 return; | 632 return; |
630 | 633 |
631 // DestroyTree() calls back to OnWindowTreeConnectionError() and the | 634 // DestroyTree() calls back to OnWindowTreeConnectionError() and the |
632 // WindowManagerState is destroyed (and removed). | 635 // WindowManagerState is destroyed (and removed). |
633 connection_manager_->DestroyTree(state->tree()); | 636 connection_manager_->DestroyTree(state->tree()); |
634 DCHECK_EQ(0u, window_manager_state_map_.count(id)); | 637 DCHECK_EQ(0u, window_manager_state_map_.count(id)); |
635 } | 638 } |
636 | 639 |
637 void Display::OnWindowManagerFactorySet(WindowManagerFactoryService* service) { | 640 void Display::OnWindowManagerFactorySet(WindowManagerFactoryService* service) { |
638 CreateWindowManagerStateFromService(service); | 641 CreateWindowManagerStateFromService(service); |
639 } | 642 } |
640 | 643 |
641 } // namespace ws | 644 } // namespace ws |
642 } // namespace mus | 645 } // namespace mus |
OLD | NEW |