Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Unified Diff: ui/ozone/platform/dri/dri_window.cc

Issue 657603002: ash: ozone: apply transformation to events outside the root window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on ToT Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..4aec0fc389153ff77628249155810bf1a478d805 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_->GrabMouseEvents(widget_);
+}
-void DriWindow::ReleaseCapture() {}
+void DriWindow::ReleaseCapture() {
+ window_manager_->UngrabMouseEvents(widget_);
+}
void DriWindow::ToggleFullscreen() {}
@@ -103,13 +107,32 @@ 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() || event->IsScrollEvent()) {
+ // 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_) {
+ 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_)));

Powered by Google App Engine
This is Rietveld 408576698