From 458d8db7e825a48867a02ae277334fc6f01670a3 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 25 May 2022 09:38:20 +0800 Subject: [PATCH] Add more atoms that don't need a roundtrip to intern * src/xterm.c (x_intern_cached_atom): Handle dpyinfo atoms that depend on the screen number and common selection atoms. --- src/xterm.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/xterm.c b/src/xterm.c index 3fe81078819..5c8221201b1 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -23608,6 +23608,35 @@ x_intern_cached_atom (struct x_display_info *dpyinfo, char *ptr; Atom *atom; + /* Special atoms that depend on the screen number. */ + char xsettings_atom_name[sizeof "_XSETTINGS_S%d" - 2 + + INT_STRLEN_BOUND (int)]; + char cm_atom_name[sizeof "_NET_WM_CM_S%d" - 2 + + INT_STRLEN_BOUND (int)]; + + sprintf (xsettings_atom_name, "_XSETTINGS_S%d", + XScreenNumberOfScreen (dpyinfo->screen)); + sprintf (cm_atom_name, "_NET_WM_CM_S%d", + XScreenNumberOfScreen (dpyinfo->screen)); + + if (!strcmp (name, xsettings_atom_name)) + return dpyinfo->Xatom_xsettings_sel; + + if (!strcmp (name, cm_atom_name)) + return dpyinfo->Xatom_NET_WM_CM_Sn; + + /* Now do some common predefined atoms. */ + if (!strcmp (name, "PRIMARY")) + return XA_PRIMARY; + if (!strcmp (name, "SECONDARY")) + return XA_SECONDARY; + if (!strcmp (name, "STRING")) + return XA_STRING; + if (!strcmp (name, "INTEGER")) + return XA_INTEGER; + if (!strcmp (name, "ATOM")) + return XA_ATOM; + for (i = 0; i < ARRAYELTS (x_atom_refs); ++i) { ptr = (char *) dpyinfo; -- 2.39.2