all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Julien Danjou <julien@danjou.info>
To: emacs-devel@gnu.org
Cc: Julien Danjou <julien@danjou.info>
Subject: [PATCH 6/6] xsettings: prefetch atoms
Date: Wed, 10 Nov 2010 14:49:56 +0100	[thread overview]
Message-ID: <1289396996-26774-7-git-send-email-julien@danjou.info> (raw)
In-Reply-To: <1289396996-26774-1-git-send-email-julien@danjou.info>

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 src/ChangeLog   |    4 ++++
 src/xsettings.c |    8 --------
 src/xterm.c     |   25 ++++++++++++++++++++-----
 3 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 3975d8b..2b7acb5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
 2010-11-10  Julien Danjou  <julien@danjou.info>
 
+	* xterm.c (x_term_init): Fetch XSETTINGS atoms.
+
+	* xsettings.c (init_xsettings): Use already fetch atoms.
+
 	* xterm.h (x_display_info): Add SM_CLIENT_ID atom.
 
 	* xsmfns.c (create_client_leader_window): Use SM_CLIENT_ID atom
diff --git a/src/xsettings.c b/src/xsettings.c
index 0d9c9ca..b3f3cb6 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -656,18 +656,10 @@ init_gconf (void)
 static void
 init_xsettings (struct x_display_info *dpyinfo)
 {
-  char sel[64];
   Display *dpy = dpyinfo->display;
 
   BLOCK_INPUT;
 
-  sprintf (sel, "_XSETTINGS_S%d", XScreenNumberOfScreen (dpyinfo->screen));
-  dpyinfo->Xatom_xsettings_sel = XInternAtom (dpy, sel, False);
-  dpyinfo->Xatom_xsettings_prop = XInternAtom (dpy,
-                                               "_XSETTINGS_SETTINGS",
-                                               False);
-  dpyinfo->Xatom_xsettings_mgr = XInternAtom (dpy, "MANAGER", False);
-
   /* Select events so we can detect client messages sent when selection
      owner changes.  */
   XSelectInput (dpy, dpyinfo->root_window, StructureNotifyMask);
diff --git a/src/xterm.c b/src/xterm.c
index e8a7d07..1900881 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10249,22 +10249,37 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
         "_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,
-        "SM_CLIENT_ID", &dpyinfo->Xatom_SM_CLIENT_ID
+        "SM_CLIENT_ID", &dpyinfo->Xatom_SM_CLIENT_ID,
+        "_XSETTINGS_SETTINGS", &dpyinfo->Xatom_xsettings_prop,
+        "MANAGER", &dpyinfo->Xatom_xsettings_mgr
       };
 
     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);
+    const int atom_count = (sizeof (atom_refs) / sizeof (atom_refs[0]));
+    /* 1 for _XSETTINGS_SN  */
+    const int total_atom_count = 1 + atom_count;
+    Atom *atoms_return = xmalloc (sizeof (Atom) * total_atom_count);
+    char **atom_names = xmalloc (sizeof (char *) * total_atom_count);
+    char xsettings_atom_name[64];
 
     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);
+    /* Build _XSETTINGS_SN atom name */
+    snprintf (xsettings_atom_name, sizeof (xsettings_atom_name),
+              "_XSETTINGS_S%d", XScreenNumberOfScreen (dpyinfo->screen));
+    atom_names[i] = xsettings_atom_name;
 
+    /* Fetch atoms */
+    XInternAtoms (dpyinfo->display, atom_names, total_atom_count, False, atoms_return);
+
+    /* Copy atoms back */
     for (i = 0; i < atom_count; i++)
       *atom_refs[i].atom = atoms_return[i];
 
+    /* Manual copy of last atoms */
+    dpyinfo->Xatom_xsettings_sel = atoms_return[i];
+
     xfree (atom_names);
     xfree (atoms_return);
   }
-- 
1.7.2.3




  parent reply	other threads:[~2010-11-10 13:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-10 13:49 X atoms rework Julien Danjou
2010-11-10 13:49 ` [PATCH 1/6] xterm: store atoms in dpyinfo Julien Danjou
2010-11-10 13:49 ` [PATCH 2/6] xselect: split x_send_client_event to use Atom directly Julien Danjou
2010-11-10 13:49 ` [PATCH 3/6] xterm: use atoms in set_wm_state Julien Danjou
2010-11-10 13:49 ` [PATCH 4/6] xterm: get all atoms in one round-trip Julien Danjou
2010-11-10 13:49 ` [PATCH 5/6] xsmfns: use pre-fetch SM_CLIENT_ID Julien Danjou
2010-11-10 13:49 ` Julien Danjou [this message]
2010-11-10 17:19 ` X atoms rework Jan Djärv
2010-11-11  7:22 ` Jan D.
2010-11-11  8:22   ` Julien Danjou
2010-11-12  9:32 ` Jan Djärv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1289396996-26774-7-git-send-email-julien@danjou.info \
    --to=julien@danjou.info \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.