]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't send XdndPosition before XdndStatus arrives
authorPo Lu <luangruo@yahoo.com>
Thu, 23 Jun 2022 03:31:10 +0000 (11:31 +0800)
committerPo Lu <luangruo@yahoo.com>
Thu, 23 Jun 2022 03:31:10 +0000 (11:31 +0800)
* src/xterm.c (x_dnd_send_position): Set pending DND message if
target is right.
(x_dnd_send_leave): Clear pending status target.
(x_dnd_begin_drag_and_drop): Clear new flags.
(handle_one_xevent): Respect those flags.

src/xterm.c

index b6300f831fd37c8d8053ce3f7ca23191f15ab6c4..d3e6c5323b715d2293473cad5b09ce041e91941a 100644 (file)
@@ -1235,6 +1235,14 @@ static Window x_dnd_mouse_rect_target;
    drop target if the mouse pointer lies within.  */
 static XRectangle x_dnd_mouse_rect;
 
+/* If not None, Emacs is waiting for an XdndStatus event from this
+   window.  */
+static Window x_dnd_waiting_for_status_window;
+
+/* If .type != 0, an event that should be sent to .xclient.window
+   upon receiving an XdndStatus event from said window.  */
+static XEvent x_dnd_pending_send_position;
+
 /* The action the drop target actually chose to perform.
 
    Under XDND, this is set upon receiving the XdndFinished or
@@ -4380,9 +4388,16 @@ x_dnd_send_position (struct frame *f, Window target, int supported,
   if (supported >= 4)
     msg.xclient.data.l[4] = action;
 
-  x_catch_errors (dpyinfo->display);
-  XSendEvent (FRAME_X_DISPLAY (f), target, False, NoEventMask, &msg);
-  x_uncatch_errors ();
+  if (x_dnd_waiting_for_status_window == target)
+    x_dnd_pending_send_position = msg;
+  else
+    {
+      x_catch_errors (dpyinfo->display);
+      XSendEvent (FRAME_X_DISPLAY (f), target, False, NoEventMask, &msg);
+      x_uncatch_errors ();
+
+      x_dnd_waiting_for_status_window = target;
+    }
 }
 
 static void
@@ -4401,6 +4416,9 @@ x_dnd_send_leave (struct frame *f, Window target)
   msg.xclient.data.l[3] = 0;
   msg.xclient.data.l[4] = 0;
 
+  puts ("RESET PENDING");
+  x_dnd_waiting_for_status_window = None;
+
   x_catch_errors (dpyinfo->display);
   XSendEvent (FRAME_X_DISPLAY (f), target, False, NoEventMask, &msg);
   x_uncatch_errors ();
@@ -11437,6 +11455,8 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
   x_dnd_return_frame = 0;
   x_dnd_waiting_for_finish = false;
   x_dnd_waiting_for_motif_finish = 0;
+  x_dnd_waiting_for_status_window = None;
+  x_dnd_pending_send_position.type = 0;
   x_dnd_xm_use_help = false;
   x_dnd_motif_setup_p = false;
   x_dnd_end_window = None;
@@ -16326,6 +16346,22 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                  x_dnd_action = None;
              }
 
+           /* Send any pending XdndPosition message.  */
+           if (x_dnd_waiting_for_status_window == target)
+             {
+               if (x_dnd_pending_send_position.type != 0)
+                 {
+                   x_catch_errors (dpyinfo->display);
+                   XSendEvent (dpyinfo->display, target,
+                               False, NoEventMask,
+                               &x_dnd_pending_send_position);
+                   x_uncatch_errors ();
+                 }
+
+               x_dnd_pending_send_position.type = 0;
+               x_dnd_waiting_for_status_window = None;
+             }
+
            goto done;
          }