From 4cf885a41a9e15a9668862747117e57f31b6146b Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 13 Apr 2022 10:07:00 +0800 Subject: [PATCH] Fix bit rot in the XEmbed code * src/xterm.c (x_term_init): Delete unused atom. (handle_one_xevent): (x_make_frame_visible): Handle embedded frame visibility correctly. * src/xterm.h (struct x_display_info): Delete unused atom. --- src/xterm.c | 18 ++++++++++++++---- src/xterm.h | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index 2999480659b..c1c9ebde5cb 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -14060,7 +14060,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, } f = x_top_window_to_frame (dpyinfo, event->xproperty.window); - if (f && event->xproperty.atom == dpyinfo->Xatom_net_wm_state) + if (f && event->xproperty.atom == dpyinfo->Xatom_net_wm_state + /* This should never happen with embedded windows. */ + && !FRAME_X_EMBEDDED_P (f)) { bool not_hidden = x_handle_net_wm_state (f, &event->xproperty); @@ -14417,7 +14419,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, x_set_z_group (f, Qbelow, Qnil); } - if (not_hidden) + /* Embedded frames might have NET_WM_STATE left over, but + are always visible once mapped. */ + if (not_hidden || FRAME_X_EMBEDDED_P (f)) { SET_FRAME_VISIBLE (f, 1); SET_FRAME_ICONIFIED (f, false); @@ -14436,7 +14440,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, x_update_opaque_region (f, NULL); - if (not_hidden && iconified) + if ((not_hidden || FRAME_X_EMBEDDED_P (f)) && iconified) { inev.ie.kind = DEICONIFY_EVENT; XSETFRAME (inev.ie.frame_or_window, f); @@ -15543,6 +15547,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, /* Even if the number of character rows and columns has not changed, the font size may have changed, so we need to check the pixel dimensions as well. */ + if (width != FRAME_PIXEL_WIDTH (f) || height != FRAME_PIXEL_HEIGHT (f) || (f->new_size_p @@ -21217,6 +21222,12 @@ x_make_frame_visible (struct frame *f) XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); #endif /* not USE_GTK */ #endif /* not USE_X_TOOLKIT */ + + if (FRAME_X_EMBEDDED_P (f)) + { + SET_FRAME_VISIBLE (f, true); + SET_FRAME_ICONIFIED (f, false); + } } XFlush (FRAME_X_DISPLAY (f)); @@ -22949,7 +22960,6 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) ATOM_REFS_INIT ("ATOM", Xatom_ATOM) ATOM_REFS_INIT ("ATOM_PAIR", Xatom_ATOM_PAIR) ATOM_REFS_INIT ("CLIPBOARD_MANAGER", Xatom_CLIPBOARD_MANAGER) - ATOM_REFS_INIT ("XATOM_COUNTER", Xatom_XEMBED_INFO) ATOM_REFS_INIT ("_XEMBED_INFO", Xatom_XEMBED_INFO) ATOM_REFS_INIT ("_MOTIF_WM_HINTS", Xatom_MOTIF_WM_HINTS) /* For properties of font. */ diff --git a/src/xterm.h b/src/xterm.h index 69313166db9..75094082683 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -414,7 +414,7 @@ struct x_display_info Atom Xatom_CLIPBOARD, Xatom_TIMESTAMP, Xatom_TEXT, Xatom_DELETE, Xatom_COMPOUND_TEXT, Xatom_UTF8_STRING, Xatom_MULTIPLE, Xatom_INCR, Xatom_EMACS_TMP, Xatom_TARGETS, Xatom_NULL, - Xatom_ATOM, Xatom_ATOM_PAIR, Xatom_CLIPBOARD_MANAGER, Xatom_COUNTER, + Xatom_ATOM, Xatom_ATOM_PAIR, Xatom_CLIPBOARD_MANAGER, Xatom_EMACS_SERVER_TIME_PROP; /* More atoms for font properties. The last three are private -- 2.39.5