emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/6] xterm: get all atoms in one round-trip


From: Julien Danjou
Subject: [PATCH 4/6] xterm: get all atoms in one round-trip
Date: Wed, 10 Nov 2010 14:49:54 +0100

Signed-off-by: Julien Danjou <address@hidden>
---
 src/ChangeLog |    3 +-
 src/xterm.c   |  165 +++++++++++++++++++++++++--------------------------------
 2 files changed, 75 insertions(+), 93 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index f1bbcb4..13bb320 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,4 @@
-2010-11-09  Julien Danjou  <address@hidden>
+2010-11-10  Julien Danjou  <address@hidden>
 
        * xterm.c (set_wm_state): Use x_send_client_event rather than
        Fx_send_client_event, using Atom directly.
@@ -7,6 +7,7 @@
        XInternAtom request.
        (x_set_sticky): Pass atoms to set_wm_state.
        (do_ewmh_fullscreen): Ditto.
+       (x_term_init): Get all atoms in one round-trip.
 
        * xselect.c (Fx_send_client_event): Split and create
        x_send_client_event.
diff --git a/src/xterm.c b/src/xterm.c
index fb24ea3..36cbb12 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10194,98 +10194,79 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
       dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm;
     }
 
-  dpyinfo->Xatom_wm_protocols
-    = XInternAtom (dpyinfo->display, "WM_PROTOCOLS", False);
-  dpyinfo->Xatom_wm_take_focus
-    = XInternAtom (dpyinfo->display, "WM_TAKE_FOCUS", False);
-  dpyinfo->Xatom_wm_save_yourself
-    = XInternAtom (dpyinfo->display, "WM_SAVE_YOURSELF", False);
-  dpyinfo->Xatom_wm_delete_window
-    = XInternAtom (dpyinfo->display, "WM_DELETE_WINDOW", False);
-  dpyinfo->Xatom_wm_change_state
-    = XInternAtom (dpyinfo->display, "WM_CHANGE_STATE", False);
-  dpyinfo->Xatom_wm_configure_denied
-    = XInternAtom (dpyinfo->display, "WM_CONFIGURE_DENIED", False);
-  dpyinfo->Xatom_wm_window_moved
-    = XInternAtom (dpyinfo->display, "WM_MOVED", False);
-  dpyinfo->Xatom_wm_client_leader
-    = XInternAtom (dpyinfo->display, "WM_CLIENT_LEADER", False);
-  dpyinfo->Xatom_editres
-    = XInternAtom (dpyinfo->display, "Editres", False);
-  dpyinfo->Xatom_CLIPBOARD
-    = XInternAtom (dpyinfo->display, "CLIPBOARD", False);
-  dpyinfo->Xatom_TIMESTAMP
-    = XInternAtom (dpyinfo->display, "TIMESTAMP", False);
-  dpyinfo->Xatom_TEXT
-    = XInternAtom (dpyinfo->display, "TEXT", False);
-  dpyinfo->Xatom_COMPOUND_TEXT
-    = XInternAtom (dpyinfo->display, "COMPOUND_TEXT", False);
-  dpyinfo->Xatom_UTF8_STRING
-    = XInternAtom (dpyinfo->display, "UTF8_STRING", False);
-  dpyinfo->Xatom_DELETE
-    = XInternAtom (dpyinfo->display, "DELETE", False);
-  dpyinfo->Xatom_MULTIPLE
-    = XInternAtom (dpyinfo->display, "MULTIPLE", False);
-  dpyinfo->Xatom_INCR
-    = XInternAtom (dpyinfo->display, "INCR", False);
-  dpyinfo->Xatom_EMACS_TMP
-    = XInternAtom (dpyinfo->display, "_EMACS_TMP_", False);
-  dpyinfo->Xatom_TARGETS
-    = XInternAtom (dpyinfo->display, "TARGETS", False);
-  dpyinfo->Xatom_NULL
-    = XInternAtom (dpyinfo->display, "NULL", False);
-  dpyinfo->Xatom_ATOM_PAIR
-    = XInternAtom (dpyinfo->display, "ATOM_PAIR", False);
-  dpyinfo->Xatom_XEMBED_INFO
-    = XInternAtom (dpyinfo->display, "_XEMBED_INFO", False);
-  /* For properties of font.  */
-  dpyinfo->Xatom_PIXEL_SIZE
-    = XInternAtom (dpyinfo->display, "PIXEL_SIZE", False);
-  dpyinfo->Xatom_AVERAGE_WIDTH
-    = XInternAtom (dpyinfo->display, "AVERAGE_WIDTH", False);
-  dpyinfo->Xatom_MULE_BASELINE_OFFSET
-    = XInternAtom (dpyinfo->display, "_MULE_BASELINE_OFFSET", False);
-  dpyinfo->Xatom_MULE_RELATIVE_COMPOSE
-    = XInternAtom (dpyinfo->display, "_MULE_RELATIVE_COMPOSE", False);
-  dpyinfo->Xatom_MULE_DEFAULT_ASCENT
-    = XInternAtom (dpyinfo->display, "_MULE_DEFAULT_ASCENT", False);
-
-  /* Ghostscript support.  */
-  dpyinfo->Xatom_PAGE = XInternAtom (dpyinfo->display, "PAGE", False);
-  dpyinfo->Xatom_DONE = XInternAtom (dpyinfo->display, "DONE", False);
-
-  dpyinfo->Xatom_Scrollbar = XInternAtom (dpyinfo->display, "SCROLLBAR",
-                                         False);
-
-  dpyinfo->Xatom_XEMBED = XInternAtom (dpyinfo->display, "_XEMBED",
-                                      False);
-
-  dpyinfo->Xatom_net_wm_state
-    = XInternAtom (dpyinfo->display, "_NET_WM_STATE", False);
-  dpyinfo->Xatom_net_wm_state_fullscreen
-    = XInternAtom (dpyinfo->display, "_NET_WM_STATE_FULLSCREEN", False);
-  dpyinfo->Xatom_net_wm_state_maximized_horz
-    = XInternAtom (dpyinfo->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
-  dpyinfo->Xatom_net_wm_state_maximized_vert
-    = XInternAtom (dpyinfo->display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
-  dpyinfo->Xatom_net_wm_state_sticky
-    = XInternAtom (dpyinfo->display, "_NET_WM_STATE_STICKY", False);
-  dpyinfo->Xatom_net_window_type
-    = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE", False);
-  dpyinfo->Xatom_net_window_type_tooltip
-    = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE_TOOLTIP", False);
-  dpyinfo->Xatom_net_wm_icon_name
-    = XInternAtom (dpyinfo->display, "_NET_WM_ICON_NAME", False);
-  dpyinfo->Xatom_net_wm_name
-    = XInternAtom (dpyinfo->display, "_NET_WM_NAME", False);
-  dpyinfo->Xatom_net_supported
-    = XInternAtom (dpyinfo->display, "_NET_SUPPORTED", False);
-  dpyinfo->Xatom_net_supported
-    = XInternAtom (dpyinfo->display, "_NET_SUPPORTING_WM_CHECK", False);
-  dpyinfo->Xatom_net_wm_window_opacity
-    = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_OPACITY", False);
-  dpyinfo->Xatom_net_active_window
-    = XInternAtom (dpyinfo->display, "_NET_ACTIVE_WINDOW", False);
+  {
+    const struct AtomRef
+    {
+      const char *name;
+      Atom *atom;
+    }
+    atom_refs[] =
+      {
+        "WM_PROTOCOLS", &dpyinfo->Xatom_wm_protocols,
+        "WM_TAKE_FOCUS", &dpyinfo->Xatom_wm_take_focus,
+        "WM_SAVE_YOURSELF", &dpyinfo->Xatom_wm_save_yourself,
+        "WM_DELETE_WINDOW", &dpyinfo->Xatom_wm_delete_window,
+        "WM_CHANGE_STATE", &dpyinfo->Xatom_wm_change_state,
+        "WM_CONFIGURE_DENIED", &dpyinfo->Xatom_wm_configure_denied,
+        "WM_MOVED", &dpyinfo->Xatom_wm_window_moved,
+        "WM_CLIENT_LEADER", &dpyinfo->Xatom_wm_client_leader,
+        "Editres", &dpyinfo->Xatom_editres,
+        "CLIPBOARD", &dpyinfo->Xatom_CLIPBOARD,
+        "TIMESTAMP", &dpyinfo->Xatom_TIMESTAMP,
+        "TEXT", &dpyinfo->Xatom_TEXT,
+        "COMPOUND_TEXT", &dpyinfo->Xatom_COMPOUND_TEXT,
+        "UTF8_STRING", &dpyinfo->Xatom_UTF8_STRING,
+        "DELETE", &dpyinfo->Xatom_DELETE,
+        "MULTIPLE", &dpyinfo->Xatom_MULTIPLE,
+        "INCR", &dpyinfo->Xatom_INCR,
+        "_EMACS_TMP_",  &dpyinfo->Xatom_EMACS_TMP,
+        "TARGETS", &dpyinfo->Xatom_TARGETS,
+        "NULL", &dpyinfo->Xatom_NULL,
+        "ATOM_PAIR", &dpyinfo->Xatom_ATOM_PAIR,
+        "_XEMBED_INFO", &dpyinfo->Xatom_XEMBED_INFO,
+        /* For properties of font.  */
+        "PIXEL_SIZE", &dpyinfo->Xatom_PIXEL_SIZE,
+        "AVERAGE_WIDTH", &dpyinfo->Xatom_AVERAGE_WIDTH,
+        "_MULE_BASELINE_OFFSET", &dpyinfo->Xatom_MULE_BASELINE_OFFSET,
+        "_MULE_RELATIVE_COMPOSE", &dpyinfo->Xatom_MULE_RELATIVE_COMPOSE,
+        "_MULE_DEFAULT_ASCENT", &dpyinfo->Xatom_MULE_DEFAULT_ASCENT,
+        /* Ghostscript support.  */
+        "DONE", &dpyinfo->Xatom_DONE,
+        "PAGE", &dpyinfo->Xatom_PAGE,
+        "SCROLLBAR", &dpyinfo->Xatom_Scrollbar,
+        "_XEMBED", &dpyinfo->Xatom_XEMBED,
+        /* EWMH */
+        "_NET_WM_STATE", &dpyinfo->Xatom_net_wm_state,
+        "_NET_WM_STATE_FULLSCREEN", &dpyinfo->Xatom_net_wm_state_fullscreen,
+        "_NET_WM_STATE_MAXIMIZED_HORZ", 
&dpyinfo->Xatom_net_wm_state_maximized_horz,
+        "_NET_WM_STATE_MAXIMIZED_VERT", 
&dpyinfo->Xatom_net_wm_state_maximized_vert,
+        "_NET_WM_STATE_STICKY", &dpyinfo->Xatom_net_wm_state_sticky,
+        "_NET_WM_WINDOW_TYPE", &dpyinfo->Xatom_net_window_type,
+        "_NET_WM_WINDOW_TYPE_TOOLTIP", &dpyinfo->Xatom_net_window_type_tooltip,
+        "_NET_WM_ICON_NAME", &dpyinfo->Xatom_net_wm_icon_name,
+        "_NET_WM_NAME", &dpyinfo->Xatom_net_wm_name,
+        "_NET_SUPPORTED",  &dpyinfo->Xatom_net_supported,
+        "_NET_SUPPORTING_WM_CHECK", &dpyinfo->Xatom_net_supported,
+        "_NET_WM_WINDOW_OPACITY", &dpyinfo->Xatom_net_wm_window_opacity,
+        "_NET_ACTIVE_WINDOW", &dpyinfo->Xatom_net_active_window
+      };
+
+    int i;
+    const int atom_count = sizeof (atom_refs) / sizeof (atom_refs[0]);
+    Atom *atoms_return = xmalloc (sizeof (Atom) * atom_count);
+    char **atom_names = xmalloc (sizeof (char *) * atom_count);
+
+    for (i = 0; i < atom_count; i++)
+      atom_names[i] = (char *) atom_refs[i].name;
+
+    XInternAtoms (dpyinfo->display, atom_names, atom_count, False, 
atoms_return);
+
+    for (i = 0; i < atom_count; i++)
+      *atom_refs[i].atom = atoms_return[i];
+
+    xfree (atom_names);
+    xfree (atoms_return);
+  }
 
   dpyinfo->x_dnd_atoms_size = 8;
   dpyinfo->x_dnd_atoms_length = 0;
-- 
1.7.2.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]