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/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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 DCHECK(ne); | 115 DCHECK(ne); |
116 Event* event = static_cast<Event*>(ne); | 116 Event* event = static_cast<Event*>(ne); |
117 | 117 |
118 // If there is a grab, capture events here. | 118 // If there is a grab, capture events here. |
119 gfx::AcceleratedWidget grabber = window_manager_->event_grabber(); | 119 gfx::AcceleratedWidget grabber = window_manager_->event_grabber(); |
120 if (grabber != gfx::kNullAcceleratedWidget) | 120 if (grabber != gfx::kNullAcceleratedWidget) |
121 return grabber == widget_; | 121 return grabber == widget_; |
122 | 122 |
123 if (event->IsLocatedEvent()) { | 123 if (event->IsLocatedEvent()) { |
124 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); | 124 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); |
125 return bounds_.Contains( | 125 return bounds_.Contains(gfx::ToFlooredPoint(located_event->location())); |
126 gfx::ToFlooredPoint(located_event->root_location())); | |
127 } | 126 } |
128 | 127 |
129 // TODO(spang): For non-ash builds we would need smarter keyboard focus. | 128 // TODO(spang): For non-ash builds we would need smarter keyboard focus. |
130 return true; | 129 return true; |
131 } | 130 } |
132 | 131 |
133 uint32_t DriWindow::DispatchEvent(const PlatformEvent& native_event) { | 132 uint32_t DriWindow::DispatchEvent(const PlatformEvent& native_event) { |
134 DCHECK(native_event); | 133 DCHECK(native_event); |
135 | 134 |
136 Event* event = static_cast<Event*>(native_event); | 135 Event* event = static_cast<Event*>(native_event); |
137 if (event->IsLocatedEvent()) { | 136 if (event->IsLocatedEvent()) { |
138 // Make the event location relative to this window's origin. | 137 // Make the event location relative to this window's origin. |
139 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); | 138 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); |
140 gfx::PointF location = located_event->root_location(); | 139 gfx::PointF location = located_event->location(); |
141 location -= bounds_.OffsetFromOrigin(); | 140 location -= bounds_.OffsetFromOrigin(); |
142 located_event->set_location(location); | 141 located_event->set_location(location); |
| 142 located_event->set_root_location(location); |
143 } | 143 } |
144 DispatchEventFromNativeUiEvent( | 144 DispatchEventFromNativeUiEvent( |
145 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, | 145 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, |
146 base::Unretained(delegate_))); | 146 base::Unretained(delegate_))); |
147 return POST_DISPATCH_STOP_PROPAGATION; | 147 return POST_DISPATCH_STOP_PROPAGATION; |
148 } | 148 } |
149 | 149 |
150 void DriWindow::OnChannelEstablished() { | 150 void DriWindow::OnChannelEstablished() { |
151 sender_->Send(new OzoneGpuMsg_CreateWindowDelegate(widget_)); | 151 sender_->Send(new OzoneGpuMsg_CreateWindowDelegate(widget_)); |
152 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); | 152 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); |
153 | 153 |
154 DriCursor* dri_cursor = window_manager_->cursor(); | 154 DriCursor* dri_cursor = window_manager_->cursor(); |
155 if (dri_cursor->GetCursorWindow() == widget_) | 155 if (dri_cursor->GetCursorWindow() == widget_) |
156 dri_cursor->ShowCursor(); | 156 dri_cursor->ShowCursor(); |
157 } | 157 } |
158 | 158 |
159 void DriWindow::OnChannelDestroyed() { | 159 void DriWindow::OnChannelDestroyed() { |
160 } | 160 } |
161 | 161 |
162 } // namespace ui | 162 } // namespace ui |
OLD | NEW |