Chromium Code Reviews| Index: ui/ozone/platform/dri/dri_window.cc |
| diff --git a/ui/ozone/platform/dri/dri_window.cc b/ui/ozone/platform/dri/dri_window.cc |
| index 745a2d007a3a5c24c958ad2eff7db961e294ce03..573a2f806a2bd02856673782705c206bde238900 100644 |
| --- a/ui/ozone/platform/dri/dri_window.cc |
| +++ b/ui/ozone/platform/dri/dri_window.cc |
| @@ -74,9 +74,13 @@ gfx::Rect DriWindow::GetBounds() { |
| return bounds_; |
| } |
| -void DriWindow::SetCapture() {} |
| +void DriWindow::SetCapture() { |
| + window_manager_->GrabEvents(widget_); |
| +} |
| -void DriWindow::ReleaseCapture() {} |
| +void DriWindow::ReleaseCapture() { |
| + window_manager_->UngrabEvents(widget_); |
| +} |
| void DriWindow::ToggleFullscreen() {} |
| @@ -103,13 +107,33 @@ void DriWindow::MoveCursorTo(const gfx::Point& location) { |
| bool DriWindow::CanDispatchEvent(const PlatformEvent& ne) { |
| DCHECK(ne); |
| Event* event = static_cast<Event*>(ne); |
| - if (event->IsMouseEvent() || event->IsScrollEvent()) |
| + |
| + // Bail out if there is a grab on mouse events. |
| + gfx::AcceleratedWidget grabber = window_manager_->event_grabber(); |
| + if (grabber != gfx::kNullAcceleratedWidget) |
| + return grabber == widget_; |
|
spang
2014/11/11 19:00:24
Let's talk about this more.
Touch events should n
llandwerlin-old
2014/11/12 15:47:24
Acknowledged.
sadrul
2014/11/19 21:07:10
I think we do grab for touch-events. Can you verif
|
| + |
| + if (event->IsMouseEvent() || event->IsScrollEvent()) { |
| + // Otherwise, just consider the position of the cursor. |
| return window_manager_->cursor()->GetCursorWindow() == widget_; |
| + } |
| return true; |
| } |
| uint32_t DriWindow::DispatchEvent(const PlatformEvent& native_event) { |
| + // Implement implicit mouse grab on button press |
| + Event* event = static_cast<Event*>(native_event); |
| + if (event->IsLocatedEvent()) { |
|
spang
2014/11/11 19:00:24
As above, touch events must not be affected by the
llandwerlin-old
2014/11/12 15:47:24
They shouldn't be, because they will be delivered
spang
2014/11/19 18:32:30
That conditional is only for mouse events. Touch e
|
| + // We need to convert the cursor's position into coordinates |
| + // relative to the window in case of an implicit grab. |
| + if (window_manager_->cursor()->GetCursorWindow() != widget_) { |
|
spang
2014/11/19 18:32:30
I don't think you need this conditional as the cal
|
| + LocatedEvent* located_event = static_cast<LocatedEvent*>(event); |
| + gfx::PointF location = located_event->root_location(); |
| + location.Offset(-bounds_.origin().x(), -bounds_.origin().y()); |
| + located_event->set_location(location); |
| + } |
| + } |
| DispatchEventFromNativeUiEvent( |
| native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, |
| base::Unretained(delegate_))); |