From: Po Lu Date: Thu, 23 Jun 2022 03:31:10 +0000 (+0800) Subject: Don't send XdndPosition before XdndStatus arrives X-Git-Tag: emacs-29.0.90~1447^2~1526 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=41540b9324283ec924d0f818e649b4b9d7679d10;p=emacs.git Don't send XdndPosition before XdndStatus arrives * 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. --- diff --git a/src/xterm.c b/src/xterm.c index b6300f831fd..d3e6c5323b7 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -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; }