]> git.eshelyaron.com Git - emacs.git/commitdiff
Add more atoms that don't need a roundtrip to intern
authorPo Lu <luangruo@yahoo.com>
Wed, 25 May 2022 01:38:20 +0000 (09:38 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 25 May 2022 01:39:04 +0000 (09:39 +0800)
* src/xterm.c (x_intern_cached_atom): Handle dpyinfo atoms that
depend on the screen number and common selection atoms.

src/xterm.c

index 3fe810788199b0bf163ad5048d9d0a18f0002448..5c8221201b1e49b576150a6c694da59a49f8aa77 100644 (file)
@@ -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;