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 7e60bd7d8943232098f09f1afb9a07e1798f6d36..3b50f72aaea0c40eeef8e29c853eb381ff6a5709 100644 |
| --- a/ui/ozone/platform/dri/dri_window.cc |
| +++ b/ui/ozone/platform/dri/dri_window.cc |
| @@ -71,9 +71,13 @@ gfx::Rect DriWindow::GetBounds() { |
| return bounds_; |
| } |
| -void DriWindow::SetCapture() {} |
| +void DriWindow::SetCapture() { |
| + window_manager_->GrabMouseEvents(widget_); |
| +} |
| -void DriWindow::ReleaseCapture() {} |
| +void DriWindow::ReleaseCapture() { |
| + window_manager_->UngrabMouseEvents(widget_); |
| +} |
| void DriWindow::ToggleFullscreen() {} |
| @@ -94,13 +98,39 @@ 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()) |
| + if (event->IsMouseEvent() || event->IsScrollEvent()) { |
| + // Bail out if there is a grab on mouse events. |
| + gfx::AcceleratedWidget grabber = window_manager_->mouse_events_grabber(); |
| + if (grabber != gfx::kNullAcceleratedWidget) |
| + return grabber == widget_; |
| + |
| + // 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->IsMouseEvent()) { |
| + // We need to convert the cursor's position into coordinates |
|
spang
2014/11/04 23:27:23
Can you change DriCursor to generate the event coo
|
| + // relative to the window in case of an implicit grab. |
| + if (window_manager_->cursor()->GetCursorWindow() != widget_) { |
| + DriWindow* window = window_manager_->GetWindow( |
| + window_manager_->cursor()->GetCursorWindow()); |
| + DCHECK(window); |
| + LocatedEvent* located_event = static_cast<LocatedEvent*>(event); |
| + gfx::Point event_point = located_event->location(); |
| + gfx::Point window_origin = GetBounds().origin(); |
| + gfx::Point cursor_origin = window->GetBounds().origin(); |
| + located_event->set_location( |
| + gfx::Point(event_point.x() + cursor_origin.x() - window_origin.x(), |
| + event_point.y() + cursor_origin.y() - window_origin.y())); |
| + located_event->set_root_location(located_event->root_location()); |
| + } |
| + } |
| DispatchEventFromNativeUiEvent( |
| native_event, |
| base::Bind(&PlatformWindowDelegate::DispatchEvent, |