OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/service.h" | 5 #include "services/ui/service.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "ui/events/event_switches.h" | 45 #include "ui/events/event_switches.h" |
46 #include "ui/events/platform/platform_event_source.h" | 46 #include "ui/events/platform/platform_event_source.h" |
47 #include "ui/gfx/geometry/rect.h" | 47 #include "ui/gfx/geometry/rect.h" |
48 #include "ui/gl/gl_surface.h" | 48 #include "ui/gl/gl_surface.h" |
49 | 49 |
50 #if defined(USE_X11) | 50 #if defined(USE_X11) |
51 #include <X11/Xlib.h> | 51 #include <X11/Xlib.h> |
52 #include "ui/base/x/x11_util.h" // nogncheck | 52 #include "ui/base/x/x11_util.h" // nogncheck |
53 #include "ui/platform_window/x11/x11_window.h" | 53 #include "ui/platform_window/x11/x11_window.h" |
54 #elif defined(USE_OZONE) | 54 #elif defined(USE_OZONE) |
| 55 #include "services/ui/display/screen_manager_forwarding.h" |
55 #include "ui/events/ozone/layout/keyboard_layout_engine.h" | 56 #include "ui/events/ozone/layout/keyboard_layout_engine.h" |
56 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 57 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
57 #include "ui/ozone/public/ozone_platform.h" | 58 #include "ui/ozone/public/ozone_platform.h" |
58 #endif | 59 #endif |
59 | 60 |
60 using mojo::InterfaceRequest; | 61 using mojo::InterfaceRequest; |
61 using ui::mojom::WindowServerTest; | 62 using ui::mojom::WindowServerTest; |
62 using ui::mojom::WindowTreeHostFactory; | 63 using ui::mojom::WindowTreeHostFactory; |
63 | 64 |
64 namespace ui { | 65 namespace ui { |
(...skipping 14 matching lines...) Expand all Loading... |
79 }; | 80 }; |
80 | 81 |
81 struct Service::UserState { | 82 struct Service::UserState { |
82 std::unique_ptr<clipboard::ClipboardImpl> clipboard; | 83 std::unique_ptr<clipboard::ClipboardImpl> clipboard; |
83 std::unique_ptr<ws::AccessibilityManager> accessibility; | 84 std::unique_ptr<ws::AccessibilityManager> accessibility; |
84 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; | 85 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; |
85 }; | 86 }; |
86 | 87 |
87 Service::Service() | 88 Service::Service() |
88 : test_config_(false), | 89 : test_config_(false), |
89 screen_manager_(display::ScreenManager::Create()), | |
90 ime_registrar_(&ime_server_) {} | 90 ime_registrar_(&ime_server_) {} |
91 | 91 |
92 Service::~Service() { | 92 Service::~Service() { |
93 // Destroy |window_server_| first, since it depends on |event_source_|. | 93 // Destroy |window_server_| first, since it depends on |event_source_|. |
94 // WindowServer (or more correctly its Displays) may have state that needs to | 94 // WindowServer (or more correctly its Displays) may have state that needs to |
95 // be destroyed before GpuState as well. | 95 // be destroyed before GpuState as well. |
96 window_server_.reset(); | 96 window_server_.reset(); |
97 | 97 |
98 #if defined(USE_OZONE) | 98 #if defined(USE_OZONE) |
99 OzonePlatform::Shutdown(); | 99 OzonePlatform::Shutdown(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 .AddInterface<discardable_memory::mojom::DiscardableSharedMemoryManager>( | 213 .AddInterface<discardable_memory::mojom::DiscardableSharedMemoryManager>( |
214 this); | 214 this); |
215 if (test_config_) | 215 if (test_config_) |
216 registry_.AddInterface<WindowServerTest>(this); | 216 registry_.AddInterface<WindowServerTest>(this); |
217 | 217 |
218 // On non-Linux platforms there will be no DeviceDataManager instance and no | 218 // On non-Linux platforms there will be no DeviceDataManager instance and no |
219 // purpose in adding the Mojo interface to connect to. | 219 // purpose in adding the Mojo interface to connect to. |
220 if (input_device_server_.IsRegisteredAsObserver()) | 220 if (input_device_server_.IsRegisteredAsObserver()) |
221 input_device_server_.AddInterface(®istry_); | 221 input_device_server_.AddInterface(®istry_); |
222 | 222 |
223 screen_manager_->AddInterfaces(®istry_); | |
224 | |
225 #if defined(USE_OZONE) | 223 #if defined(USE_OZONE) |
226 ui::OzonePlatform::GetInstance()->AddInterfaces(®istry_); | 224 ui::OzonePlatform::GetInstance()->AddInterfaces(®istry_); |
227 #endif | 225 #endif |
228 } | 226 } |
229 | 227 |
230 void Service::OnBindInterface(const service_manager::ServiceInfo& source_info, | 228 void Service::OnBindInterface(const service_manager::ServiceInfo& source_info, |
231 const std::string& interface_name, | 229 const std::string& interface_name, |
232 mojo::ScopedMessagePipeHandle interface_pipe) { | 230 mojo::ScopedMessagePipeHandle interface_pipe) { |
233 registry_.BindInterface(source_info.identity, interface_name, | 231 registry_.BindInterface(source_info.identity, interface_name, |
234 std::move(interface_pipe)); | 232 std::move(interface_pipe)); |
235 } | 233 } |
236 | 234 |
237 void Service::StartDisplayInit() { | 235 void Service::StartDisplayInit() { |
238 screen_manager_->Init(window_server_->display_manager()); | 236 DCHECK(!is_gpu_ready_); // This should only be called once. |
| 237 is_gpu_ready_ = true; |
| 238 if (screen_manager_) |
| 239 screen_manager_->Init(window_server_->display_manager()); |
239 } | 240 } |
240 | 241 |
241 void Service::OnFirstDisplayReady() { | 242 void Service::OnFirstDisplayReady() { |
242 PendingRequests requests; | 243 PendingRequests requests; |
243 requests.swap(pending_requests_); | 244 requests.swap(pending_requests_); |
244 for (auto& request : requests) { | 245 for (auto& request : requests) { |
245 if (request->wtf_request) | 246 if (request->wtf_request) |
246 Create(request->remote_identity, std::move(*request->wtf_request)); | 247 Create(request->remote_identity, std::move(*request->wtf_request)); |
247 else | 248 else |
248 Create(request->remote_identity, std::move(*request->dm_request)); | 249 Create(request->remote_identity, std::move(*request->dm_request)); |
249 } | 250 } |
250 } | 251 } |
251 | 252 |
252 void Service::OnNoMoreDisplays() { | 253 void Service::OnNoMoreDisplays() { |
253 // We may get here from the destructor, in which case there is no messageloop. | 254 // We may get here from the destructor, in which case there is no messageloop. |
254 if (base::MessageLoop::current() && | 255 if (base::MessageLoop::current() && |
255 base::MessageLoop::current()->is_running()) { | 256 base::MessageLoop::current()->is_running()) { |
256 base::MessageLoop::current()->QuitWhenIdle(); | 257 base::MessageLoop::current()->QuitWhenIdle(); |
257 } | 258 } |
258 } | 259 } |
259 | 260 |
260 bool Service::IsTestConfig() const { | 261 bool Service::IsTestConfig() const { |
261 return test_config_; | 262 return test_config_; |
262 } | 263 } |
263 | 264 |
| 265 void Service::OnWillCreateTreeForWindowManager( |
| 266 bool automatically_create_display_roots) { |
| 267 if (screen_manager_config_ != ScreenManagerConfig::UNKNOWN) |
| 268 return; |
| 269 |
| 270 DVLOG(3) << "OnWillCreateTreeForWindowManager " |
| 271 << automatically_create_display_roots; |
| 272 screen_manager_config_ = automatically_create_display_roots |
| 273 ? ScreenManagerConfig::INTERNAL |
| 274 : ScreenManagerConfig::FORWARDING; |
| 275 if (screen_manager_config_ == ScreenManagerConfig::FORWARDING) { |
| 276 #if defined(USE_OZONE) && defined(OS_CHROMEOS) |
| 277 screen_manager_ = base::MakeUnique<display::ScreenManagerForwarding>(); |
| 278 #else |
| 279 CHECK(false); |
| 280 #endif |
| 281 } else { |
| 282 screen_manager_ = display::ScreenManager::Create(); |
| 283 } |
| 284 screen_manager_->AddInterfaces(®istry_); |
| 285 if (is_gpu_ready_) |
| 286 screen_manager_->Init(window_server_->display_manager()); |
| 287 } |
| 288 |
264 void Service::Create(const service_manager::Identity& remote_identity, | 289 void Service::Create(const service_manager::Identity& remote_identity, |
265 mojom::AccessibilityManagerRequest request) { | 290 mojom::AccessibilityManagerRequest request) { |
266 UserState* user_state = GetUserState(remote_identity); | 291 UserState* user_state = GetUserState(remote_identity); |
267 if (!user_state->accessibility) { | 292 if (!user_state->accessibility) { |
268 const ws::UserId& user_id = remote_identity.user_id(); | 293 const ws::UserId& user_id = remote_identity.user_id(); |
269 user_state->accessibility.reset( | 294 user_state->accessibility.reset( |
270 new ws::AccessibilityManager(window_server_.get(), user_id)); | 295 new ws::AccessibilityManager(window_server_.get(), user_id)); |
271 } | 296 } |
272 user_state->accessibility->Bind(std::move(request)); | 297 user_state->accessibility->Bind(std::move(request)); |
273 } | 298 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 mojom::WindowServerTestRequest request) { | 394 mojom::WindowServerTestRequest request) { |
370 if (!test_config_) | 395 if (!test_config_) |
371 return; | 396 return; |
372 mojo::MakeStrongBinding( | 397 mojo::MakeStrongBinding( |
373 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()), | 398 base::MakeUnique<ws::WindowServerTestImpl>(window_server_.get()), |
374 std::move(request)); | 399 std::move(request)); |
375 } | 400 } |
376 | 401 |
377 | 402 |
378 } // namespace ui | 403 } // namespace ui |
OLD | NEW |