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 "components/mus/ws/display_manager.h" | 5 #include "components/mus/ws/display_manager.h" |
6 | 6 |
7 #include "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 228 } |
229 | 229 |
230 void DefaultDisplayManager::SetViewportSize(const gfx::Size& size) { | 230 void DefaultDisplayManager::SetViewportSize(const gfx::Size& size) { |
231 platform_window_->SetBounds(gfx::Rect(size)); | 231 platform_window_->SetBounds(gfx::Rect(size)); |
232 } | 232 } |
233 | 233 |
234 void DefaultDisplayManager::SetTitle(const base::string16& title) { | 234 void DefaultDisplayManager::SetTitle(const base::string16& title) { |
235 platform_window_->SetTitle(title); | 235 platform_window_->SetTitle(title); |
236 } | 236 } |
237 | 237 |
| 238 void DefaultDisplayManager::SetCapture() { |
| 239 platform_window_->SetCapture(); |
| 240 } |
| 241 |
| 242 void DefaultDisplayManager::ReleaseCapture() { |
| 243 platform_window_->ReleaseCapture(); |
| 244 } |
| 245 |
238 void DefaultDisplayManager::SetCursorById(int32_t cursor_id) { | 246 void DefaultDisplayManager::SetCursorById(int32_t cursor_id) { |
239 #if !defined(OS_ANDROID) | 247 #if !defined(OS_ANDROID) |
240 // TODO(erg): This still isn't sufficient, and will only use native cursors | 248 // TODO(erg): This still isn't sufficient, and will only use native cursors |
241 // that chrome would use, not custom image cursors. For that, we should | 249 // that chrome would use, not custom image cursors. For that, we should |
242 // delegate to the window manager to load images from resource packs. | 250 // delegate to the window manager to load images from resource packs. |
243 // | 251 // |
244 // We probably also need to deal with different DPIs. | 252 // We probably also need to deal with different DPIs. |
245 ui::Cursor cursor(cursor_id); | 253 ui::Cursor cursor(cursor_id); |
246 cursor_loader_->SetPlatformCursor(&cursor); | 254 cursor_loader_->SetPlatformCursor(&cursor); |
247 platform_window_->SetCursor(cursor.platform()); | 255 platform_window_->SetCursor(cursor.platform()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } | 354 } |
347 | 355 |
348 void DefaultDisplayManager::OnDamageRect(const gfx::Rect& damaged_region) { | 356 void DefaultDisplayManager::OnDamageRect(const gfx::Rect& damaged_region) { |
349 dirty_rect_.Union(damaged_region); | 357 dirty_rect_.Union(damaged_region); |
350 WantToDraw(); | 358 WantToDraw(); |
351 } | 359 } |
352 | 360 |
353 void DefaultDisplayManager::DispatchEvent(ui::Event* event) { | 361 void DefaultDisplayManager::DispatchEvent(ui::Event* event) { |
354 delegate_->OnEvent(*event); | 362 delegate_->OnEvent(*event); |
355 | 363 |
356 switch (event->type()) { | |
357 case ui::ET_MOUSE_PRESSED: | |
358 case ui::ET_TOUCH_PRESSED: | |
359 platform_window_->SetCapture(); | |
360 break; | |
361 case ui::ET_MOUSE_RELEASED: | |
362 case ui::ET_TOUCH_RELEASED: | |
363 platform_window_->ReleaseCapture(); | |
364 break; | |
365 default: | |
366 break; | |
367 } | |
368 | |
369 #if defined(USE_X11) | 364 #if defined(USE_X11) |
370 // We want to emulate the WM_CHAR generation behaviour of Windows. | 365 // We want to emulate the WM_CHAR generation behaviour of Windows. |
371 // | 366 // |
372 // On Linux, we've previously inserted characters by having | 367 // On Linux, we've previously inserted characters by having |
373 // InputMethodAuraLinux take all key down events and send a character event | 368 // InputMethodAuraLinux take all key down events and send a character event |
374 // to the TextInputClient. This causes a mismatch in code that has to be | 369 // to the TextInputClient. This causes a mismatch in code that has to be |
375 // shared between Windows and Linux, including blink code. Now that we're | 370 // shared between Windows and Linux, including blink code. Now that we're |
376 // trying to have one way of doing things, we need to standardize on and | 371 // trying to have one way of doing things, we need to standardize on and |
377 // emulate Windows character events. | 372 // emulate Windows character events. |
378 // | 373 // |
(...skipping 16 matching lines...) Expand all Loading... |
395 platform_window_->Close(); | 390 platform_window_->Close(); |
396 } | 391 } |
397 | 392 |
398 void DefaultDisplayManager::OnClosed() { | 393 void DefaultDisplayManager::OnClosed() { |
399 delegate_->OnDisplayClosed(); | 394 delegate_->OnDisplayClosed(); |
400 } | 395 } |
401 | 396 |
402 void DefaultDisplayManager::OnWindowStateChanged( | 397 void DefaultDisplayManager::OnWindowStateChanged( |
403 ui::PlatformWindowState new_state) {} | 398 ui::PlatformWindowState new_state) {} |
404 | 399 |
405 void DefaultDisplayManager::OnLostCapture() {} | 400 void DefaultDisplayManager::OnLostCapture() { |
| 401 delegate_->OnNativeCaptureLost(); |
| 402 } |
406 | 403 |
407 void DefaultDisplayManager::OnAcceleratedWidgetAvailable( | 404 void DefaultDisplayManager::OnAcceleratedWidgetAvailable( |
408 gfx::AcceleratedWidget widget, | 405 gfx::AcceleratedWidget widget, |
409 float device_pixel_ratio) { | 406 float device_pixel_ratio) { |
410 if (widget != gfx::kNullAcceleratedWidget) { | 407 if (widget != gfx::kNullAcceleratedWidget) { |
411 top_level_display_client_.reset( | 408 top_level_display_client_.reset( |
412 new TopLevelDisplayClient(widget, gpu_state_, surfaces_state_)); | 409 new TopLevelDisplayClient(widget, gpu_state_, surfaces_state_)); |
413 delegate_->OnTopLevelSurfaceChanged( | 410 delegate_->OnTopLevelSurfaceChanged( |
414 top_level_display_client_->surface_id()); | 411 top_level_display_client_->surface_id()); |
415 } | 412 } |
416 UpdateMetrics(metrics_.size_in_pixels.To<gfx::Size>(), device_pixel_ratio); | 413 UpdateMetrics(metrics_.size_in_pixels.To<gfx::Size>(), device_pixel_ratio); |
417 } | 414 } |
418 | 415 |
419 void DefaultDisplayManager::OnAcceleratedWidgetDestroyed() { | 416 void DefaultDisplayManager::OnAcceleratedWidgetDestroyed() { |
420 NOTREACHED(); | 417 NOTREACHED(); |
421 } | 418 } |
422 | 419 |
423 void DefaultDisplayManager::OnActivationChanged(bool active) {} | 420 void DefaultDisplayManager::OnActivationChanged(bool active) {} |
424 | 421 |
425 void DefaultDisplayManager::RequestCopyOfOutput( | 422 void DefaultDisplayManager::RequestCopyOfOutput( |
426 scoped_ptr<cc::CopyOutputRequest> output_request) { | 423 scoped_ptr<cc::CopyOutputRequest> output_request) { |
427 if (top_level_display_client_) | 424 if (top_level_display_client_) |
428 top_level_display_client_->RequestCopyOfOutput(std::move(output_request)); | 425 top_level_display_client_->RequestCopyOfOutput(std::move(output_request)); |
429 } | 426 } |
430 | 427 |
431 } // namespace ws | 428 } // namespace ws |
432 | 429 |
433 } // namespace mus | 430 } // namespace mus |
OLD | NEW |