[PATCH v3 2/6] winex11.drv: Only call XWarpPointer if we can get exclusive grab

Rémi Bernon rbernon at codeweavers.com
Thu Jun 27 09:30:11 CDT 2019


XWarpPointer will always succeed regardless of grabs. If the pointer is
already grabbed by some other application, we should not ask to warp it.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/winex11.drv/mouse.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index f737a306a56..c3a9a027957 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -1430,6 +1430,18 @@ BOOL CDECL X11DRV_SetCursorPos( INT x, INT y )
     struct x11drv_thread_data *data = x11drv_init_thread_data();
     POINT pos = virtual_screen_to_root( x, y );
 
+    if (!clipping_cursor &&
+        XGrabPointer( data->display, root_window, False,
+                      PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
+                      GrabModeAsync, GrabModeAsync, root_window, None, CurrentTime ) != GrabSuccess)
+    {
+        WARN( "refusing to warp pointer to %u, %u without exclusive grab\n", pos.x, pos.y );
+        return FALSE;
+    }
+
+    if (!clipping_cursor)
+        XUngrabPointer( data->display, CurrentTime );
+
     XWarpPointer( data->display, root_window, root_window, 0, 0, 0, 0, pos.x, pos.y );
     data->warp_serial = NextRequest( data->display );
     XNoOp( data->display );
-- 
2.20.1




More information about the wine-devel mailing list