| 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/drm/host/drm_window_host.h" | 5 #include "ui/ozone/platform/drm/host/drm_window_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/events/devices/device_data_manager.h" | 8 #include "ui/events/devices/device_data_manager.h" |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 10 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 void DrmWindowHost::Restore() { | 108 void DrmWindowHost::Restore() { |
| 109 } | 109 } |
| 110 | 110 |
| 111 void DrmWindowHost::SetCursor(PlatformCursor cursor) { | 111 void DrmWindowHost::SetCursor(PlatformCursor cursor) { |
| 112 cursor_->SetCursor(widget_, cursor); | 112 cursor_->SetCursor(widget_, cursor); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void DrmWindowHost::MoveCursorTo(const gfx::Point& location) { | 115 void DrmWindowHost::MoveCursorTo(const gfx::Point& location) { |
| 116 event_factory_->WarpCursorTo(widget_, location); | 116 event_factory_->WarpCursorTo(widget_, gfx::PointF(location)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void DrmWindowHost::ConfineCursorToBounds(const gfx::Rect& bounds) { | 119 void DrmWindowHost::ConfineCursorToBounds(const gfx::Rect& bounds) { |
| 120 if (cursor_confined_bounds_ == bounds) | 120 if (cursor_confined_bounds_ == bounds) |
| 121 return; | 121 return; |
| 122 | 122 |
| 123 cursor_confined_bounds_ = bounds; | 123 cursor_confined_bounds_ = bounds; |
| 124 cursor_->CommitBoundsChange(widget_, bounds_, bounds); | 124 cursor_->CommitBoundsChange(widget_, bounds_, bounds); |
| 125 } | 125 } |
| 126 | 126 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 155 | 155 |
| 156 DisplaySnapshot* snapshot = display->snapshot(); | 156 DisplaySnapshot* snapshot = display->snapshot(); |
| 157 if (!snapshot->current_mode()) | 157 if (!snapshot->current_mode()) |
| 158 return false; | 158 return false; |
| 159 | 159 |
| 160 gfx::Rect display_bounds(snapshot->origin(), | 160 gfx::Rect display_bounds(snapshot->origin(), |
| 161 snapshot->current_mode()->size()); | 161 snapshot->current_mode()->size()); |
| 162 return display_bounds == bounds_; | 162 return display_bounds == bounds_; |
| 163 } else if (event->IsLocatedEvent()) { | 163 } else if (event->IsLocatedEvent()) { |
| 164 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); | 164 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); |
| 165 return bounds_.Contains(gfx::ToFlooredPoint(located_event->location())); | 165 return bounds_.Contains(located_event->location()); |
| 166 } | 166 } |
| 167 | 167 |
| 168 // TODO(spang): For non-ash builds we would need smarter keyboard focus. | 168 // TODO(spang): For non-ash builds we would need smarter keyboard focus. |
| 169 return true; | 169 return true; |
| 170 } | 170 } |
| 171 | 171 |
| 172 uint32_t DrmWindowHost::DispatchEvent(const PlatformEvent& native_event) { | 172 uint32_t DrmWindowHost::DispatchEvent(const PlatformEvent& native_event) { |
| 173 DCHECK(native_event); | 173 DCHECK(native_event); |
| 174 | 174 |
| 175 Event* event = static_cast<Event*>(native_event); | 175 Event* event = static_cast<Event*>(native_event); |
| 176 if (event->IsLocatedEvent()) { | 176 if (event->IsLocatedEvent()) { |
| 177 // Make the event location relative to this window's origin. | 177 // Make the event location relative to this window's origin. |
| 178 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); | 178 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); |
| 179 gfx::PointF location = located_event->location(); | 179 gfx::PointF location = located_event->location_f(); |
| 180 location -= bounds_.OffsetFromOrigin(); | 180 location -= gfx::Vector2dF(bounds_.OffsetFromOrigin()); |
| 181 located_event->set_location(location); | 181 located_event->set_location_f(location); |
| 182 located_event->set_root_location(location); | 182 located_event->set_root_location_f(location); |
| 183 } | 183 } |
| 184 DispatchEventFromNativeUiEvent( | 184 DispatchEventFromNativeUiEvent( |
| 185 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, | 185 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, |
| 186 base::Unretained(delegate_))); | 186 base::Unretained(delegate_))); |
| 187 return POST_DISPATCH_STOP_PROPAGATION; | 187 return POST_DISPATCH_STOP_PROPAGATION; |
| 188 } | 188 } |
| 189 | 189 |
| 190 void DrmWindowHost::OnChannelEstablished() { | 190 void DrmWindowHost::OnChannelEstablished() { |
| 191 sender_->Send(new OzoneGpuMsg_CreateWindow(widget_)); | 191 sender_->Send(new OzoneGpuMsg_CreateWindow(widget_)); |
| 192 SendBoundsChange(); | 192 SendBoundsChange(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 203 // Update the cursor before the window so that the cursor stays within the | 203 // Update the cursor before the window so that the cursor stays within the |
| 204 // window bounds when the window size shrinks. | 204 // window bounds when the window size shrinks. |
| 205 cursor_->CommitBoundsChange(widget_, bounds_, GetCursorConfinedBounds()); | 205 cursor_->CommitBoundsChange(widget_, bounds_, GetCursorConfinedBounds()); |
| 206 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); | 206 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); |
| 207 | 207 |
| 208 if (overlay_candidates_host_) | 208 if (overlay_candidates_host_) |
| 209 overlay_candidates_host_->ResetCache(); | 209 overlay_candidates_host_->ResetCache(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 } // namespace ui | 212 } // namespace ui |
| OLD | NEW |