1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-28 17:22:48 -07:00

Fix closing displays when preserving selections is enabled

* src/frame.c (delete_frame): Bind `x-auto-preserve-selections'
to nil if deleting display.
* src/xselect.c (x_clear_frame_selections): Pass original frame
to that function.
* src/xterm.c (x_preserve_selections): Fix determining the new
owner.
(syms_of_xterm): New defsym `x-auto-preserve-selections'.
* src/xterm.h: Update prototypes.
This commit is contained in:
Po Lu 2022-07-13 11:01:59 +08:00
parent 113a6a0a88
commit 6be201cf51
4 changed files with 22 additions and 4 deletions

View file

@ -1933,6 +1933,9 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
int is_tooltip_frame;
bool nochild = !FRAME_PARENT_FRAME (f);
Lisp_Object minibuffer_child_frame = Qnil;
#ifdef HAVE_X_WINDOWS
specpdl_ref ref;
#endif
if (!FRAME_LIVE_P (f))
return Qnil;
@ -2116,7 +2119,18 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
/* Clear any X selections for this frame. */
#ifdef HAVE_X_WINDOWS
if (FRAME_X_P (f))
x_clear_frame_selections (f);
{
/* Don't preserve selections when a display is going away, since
that sends stuff down the wire. */
ref = SPECPDL_INDEX ();
if (EQ (force, Qnoelisp))
specbind (Qx_auto_preserve_selections, Qnil);
x_clear_frame_selections (f);
unbind_to (ref, Qnil);
}
#endif
#ifdef HAVE_PGTK

View file

@ -1128,7 +1128,7 @@ x_clear_frame_selections (struct frame *f)
}
if (x_auto_preserve_selections)
x_preserve_selections (dpyinfo, lost);
x_preserve_selections (dpyinfo, lost, frame);
}
/* True if any properties for DISPLAY and WINDOW

View file

@ -27956,7 +27956,8 @@ x_uncatch_errors_for_lisp (struct x_display_info *dpyinfo)
being deleted. */
void
x_preserve_selections (struct x_display_info *dpyinfo, Lisp_Object lost)
x_preserve_selections (struct x_display_info *dpyinfo, Lisp_Object lost,
Lisp_Object current_owner)
{
Lisp_Object tail, frame, new_owner, tem;
Time timestamp;
@ -27975,6 +27976,7 @@ x_preserve_selections (struct x_display_info *dpyinfo, Lisp_Object lost)
FOR_EACH_FRAME (tail, frame)
{
if (FRAME_X_P (XFRAME (frame))
&& !EQ (frame, current_owner)
&& FRAME_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
{
new_owner = frame;
@ -28105,6 +28107,7 @@ syms_of_xterm (void)
DEFSYM (Qlatin_1, "latin-1");
DEFSYM (Qnow, "now");
DEFSYM (Qx_dnd_targets_list, "x-dnd-targets-list");
DEFSYM (Qx_auto_preserve_selections, "x-auto-preserve-selections");
#ifdef USE_GTK
xg_default_icon_file = build_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg");

View file

@ -1643,7 +1643,8 @@ extern void xic_set_statusarea (struct frame *);
extern void xic_set_xfontset (struct frame *, const char *);
extern bool x_defined_color (struct frame *, const char *, Emacs_Color *,
bool, bool);
extern void x_preserve_selections (struct x_display_info *, Lisp_Object);
extern void x_preserve_selections (struct x_display_info *, Lisp_Object,
Lisp_Object);
#ifdef HAVE_X_I18N
extern void free_frame_xic (struct frame *);
# if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT