| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/ws/display_manager.h" | 5 #include "services/ui/ws/display_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "services/ui/display/viewport_metrics.h" | 11 #include "services/ui/display/viewport_metrics.h" |
| 12 #include "services/ui/ws/cursor_location_manager.h" | 12 #include "services/ui/ws/cursor_location_manager.h" |
| 13 #include "services/ui/ws/display.h" | 13 #include "services/ui/ws/display.h" |
| 14 #include "services/ui/ws/display_binding.h" | 14 #include "services/ui/ws/display_binding.h" |
| 15 #include "services/ui/ws/event_dispatcher.h" | 15 #include "services/ui/ws/event_dispatcher.h" |
| 16 #include "services/ui/ws/server_window.h" | 16 #include "services/ui/ws/server_window.h" |
| 17 #include "services/ui/ws/user_display_manager.h" | 17 #include "services/ui/ws/user_display_manager.h" |
| 18 #include "services/ui/ws/user_display_manager_delegate.h" | 18 #include "services/ui/ws/user_display_manager_delegate.h" |
| 19 #include "services/ui/ws/user_id_tracker.h" | 19 #include "services/ui/ws/user_id_tracker.h" |
| 20 #include "services/ui/ws/window_manager_state.h" | 20 #include "services/ui/ws/window_manager_state.h" |
| 21 #include "services/ui/ws/window_manager_window_tree_factory.h" | 21 #include "services/ui/ws/window_manager_window_tree_factory.h" |
| 22 #include "services/ui/ws/window_server_delegate.h" | 22 #include "services/ui/ws/window_server_delegate.h" |
| 23 #include "services/ui/ws/window_tree.h" | 23 #include "services/ui/ws/window_tree.h" |
| 24 | 24 |
| 25 #if defined(OS_CHROMEOS) |
| 26 #include "ui/chromeos/events/event_rewriter_chromeos.h" |
| 27 #endif |
| 28 |
| 25 namespace ui { | 29 namespace ui { |
| 26 namespace ws { | 30 namespace ws { |
| 27 | 31 |
| 28 DisplayManager::DisplayManager(WindowServer* window_server, | 32 DisplayManager::DisplayManager(WindowServer* window_server, |
| 29 UserIdTracker* user_id_tracker) | 33 UserIdTracker* user_id_tracker) |
| 30 // |next_root_id_| is used as the lower bits, so that starting at 0 is | 34 // |next_root_id_| is used as the lower bits, so that starting at 0 is |
| 31 // fine. |next_display_id_| is used by itself, so we start at 1 to reserve | 35 // fine. |next_display_id_| is used by itself, so we start at 1 to reserve |
| 32 // 0 as invalid. | 36 // 0 as invalid. |
| 33 : window_server_(window_server), | 37 : window_server_(window_server), |
| 34 user_id_tracker_(user_id_tracker), | 38 user_id_tracker_(user_id_tracker), |
| 35 next_root_id_(0) { | 39 next_root_id_(0) { |
| 40 #if defined(OS_CHROMEOS) |
| 41 // TODO: http://crbug.com/701468 fix function key preferences and sticky keys. |
| 42 ui::EventRewriterChromeOS::Delegate* delegate = nullptr; |
| 43 ui::EventRewriter* sticky_keys_controller = nullptr; |
| 44 event_rewriter_ = base::MakeUnique<ui::EventRewriterChromeOS>( |
| 45 delegate, sticky_keys_controller); |
| 46 #endif |
| 36 user_id_tracker_->AddObserver(this); | 47 user_id_tracker_->AddObserver(this); |
| 37 } | 48 } |
| 38 | 49 |
| 39 DisplayManager::~DisplayManager() { | 50 DisplayManager::~DisplayManager() { |
| 40 user_id_tracker_->RemoveObserver(this); | 51 user_id_tracker_->RemoveObserver(this); |
| 41 DestroyAllDisplays(); | 52 DestroyAllDisplays(); |
| 42 } | 53 } |
| 43 | 54 |
| 44 UserDisplayManager* DisplayManager::GetUserDisplayManager( | 55 UserDisplayManager* DisplayManager::GetUserDisplayManager( |
| 45 const UserId& user_id) { | 56 const UserId& user_id) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 DCHECK_LT(id, next_root_id_); | 165 DCHECK_LT(id, next_root_id_); |
| 155 return RootWindowId(id); | 166 return RootWindowId(id); |
| 156 } | 167 } |
| 157 | 168 |
| 158 void DisplayManager::OnDisplayAcceleratedWidgetAvailable(Display* display) { | 169 void DisplayManager::OnDisplayAcceleratedWidgetAvailable(Display* display) { |
| 159 DCHECK_NE(0u, pending_displays_.count(display)); | 170 DCHECK_NE(0u, pending_displays_.count(display)); |
| 160 DCHECK_EQ(0u, displays_.count(display)); | 171 DCHECK_EQ(0u, displays_.count(display)); |
| 161 const bool is_first_display = displays_.empty(); | 172 const bool is_first_display = displays_.empty(); |
| 162 displays_.insert(display); | 173 displays_.insert(display); |
| 163 pending_displays_.erase(display); | 174 pending_displays_.erase(display); |
| 175 if (event_rewriter_) |
| 176 display->platform_display()->AddEventRewriter(event_rewriter_.get()); |
| 164 window_server_->OnDisplayReady(display, is_first_display); | 177 window_server_->OnDisplayReady(display, is_first_display); |
| 165 } | 178 } |
| 166 | 179 |
| 167 void DisplayManager::OnActiveUserIdChanged(const UserId& previously_active_id, | 180 void DisplayManager::OnActiveUserIdChanged(const UserId& previously_active_id, |
| 168 const UserId& active_id) { | 181 const UserId& active_id) { |
| 169 WindowManagerState* previous_window_manager_state = | 182 WindowManagerState* previous_window_manager_state = |
| 170 window_server_->GetWindowManagerStateForUser(previously_active_id); | 183 window_server_->GetWindowManagerStateForUser(previously_active_id); |
| 171 gfx::Point mouse_location_on_screen; | 184 gfx::Point mouse_location_on_screen; |
| 172 if (previous_window_manager_state) { | 185 if (previous_window_manager_state) { |
| 173 mouse_location_on_screen = previous_window_manager_state->event_dispatcher() | 186 mouse_location_on_screen = previous_window_manager_state->event_dispatcher() |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 DVLOG(3) << "OnPrimaryDisplayChanged: " << primary_display_id; | 240 DVLOG(3) << "OnPrimaryDisplayChanged: " << primary_display_id; |
| 228 // TODO(kylechar): Send IPCs to WM clients first. | 241 // TODO(kylechar): Send IPCs to WM clients first. |
| 229 | 242 |
| 230 // Send IPCs to any DisplayManagerObservers. | 243 // Send IPCs to any DisplayManagerObservers. |
| 231 for (const auto& pair : user_display_managers_) | 244 for (const auto& pair : user_display_managers_) |
| 232 pair.second->OnPrimaryDisplayChanged(primary_display_id); | 245 pair.second->OnPrimaryDisplayChanged(primary_display_id); |
| 233 } | 246 } |
| 234 | 247 |
| 235 } // namespace ws | 248 } // namespace ws |
| 236 } // namespace ui | 249 } // namespace ui |
| OLD | NEW |