From c7e4c1a5fa3ecbcb29cba6f01016808f1a524eaf Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 26 May 2022 08:13:17 +0800 Subject: [PATCH] Improve x_get_atom_name for some predefined atoms * src/xterm.c (x_get_atom_name): Handle XSETTINGS and cm atoms. --- src/xterm.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index 1997cc77dc1..1d91055a4af 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -23674,19 +23674,21 @@ x_intern_cached_atom (struct x_display_info *dpyinfo, return XInternAtom (dpyinfo->display, name, False); } -/* Whether or not a request to the X server happened is placed in - NEED_SYNC. */ +/* Get the name of ATOM, but try not to make a request to the X + server. Whether or not a request to the X server happened is + placed in NEED_SYNC. */ char * x_get_atom_name (struct x_display_info *dpyinfo, Atom atom, bool *need_sync) { - char *dpyinfo_pointer, *name, *value; + char *dpyinfo_pointer, *name, *value, *buffer; int i; Atom ref_atom; dpyinfo_pointer = (char *) dpyinfo; value = NULL; *need_sync = false; + buffer = alloca (45 + INT_STRLEN_BOUND (int)); switch (atom) { @@ -23709,6 +23711,20 @@ x_get_atom_name (struct x_display_info *dpyinfo, Atom atom, return xstrdup ("WINDOW"); default: + if (atom == dpyinfo->Xatom_xsettings_sel) + { + sprintf (buffer, "_XSETTINGS_S%d", + XScreenNumberOfScreen (dpyinfo->screen)); + return xstrdup (buffer); + } + + if (atom == dpyinfo->Xatom_NET_WM_CM_Sn) + { + sprintf (buffer, "_NET_WM_CM_S%d", + XScreenNumberOfScreen (dpyinfo->screen)); + return xstrdup (buffer); + } + for (i = 0; i < ARRAYELTS (x_atom_refs); ++i) { ref_atom = *(Atom *) (dpyinfo_pointer -- 2.39.2