From 55e9d729ca34c4dd05bfb0d606425b8fc27d53ca Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 16 Jun 2022 13:58:39 +0800 Subject: [PATCH] Fix Motif DND after atom ownership is lost due to frame destruction * src/xterm.c (xm_get_drag_atom_1): Record owner. (x_free_frame_resources): Clear drag atom if owner was freed. * src/xterm.h (struct x_display_info): New field `motif_drag_atom_owner'. --- src/xterm.c | 7 +++++++ src/xterm.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/xterm.c b/src/xterm.c index cc47427a9d7..04e3223478f 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -2281,6 +2281,7 @@ xm_get_drag_atom_1 (struct x_display_info *dpyinfo, } dpyinfo->motif_drag_atom_time = dpyinfo->last_user_time; + dpyinfo->motif_drag_atom_owner = source_frame; XUngrabServer (dpyinfo->display); return atom; @@ -25310,6 +25311,12 @@ x_free_frame_resources (struct frame *f) g_object_unref (FRAME_OUTPUT_DATA (f)->scrollbar_foreground_css_provider); #endif + if (f == dpyinfo->motif_drag_atom_owner) + { + dpyinfo->motif_drag_atom_owner = NULL; + dpyinfo->motif_drag_atom = None; + } + if (f == dpyinfo->x_focus_frame) dpyinfo->x_focus_frame = 0; if (f == dpyinfo->x_focus_event_frame) diff --git a/src/xterm.h b/src/xterm.h index 119382c73ce..ad0df6bff93 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -576,6 +576,9 @@ struct x_display_info /* When it was owned. */ Time motif_drag_atom_time; + /* The frame that currently owns `motif_drag_atom'. */ + struct frame *motif_drag_atom_owner; + /* Extended window manager hints, Atoms supported by the window manager and atoms for setting the window type. */ Atom Xatom_net_supported, Xatom_net_supporting_wm_check; -- 2.39.2