]> git.eshelyaron.com Git - emacs.git/commitdiff
Prevent races when trying to set Motif drag window
authorPo Lu <luangruo@yahoo.com>
Wed, 6 Apr 2022 09:17:41 +0000 (17:17 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 6 Apr 2022 09:18:26 +0000 (17:18 +0800)
* src/xterm.c (xm_get_drag_window): Grab temp connection when
setting the drag window.

src/xterm.c

index 7eef2b488be975b493f86b25d5f15f9ab3e5ca59..b6aed004ed39e8b23f9faf7e55bd9da60f6a673e 100644 (file)
@@ -1395,13 +1395,18 @@ xm_get_drag_window (struct x_display_info *dpyinfo)
 
   if (drag_window == None)
     {
+      block_input ();
       unrequest_sigio ();
       temp_display = XOpenDisplay (XDisplayString (dpyinfo->display));
       request_sigio ();
 
       if (!temp_display)
-       return None;
+       {
+         unblock_input ();
+         return None;
+       }
 
+      XGrabServer (temp_display);
       XSetCloseDownMode (temp_display, RetainPermanent);
       attrs.override_redirect = True;
       drag_window = XCreateWindow (temp_display, DefaultRootWindow (temp_display),
@@ -1422,6 +1427,7 @@ xm_get_drag_window (struct x_display_info *dpyinfo)
                            drag_window, &wattrs);
       rc = !x_had_errors_p (dpyinfo->display);
       x_uncatch_errors_after_check ();
+      unblock_input ();
 
       /* We connected to the wrong display, so just give up.  */
       if (!rc)