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/display/display.h" | 8 #include "ui/display/display.h" |
9 #include "ui/events/devices/device_data_manager.h" | 9 #include "ui/events/devices/device_data_manager.h" |
10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 return false; | 153 return false; |
154 | 154 |
155 DisplaySnapshot* snapshot = display->snapshot(); | 155 DisplaySnapshot* snapshot = display->snapshot(); |
156 if (!snapshot->current_mode()) | 156 if (!snapshot->current_mode()) |
157 return false; | 157 return false; |
158 | 158 |
159 gfx::Rect display_bounds(snapshot->origin(), | 159 gfx::Rect display_bounds(snapshot->origin(), |
160 snapshot->current_mode()->size()); | 160 snapshot->current_mode()->size()); |
161 return display_bounds == bounds_; | 161 return display_bounds == bounds_; |
162 } else if (event->IsLocatedEvent()) { | 162 } else if (event->IsLocatedEvent()) { |
163 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); | 163 LocatedEvent* located_event = event->AsLocatedEvent(); |
164 return bounds_.Contains(located_event->location()); | 164 return bounds_.Contains(located_event->location()); |
165 } | 165 } |
166 | 166 |
167 // TODO(spang): For non-ash builds we would need smarter keyboard focus. | 167 // TODO(spang): For non-ash builds we would need smarter keyboard focus. |
168 return true; | 168 return true; |
169 } | 169 } |
170 | 170 |
171 uint32_t DrmWindowHost::DispatchEvent(const PlatformEvent& native_event) { | 171 uint32_t DrmWindowHost::DispatchEvent(const PlatformEvent& native_event) { |
172 DCHECK(native_event); | 172 DCHECK(native_event); |
173 | 173 |
174 Event* event = static_cast<Event*>(native_event); | 174 Event* event = static_cast<Event*>(native_event); |
175 if (event->IsLocatedEvent()) { | 175 if (event->IsLocatedEvent()) { |
176 // Make the event location relative to this window's origin. | 176 // Make the event location relative to this window's origin. |
177 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); | 177 LocatedEvent* located_event = event->AsLocatedEvent(); |
178 gfx::PointF location = located_event->location_f(); | 178 gfx::PointF location = located_event->location_f(); |
179 location -= gfx::Vector2dF(bounds_.OffsetFromOrigin()); | 179 location -= gfx::Vector2dF(bounds_.OffsetFromOrigin()); |
180 located_event->set_location_f(location); | 180 located_event->set_location_f(location); |
181 located_event->set_root_location_f(location); | 181 located_event->set_root_location_f(location); |
182 } | 182 } |
183 DispatchEventFromNativeUiEvent( | 183 DispatchEventFromNativeUiEvent( |
184 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, | 184 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, |
185 base::Unretained(delegate_))); | 185 base::Unretained(delegate_))); |
186 return POST_DISPATCH_STOP_PROPAGATION; | 186 return POST_DISPATCH_STOP_PROPAGATION; |
187 } | 187 } |
188 | 188 |
189 void DrmWindowHost::OnGpuThreadReady() { | 189 void DrmWindowHost::OnGpuThreadReady() { |
190 sender_->GpuCreateWindow(widget_); | 190 sender_->GpuCreateWindow(widget_); |
191 SendBoundsChange(); | 191 SendBoundsChange(); |
192 } | 192 } |
193 | 193 |
194 void DrmWindowHost::OnGpuThreadRetired() {} | 194 void DrmWindowHost::OnGpuThreadRetired() {} |
195 | 195 |
196 void DrmWindowHost::SendBoundsChange() { | 196 void DrmWindowHost::SendBoundsChange() { |
197 // Update the cursor before the window so that the cursor stays within the | 197 // Update the cursor before the window so that the cursor stays within the |
198 // window bounds when the window size shrinks. | 198 // window bounds when the window size shrinks. |
199 cursor_->CommitBoundsChange(widget_, bounds_, GetCursorConfinedBounds()); | 199 cursor_->CommitBoundsChange(widget_, bounds_, GetCursorConfinedBounds()); |
200 sender_->GpuWindowBoundsChanged(widget_, bounds_); | 200 sender_->GpuWindowBoundsChanged(widget_, bounds_); |
201 | 201 |
202 overlay_manager_->ResetCache(); | 202 overlay_manager_->ResetCache(); |
203 } | 203 } |
204 | 204 |
205 } // namespace ui | 205 } // namespace ui |
OLD | NEW |