| 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 "ui/ozone/platform/dri/dri_window.h" | 5 #include "ui/ozone/platform/dri/dri_window.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 9 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 10 #include "ui/events/ozone/events_ozone.h" | 10 #include "ui/events/ozone/events_ozone.h" |
| 11 #include "ui/events/platform/platform_event_source.h" | 11 #include "ui/events/platform/platform_event_source.h" |
| 12 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" | 12 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" |
| 13 #include "ui/ozone/platform/dri/dri_cursor.h" | 13 #include "ui/ozone/platform/dri/dri_cursor.h" |
| 14 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" | 14 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" |
| 15 #include "ui/ozone/platform/dri/dri_window_manager.h" | 15 #include "ui/ozone/platform/dri/dri_window_manager.h" |
| 16 #include "ui/platform_window/platform_window_delegate.h" | 16 #include "ui/platform_window/platform_window_delegate.h" |
| 17 | 17 |
| 18 namespace ui { | 18 namespace ui { |
| 19 | 19 |
| 20 DriWindow::DriWindow(PlatformWindowDelegate* delegate, | 20 DriWindow::DriWindow(PlatformWindowDelegate* delegate, |
| 21 const gfx::Rect& bounds, | 21 const gfx::Rect& bounds, |
| 22 DriGpuPlatformSupportHost* sender, | 22 DriGpuPlatformSupportHost* sender, |
| 23 EventFactoryEvdev* event_factory, | 23 EventFactoryEvdev* event_factory, |
| 24 DriWindowManager* window_manager) | 24 DriWindowManager* window_manager, |
| 25 DisplayManager* display_manager) |
| 25 : delegate_(delegate), | 26 : delegate_(delegate), |
| 26 sender_(sender), | 27 sender_(sender), |
| 27 event_factory_(event_factory), | 28 event_factory_(event_factory), |
| 28 window_manager_(window_manager), | 29 window_manager_(window_manager), |
| 29 bounds_(bounds), | 30 bounds_(bounds), |
| 30 widget_(window_manager->NextAcceleratedWidget()) { | 31 widget_(window_manager->NextAcceleratedWidget()), |
| 32 touch_converter_(this, display_manager) { |
| 31 window_manager_->AddWindow(widget_, this); | 33 window_manager_->AddWindow(widget_, this); |
| 32 } | 34 } |
| 33 | 35 |
| 34 DriWindow::~DriWindow() { | 36 DriWindow::~DriWindow() { |
| 35 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | 37 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); |
| 36 window_manager_->RemoveWindow(widget_); | 38 window_manager_->RemoveWindow(widget_); |
| 37 | 39 |
| 38 sender_->RemoveChannelObserver(this); | 40 sender_->RemoveChannelObserver(this); |
| 39 if (!sender_->IsConnected()) | 41 if (!sender_->IsConnected()) |
| 40 return; | 42 return; |
| 41 | 43 |
| 42 sender_->Send(new OzoneGpuMsg_DestroyWindowDelegate(widget_)); | 44 sender_->Send(new OzoneGpuMsg_DestroyWindowDelegate(widget_)); |
| 43 } | 45 } |
| 44 | 46 |
| 45 void DriWindow::Initialize() { | 47 void DriWindow::Initialize() { |
| 46 sender_->AddChannelObserver(this); | 48 sender_->AddChannelObserver(this); |
| 47 delegate_->OnAcceleratedWidgetAvailable(widget_); | 49 delegate_->OnAcceleratedWidgetAvailable(widget_); |
| 48 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | 50 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
| 49 } | 51 } |
| 50 | 52 |
| 51 void DriWindow::Show() {} | 53 void DriWindow::Show() {} |
| 52 | 54 |
| 53 void DriWindow::Hide() {} | 55 void DriWindow::Hide() {} |
| 54 | 56 |
| 55 void DriWindow::Close() {} | 57 void DriWindow::Close() {} |
| 56 | 58 |
| 57 void DriWindow::SetBounds(const gfx::Rect& bounds) { | 59 void DriWindow::SetBounds(const gfx::Rect& bounds) { |
| 58 bounds_ = bounds; | 60 bounds_ = bounds; |
| 59 delegate_->OnBoundsChanged(bounds); | 61 delegate_->OnBoundsChanged(bounds); |
| 62 touch_converter_.UpdateTransform(); |
| 60 | 63 |
| 61 if (!sender_->IsConnected()) | 64 if (!sender_->IsConnected()) |
| 62 return; | 65 return; |
| 63 | 66 |
| 64 if (window_manager_->cursor()->GetCursorWindow() == widget_) | 67 if (window_manager_->cursor()->GetCursorWindow() == widget_) |
| 65 window_manager_->cursor()->HideCursor(); | 68 window_manager_->cursor()->HideCursor(); |
| 66 | 69 |
| 67 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds)); | 70 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds)); |
| 68 | 71 |
| 69 if (window_manager_->cursor()->GetCursorWindow() == widget_) | 72 if (window_manager_->cursor()->GetCursorWindow() == widget_) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 93 void DriWindow::MoveCursorTo(const gfx::Point& location) { | 96 void DriWindow::MoveCursorTo(const gfx::Point& location) { |
| 94 event_factory_->WarpCursorTo(widget_, location); | 97 event_factory_->WarpCursorTo(widget_, location); |
| 95 } | 98 } |
| 96 | 99 |
| 97 bool DriWindow::CanDispatchEvent(const PlatformEvent& ne) { | 100 bool DriWindow::CanDispatchEvent(const PlatformEvent& ne) { |
| 98 DCHECK(ne); | 101 DCHECK(ne); |
| 99 Event* event = static_cast<Event*>(ne); | 102 Event* event = static_cast<Event*>(ne); |
| 100 if (event->IsMouseEvent() || event->IsScrollEvent()) | 103 if (event->IsMouseEvent() || event->IsScrollEvent()) |
| 101 return window_manager_->cursor()->GetCursorWindow() == widget_; | 104 return window_manager_->cursor()->GetCursorWindow() == widget_; |
| 102 | 105 |
| 106 if (event->IsTouchEvent()) |
| 107 return touch_converter_.CanHandleEvent(*static_cast<TouchEvent*>(event)); |
| 108 |
| 103 return true; | 109 return true; |
| 104 } | 110 } |
| 105 | 111 |
| 106 uint32_t DriWindow::DispatchEvent(const PlatformEvent& native_event) { | 112 uint32_t DriWindow::DispatchEvent(const PlatformEvent& native_event) { |
| 113 DCHECK(native_event); |
| 114 Event* event = static_cast<Event*>(native_event); |
| 115 if (event->IsTouchEvent()) |
| 116 touch_converter_.RewriteTouchEvent(static_cast<TouchEvent*>(event)); |
| 117 |
| 107 DispatchEventFromNativeUiEvent( | 118 DispatchEventFromNativeUiEvent( |
| 108 native_event, | 119 native_event, |
| 109 base::Bind(&PlatformWindowDelegate::DispatchEvent, | 120 base::Bind(&PlatformWindowDelegate::DispatchEvent, |
| 110 base::Unretained(delegate_))); | 121 base::Unretained(delegate_))); |
| 111 return POST_DISPATCH_STOP_PROPAGATION; | 122 return POST_DISPATCH_STOP_PROPAGATION; |
| 112 } | 123 } |
| 113 | 124 |
| 114 void DriWindow::OnChannelEstablished() { | 125 void DriWindow::OnChannelEstablished() { |
| 115 sender_->Send(new OzoneGpuMsg_CreateWindowDelegate(widget_)); | 126 sender_->Send(new OzoneGpuMsg_CreateWindowDelegate(widget_)); |
| 116 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); | 127 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); |
| 117 } | 128 } |
| 118 | 129 |
| 119 void DriWindow::OnChannelDestroyed() { | 130 void DriWindow::OnChannelDestroyed() { |
| 120 } | 131 } |
| 121 | 132 |
| 122 } // namespace ui | 133 } // namespace ui |
| OLD | NEW |