From: Po Lu Date: Fri, 17 Jun 2022 04:57:03 +0000 (+0800) Subject: Fix instances of not using a usable Motif drag atom X-Git-Tag: emacs-29.0.90~1447^2~1695 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cce197c630ed3913ef4b5d39bdcb1d684c861a87;p=emacs.git Fix instances of not using a usable Motif drag atom * src/xterm.c (xm_get_drag_atom_1): If another frame owns an atom, use it anyway. --- diff --git a/src/xterm.c b/src/xterm.c index e26cd586797..9d5e1babf39 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -1063,6 +1063,7 @@ static void x_frame_rehighlight (struct x_display_info *); static void x_clip_to_row (struct window *, struct glyph_row *, enum glyph_row_area, GC); static struct scroll_bar *x_window_to_scroll_bar (Display *, Window, int); +static struct frame *x_window_to_frame (struct x_display_info *, int); static void x_scroll_bar_report_motion (struct frame **, Lisp_Object *, enum scroll_bar_part *, Lisp_Object *, Lisp_Object *, @@ -2197,6 +2198,7 @@ xm_get_drag_atom_1 (struct x_display_info *dpyinfo, int rc, actual_format; unsigned long i; char *buffer; + Window owner; /* Make sure this operation is done atomically. */ XGrabServer (dpyinfo->display); @@ -2221,11 +2223,18 @@ xm_get_drag_atom_1 (struct x_display_info *dpyinfo, for (i = 0; i < nitems; ++i) { - if (XGetSelectionOwner (dpyinfo->display, - atoms[i]) == None - && !x_had_errors_p (dpyinfo->display)) + owner = XGetSelectionOwner (dpyinfo->display, atoms[i]); + + if (!x_had_errors_p (dpyinfo->display) + && (owner == None + /* If we already own this selection (even if another + frame owns it), use it. There is no way of + knowing when ownership was asserted, so it still + has to be owned again. */ + || x_window_to_frame (dpyinfo, owner))) { atom = atoms[i]; + break; } }