emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 965b8b0: Grab the server when warping the client pointer


From: Po Lu
Subject: master 965b8b0: Grab the server when warping the client pointer
Date: Fri, 24 Dec 2021 01:23:35 -0500 (EST)

branch: master
commit 965b8b0fad617a6a1050ca850567726cb7197694
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Grab the server when warping the client pointer
    
    * src/xfns.c (Fx_set_mouse_absolute_pixel_position):
    * src/xterm.c (x_make_frame_invisible): Avoid race conditions
    where the client pointer is destroyed between when it is
    obtained and when XIWarpPointer is called.
---
 src/xfns.c  | 2 ++
 src/xterm.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/xfns.c b/src/xfns.c
index 168debc..b02996c 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5648,6 +5648,7 @@ The coordinates X and Y are interpreted in pixels 
relative to a position
 
   if (FRAME_DISPLAY_INFO (f)->supports_xi2)
     {
+      XGrabServer (FRAME_X_DISPLAY (f));
       if (XIGetClientPointer (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                              &deviceid))
        {
@@ -5655,6 +5656,7 @@ The coordinates X and Y are interpreted in pixels 
relative to a position
                         DefaultRootWindow (FRAME_X_DISPLAY (f)),
                         0, 0, 0, 0, xval, yval);
        }
+      XUngrabServer (FRAME_X_DISPLAY (f));
     }
   else
 #endif
diff --git a/src/xterm.c b/src/xterm.c
index aa88610..4200102 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -13242,6 +13242,7 @@ frame_set_mouse_pixel_position (struct frame *f, int 
pix_x, int pix_y)
 
   if (FRAME_DISPLAY_INFO (f)->supports_xi2)
     {
+      XGrabServer (FRAME_X_DISPLAY (f));
       if (XIGetClientPointer (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                              &deviceid))
        {
@@ -13250,6 +13251,7 @@ frame_set_mouse_pixel_position (struct frame *f, int 
pix_x, int pix_y)
                         FRAME_X_WINDOW (f),
                         0, 0, 0, 0, pix_x, pix_y);
        }
+      XUngrabServer (FRAME_X_DISPLAY (f));
     }
   else
 #endif



reply via email to

[Prev in Thread] Current Thread [Next in Thread]