unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* X atoms rework
@ 2010-11-10 13:49 Julien Danjou
  2010-11-10 13:49 ` [PATCH 1/6] xterm: store atoms in dpyinfo Julien Danjou
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Julien Danjou @ 2010-11-10 13:49 UTC (permalink / raw)
  To: emacs-devel

I've been hacking in xterm.c this days, and saw some things I did not
like that much about the handling of X atoms.

Therefore, I rewrote this part, and here's a set of patch that enhance
things a bit.  It should make X initialization faster over the
network, at least, and stop requesting atoms that Emacs should already
have locally.

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/6] xterm: store atoms in dpyinfo
  2010-11-10 13:49 X atoms rework Julien Danjou
@ 2010-11-10 13:49 ` Julien Danjou
  2010-11-10 13:49 ` [PATCH 2/6] xselect: split x_send_client_event to use Atom directly Julien Danjou
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Julien Danjou @ 2010-11-10 13:49 UTC (permalink / raw)
  To: emacs-devel; +Cc: Julien Danjou

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 src/ChangeLog |   14 ++++++++++++++
 src/xterm.c   |   47 +++++++++++++++++++++++++++--------------------
 src/xterm.h   |    8 ++++++--
 3 files changed, 47 insertions(+), 22 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 4e9f403..994d106 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,19 @@
 2010-11-09  Julien Danjou  <julien@danjou.info>
 
+	* xterm.c (x_set_frame_alpha): Use _NET_WM_WINDOW_OPACITY atom
+	from dpyinfo.
+	(wm_supports): Use atoms from dpyinfo.
+	(do_ewmh_fullscreen): Use atoms from dpyinfo.
+	(x_ewmh_activate_frame): Use atoms from dpyinfo.
+	(xembed_set_info): Use atoms from dpyinfo.
+	(x_term_init): Fetch _XEMBED_INFO, _NET_SUPPORTED,
+	_NET_SUPPORTING_WM_CHECK, _NET_WM_WINDOW_OPACITY and
+	_NET_ACTIVE_WINDOW atoms.
+
+	* xterm.h (x_display_info): Add Xatom_net_supported,
+	Xatom_net_supporting_wm_check, Xatom_net_active_window,
+	Xatom_net_wm_window_opacity, Xatom_XEMBED_INFO.
+
 	* xfns.c (Fx_show_tip): Fix typo in docstring.
 
 2010-11-07  Jan Djärv  <jan.h.d@swipnet.se>
diff --git a/src/xterm.c b/src/xterm.c
index 7297ee7..5df0fbc 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -442,7 +442,6 @@ x_display_info_for_display (Display *dpy)
 }
 
 #define OPAQUE  0xffffffff
-#define OPACITY "_NET_WM_WINDOW_OPACITY"
 
 void
 x_set_frame_alpha (struct frame *f)
@@ -486,7 +485,7 @@ x_set_frame_alpha (struct frame *f)
     unsigned long n, left;
 
     x_catch_errors (dpy);
-    rc = XGetWindowProperty (dpy, win, XInternAtom(dpy, OPACITY, False),
+    rc = XGetWindowProperty (dpy, win, dpyinfo->Xatom_net_wm_window_opacity,
 			     0L, 1L, False, XA_CARDINAL,
 			     &actual, &format, &n, &left,
 			     &data);
@@ -504,7 +503,7 @@ x_set_frame_alpha (struct frame *f)
   }
 
   x_catch_errors (dpy);
-  XChangeProperty (dpy, win, XInternAtom (dpy, OPACITY, False),
+  XChangeProperty (dpy, win, dpyinfo->Xatom_net_wm_window_opacity,
 		   XA_CARDINAL, 32, PropModeReplace,
 		   (unsigned char *) &opac, 1L);
   x_uncatch_errors ();
@@ -8285,12 +8284,11 @@ x_set_offset (struct frame *f, register int xoff, register int yoff, int change_
    http://freedesktop.org/wiki/Specifications/wm-spec.  */
 
 static int
-wm_supports (struct frame *f, const char *atomname)
+wm_supports (struct frame *f, Atom want_atom)
 {
   Atom actual_type;
   unsigned long actual_size, bytes_remaining;
   int i, rc, actual_format;
-  Atom prop_atom;
   Window wmcheck_window;
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
   Window target_window = dpyinfo->root_window;
@@ -8298,15 +8296,13 @@ wm_supports (struct frame *f, const char *atomname)
   Display *dpy = FRAME_X_DISPLAY (f);
   unsigned char *tmp_data = NULL;
   Atom target_type = XA_WINDOW;
-  Atom want_atom;
 
   BLOCK_INPUT;
 
-  prop_atom = XInternAtom (dpy, "_NET_SUPPORTING_WM_CHECK", False);
-
   x_catch_errors (dpy);
   rc = XGetWindowProperty (dpy, target_window,
-                           prop_atom, 0, max_len, False, target_type,
+                           dpyinfo->Xatom_net_supporting_wm_check,
+                           0, max_len, False, target_type,
                            &actual_type, &actual_format, &actual_size,
                            &bytes_remaining, &tmp_data);
 
@@ -8341,10 +8337,10 @@ wm_supports (struct frame *f, const char *atomname)
       dpyinfo->net_supported_window = 0;
 
       target_type = XA_ATOM;
-      prop_atom = XInternAtom (dpy, "_NET_SUPPORTED", False);
       tmp_data = NULL;
       rc = XGetWindowProperty (dpy, target_window,
-                               prop_atom, 0, max_len, False, target_type,
+                               dpyinfo->Xatom_net_supported,
+                               0, max_len, False, target_type,
                                &actual_type, &actual_format, &actual_size,
                                &bytes_remaining, &tmp_data);
 
@@ -8362,7 +8358,6 @@ wm_supports (struct frame *f, const char *atomname)
     }
 
   rc = 0;
-  want_atom = XInternAtom (dpy, atomname, False);
 
   for (i = 0; rc == 0 && i < dpyinfo->nr_net_supported_atoms; ++i)
     rc = dpyinfo->net_supported_atoms[i] == want_atom;
@@ -8457,7 +8452,7 @@ get_current_vm_state (struct frame *f,
           else
             *size_state = FULLSCREEN_HEIGHT;
         }
-      else if (a == dpyinfo->Xatom_net_wm_state_fullscreen_atom)
+      else if (a == dpyinfo->Xatom_net_wm_state_fullscreen)
         *size_state = FULLSCREEN_BOTH;
       else if (a == dpyinfo->Xatom_net_wm_state_sticky)
         *sticky = 1;
@@ -8472,7 +8467,8 @@ get_current_vm_state (struct frame *f,
 static int
 do_ewmh_fullscreen (struct frame *f)
 {
-  int have_net_atom = wm_supports (f, "_NET_WM_STATE");
+  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  int have_net_atom = wm_supports (f, dpyinfo->Xatom_net_wm_state);
   Lisp_Object lval = get_frame_param (f, Qfullscreen);
   int cur, dummy;
 
@@ -8481,7 +8477,7 @@ do_ewmh_fullscreen (struct frame *f)
   /* Some window managers don't say they support _NET_WM_STATE, but they do say
      they support _NET_WM_STATE_FULLSCREEN.  Try that also.  */
   if (!have_net_atom)
-      have_net_atom = wm_supports (f, "_NET_WM_STATE_FULLSCREEN");
+    have_net_atom = wm_supports (f, dpyinfo->Xatom_net_wm_state_fullscreen);
 
   if (have_net_atom && cur != f->want_fullscreen)
     {
@@ -8967,7 +8963,8 @@ x_ewmh_activate_frame (FRAME_PTR f)
      http://freedesktop.org/wiki/Specifications/wm-spec  */
 
   const char *atom = "_NET_ACTIVE_WINDOW";
-  if (f->async_visible && wm_supports (f, atom))
+  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  if (f->async_visible && wm_supports (f, dpyinfo->Xatom_net_active_window))
     {
       Lisp_Object frame;
       XSETFRAME (frame, f);
@@ -8996,13 +8993,13 @@ xembed_set_info (struct frame *f, enum xembed_info flags)
 {
   Atom atom;
   unsigned long data[2];
-
-  atom = XInternAtom (FRAME_X_DISPLAY (f), "_XEMBED_INFO", False);
+  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
 
   data[0] = XEMBED_VERSION;
   data[1] = flags;
 
-  XChangeProperty (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), atom, atom,
+  XChangeProperty (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
+                   dpyinfo->Xatom_XEMBED_INFO, dpyinfo->Xatom_XEMBED_INFO,
 		   32, PropModeReplace, (unsigned char *) data, 2);
 }
 
@@ -10238,6 +10235,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
     = 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);
@@ -10262,7 +10261,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
 
   dpyinfo->Xatom_net_wm_state
     = XInternAtom (dpyinfo->display, "_NET_WM_STATE", False);
-  dpyinfo->Xatom_net_wm_state_fullscreen_atom
+  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);
@@ -10278,6 +10277,14 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_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);
 
   dpyinfo->x_dnd_atoms_size = 8;
   dpyinfo->x_dnd_atoms_length = 0;
diff --git a/src/xterm.h b/src/xterm.h
index ec99a65..72529b0 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -270,7 +270,7 @@ struct x_display_info
   Atom Xatom_Scrollbar;
 
   /* Atom used in XEmbed client messages.  */
-  Atom Xatom_XEMBED;
+  Atom Xatom_XEMBED, Xatom_XEMBED_INFO;;
  
   /* The frame (if any) which has the X window that has keyboard focus.
      Zero if none.  This is examined by Ffocus_frame in xfns.c.  Note
@@ -332,13 +332,15 @@ struct x_display_info
 
   /* Extended window manager hints, Atoms supported by the window manager and
      atoms for settig the window type.  */
+  Atom Xatom_net_supported, Xatom_net_supporting_wm_check;
   Atom *net_supported_atoms;
   int nr_net_supported_atoms;
   Window net_supported_window;
   Atom Xatom_net_window_type, Xatom_net_window_type_tooltip;
+  Atom Xatom_net_active_window;
 
   /* Atoms dealing with maximization and fullscreen */
-  Atom Xatom_net_wm_state, Xatom_net_wm_state_fullscreen_atom,
+  Atom Xatom_net_wm_state, Xatom_net_wm_state_fullscreen,
     Xatom_net_wm_state_maximized_horz, Xatom_net_wm_state_maximized_vert,
     Xatom_net_wm_state_sticky;
 
@@ -348,6 +350,8 @@ struct x_display_info
 
   /* Frame name and icon name */
   Atom Xatom_net_wm_name, Xatom_net_wm_icon_name;
+  /* Frame opacity */
+  Atom Xatom_net_wm_window_opacity;
 };
 
 #ifdef HAVE_X_I18N
-- 
1.7.2.3




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/6] xselect: split x_send_client_event to use Atom directly
  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 ` Julien Danjou
  2010-11-10 13:49 ` [PATCH 3/6] xterm: use atoms in set_wm_state Julien Danjou
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Julien Danjou @ 2010-11-10 13:49 UTC (permalink / raw)
  To: emacs-devel; +Cc: Julien Danjou

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 src/ChangeLog |    9 +++++++++
 src/lisp.h    |    1 -
 src/xselect.c |   17 +++++++++++++----
 src/xterm.c   |   38 +++++++++++++++++++-------------------
 src/xterm.h   |    7 +++++++
 5 files changed, 48 insertions(+), 24 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 994d106..8810dad 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,14 @@
 2010-11-09  Julien Danjou  <julien@danjou.info>
 
+	* xterm.c (set_wm_state): Use x_send_client_event rather than
+	Fx_send_client_event, using Atom directly.
+	(x_ewmh_activate_frame): Ditto.
+
+	* xselect.c (Fx_send_client_event): Split and create
+	x_send_client_event.
+
+	* lisp.h: Do not EXFUN Fx_send_client_event.
+
 	* xterm.c (x_set_frame_alpha): Use _NET_WM_WINDOW_OPACITY atom
 	from dpyinfo.
 	(wm_supports): Use atoms from dpyinfo.
diff --git a/src/lisp.h b/src/lisp.h
index 4adf9ef..6c00aa2 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3600,7 +3600,6 @@ extern void syms_of_xfns (void);
 extern void syms_of_xsmfns (void);
 
 /* Defined in xselect.c */
-EXFUN (Fx_send_client_event, 6);
 extern void syms_of_xselect (void);
 
 /* Defined in xterm.c */
diff --git a/src/xselect.c b/src/xselect.c
index 7479f24..b566b90 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2527,6 +2527,18 @@ are ignored.  */)
   (Lisp_Object display, Lisp_Object dest, Lisp_Object from, Lisp_Object message_type, Lisp_Object format, Lisp_Object values)
 {
   struct x_display_info *dpyinfo = check_x_display_info (display);
+
+  x_send_client_event(display, dest, from,
+                      XInternAtom (dpyinfo->display, SDATA (message_type), False),
+                      format, values);
+
+  return Qnil;
+}
+
+void
+x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from, Atom message_type, Lisp_Object format, Lisp_Object values)
+{
+  struct x_display_info *dpyinfo = check_x_display_info (display);
   Window wdest;
   XEvent event;
   Lisp_Object cons;
@@ -2584,8 +2596,7 @@ are ignored.  */)
 
   BLOCK_INPUT;
 
-  event.xclient.message_type
-    = XInternAtom (dpyinfo->display, SDATA (message_type), False);
+  event.xclient.message_type = message_type;
   event.xclient.display = dpyinfo->display;
 
   /* Some clients (metacity for example) expects sending window to be here
@@ -2610,8 +2621,6 @@ are ignored.  */)
   }
   x_uncatch_errors ();
   UNBLOCK_INPUT;
-
-  return Qnil;
 }
 
 \f
diff --git a/src/xterm.c b/src/xterm.c
index 5df0fbc..f8e95ba 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8371,19 +8371,20 @@ wm_supports (struct frame *f, Atom want_atom)
 static void
 set_wm_state (Lisp_Object frame, int add, const char *what, const char *what2)
 {
-  const char *atom = "_NET_WM_STATE";
-  Fx_send_client_event (frame, make_number (0), frame,
-                        make_unibyte_string (atom, strlen (atom)),
-                        make_number (32),
-                        /* 1 = add, 0 = remove */
+  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (frame));
+
+  x_send_client_event (frame, make_number (0), frame,
+                       dpyinfo->Xatom_net_wm_state,
+                       make_number (32),
+                       /* 1 = add, 0 = remove */
+                       Fcons
+                       (make_number (add ? 1 : 0),
                         Fcons
-                        (make_number (add ? 1 : 0),
-                         Fcons
-                         (make_unibyte_string (what, strlen (what)),
-                          what2 != 0
-                          ? Fcons (make_unibyte_string (what2, strlen (what2)),
-                                   Qnil)
-                          : Qnil)));
+                        (make_unibyte_string (what, strlen (what)),
+                         what2 != 0
+                         ? Fcons (make_unibyte_string (what2, strlen (what2)),
+                                  Qnil)
+                         : Qnil)));
 }
 
 void
@@ -8962,18 +8963,17 @@ x_ewmh_activate_frame (FRAME_PTR f)
   /* See Window Manager Specification/Extended Window Manager Hints at
      http://freedesktop.org/wiki/Specifications/wm-spec  */
 
-  const char *atom = "_NET_ACTIVE_WINDOW";
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
   if (f->async_visible && wm_supports (f, dpyinfo->Xatom_net_active_window))
     {
       Lisp_Object frame;
       XSETFRAME (frame, f);
-      Fx_send_client_event (frame, make_number (0), frame,
-                            make_unibyte_string (atom, strlen (atom)),
-                            make_number (32),
-                            Fcons (make_number (1),
-                                   Fcons (make_number (last_user_time),
-                                          Qnil)));
+      x_send_client_event (frame, make_number (0), frame,
+                           dpyinfo->Xatom_net_active_window,
+                           make_number (32),
+                           Fcons (make_number (1),
+                                  Fcons (make_number (last_user_time),
+                                         Qnil)));
     }
 }
 
diff --git a/src/xterm.h b/src/xterm.h
index 72529b0..d9ed120 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1015,6 +1015,13 @@ extern void x_handle_selection_notify (XSelectionEvent *);
 extern void x_handle_selection_event (struct input_event *);
 extern void x_clear_frame_selections (struct frame *);
 
+extern void x_send_client_event (Lisp_Object display,
+                                 Lisp_Object dest,
+                                 Lisp_Object from,
+                                 Atom message_type,
+                                 Lisp_Object format,
+                                 Lisp_Object values);
+
 extern int x_handle_dnd_message (struct frame *,
                                  XClientMessageEvent *,
                                  struct x_display_info *,
-- 
1.7.2.3




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/6] xterm: use atoms in set_wm_state
  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 ` Julien Danjou
  2010-11-10 13:49 ` [PATCH 4/6] xterm: get all atoms in one round-trip Julien Danjou
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Julien Danjou @ 2010-11-10 13:49 UTC (permalink / raw)
  To: emacs-devel; +Cc: Julien Danjou

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 src/ChangeLog |    4 ++++
 src/xterm.c   |   41 +++++++++++++++++++++--------------------
 2 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 8810dad..f1bbcb4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -3,6 +3,10 @@
 	* xterm.c (set_wm_state): Use x_send_client_event rather than
 	Fx_send_client_event, using Atom directly.
 	(x_ewmh_activate_frame): Ditto.
+	(set_wm_state): Use directly atoms, not their names to save a
+	XInternAtom request.
+	(x_set_sticky): Pass atoms to set_wm_state.
+	(do_ewmh_fullscreen): Ditto.
 
 	* xselect.c (Fx_send_client_event): Split and create
 	x_send_client_event.
diff --git a/src/xterm.c b/src/xterm.c
index f8e95ba..fb24ea3 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8369,7 +8369,7 @@ wm_supports (struct frame *f, Atom want_atom)
 }
 
 static void
-set_wm_state (Lisp_Object frame, int add, const char *what, const char *what2)
+set_wm_state (Lisp_Object frame, int add, Atom atom, Atom value)
 {
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (frame));
 
@@ -8380,21 +8380,20 @@ set_wm_state (Lisp_Object frame, int add, const char *what, const char *what2)
                        Fcons
                        (make_number (add ? 1 : 0),
                         Fcons
-                        (make_unibyte_string (what, strlen (what)),
-                         what2 != 0
-                         ? Fcons (make_unibyte_string (what2, strlen (what2)),
-                                  Qnil)
-                         : Qnil)));
+                        (atom,
+                         value != 0 ? value : Qnil)));
 }
 
 void
 x_set_sticky (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
 {
   Lisp_Object frame;
+  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
 
   XSETFRAME (frame, f);
+
   set_wm_state (frame, NILP (new_value) ? 0 : 1,
-                "_NET_WM_STATE_STICKY", NULL);
+                dpyinfo->Xatom_net_wm_state_sticky, None);
 }
 
 /* Return the current _NET_WM_STATE.
@@ -8483,9 +8482,6 @@ do_ewmh_fullscreen (struct frame *f)
   if (have_net_atom && cur != f->want_fullscreen)
     {
       Lisp_Object frame;
-      const char *fs = "_NET_WM_STATE_FULLSCREEN";
-      const char *fw = "_NET_WM_STATE_MAXIMIZED_HORZ";
-      const char *fh = "_NET_WM_STATE_MAXIMIZED_VERT";
 
       XSETFRAME (frame, f);
 
@@ -8497,33 +8493,38 @@ do_ewmh_fullscreen (struct frame *f)
         case FULLSCREEN_BOTH:
           if (cur == FULLSCREEN_WIDTH || cur == FULLSCREEN_MAXIMIZED
               || cur == FULLSCREEN_HEIGHT)
-            set_wm_state (frame, 0, fw, fh);
-          set_wm_state (frame, 1, fs, NULL);
+            set_wm_state (frame, 0, dpyinfo->Xatom_net_wm_state_maximized_horz,
+                          dpyinfo->Xatom_net_wm_state_maximized_vert);
+          set_wm_state (frame, 1, dpyinfo->Xatom_net_wm_state_fullscreen, None);
           break;
         case FULLSCREEN_WIDTH:
           if (cur == FULLSCREEN_BOTH || cur == FULLSCREEN_HEIGHT
               || cur == FULLSCREEN_MAXIMIZED)
-            set_wm_state (frame, 0, fs, fh);
+            set_wm_state (frame, 0, dpyinfo->Xatom_net_wm_state_fullscreen,
+                          dpyinfo->Xatom_net_wm_state_maximized_vert);
           if (cur != FULLSCREEN_MAXIMIZED)
-            set_wm_state (frame, 1, fw, NULL);
+            set_wm_state (frame, 1, dpyinfo->Xatom_net_wm_state_maximized_horz, None);
           break;
         case FULLSCREEN_HEIGHT:
           if (cur == FULLSCREEN_BOTH || cur == FULLSCREEN_WIDTH
               || cur == FULLSCREEN_MAXIMIZED)
-            set_wm_state (frame, 0, fs, fw);
+            set_wm_state (frame, 0, dpyinfo->Xatom_net_wm_state_fullscreen,
+                          dpyinfo->Xatom_net_wm_state_maximized_horz);
           if (cur != FULLSCREEN_MAXIMIZED)
-            set_wm_state (frame, 1, fh, NULL);
+            set_wm_state (frame, 1, dpyinfo->Xatom_net_wm_state_maximized_vert, None);
           break;
         case FULLSCREEN_MAXIMIZED:
           if (cur == FULLSCREEN_BOTH)
-            set_wm_state (frame, 0, fs, NULL);
-          set_wm_state (frame, 1, fw, fh);
+            set_wm_state (frame, 0, dpyinfo->Xatom_net_wm_state_fullscreen, None);
+          set_wm_state (frame, 1, dpyinfo->Xatom_net_wm_state_maximized_horz,
+                        dpyinfo->Xatom_net_wm_state_maximized_vert);
           break;
         case FULLSCREEN_NONE:
           if (cur == FULLSCREEN_BOTH)
-            set_wm_state (frame, 0, fs, NULL);
+            set_wm_state (frame, 0, dpyinfo->Xatom_net_wm_state_fullscreen, None);
           else
-            set_wm_state (frame, 0, fw, fh);
+            set_wm_state (frame, 0, dpyinfo->Xatom_net_wm_state_maximized_horz,
+                          dpyinfo->Xatom_net_wm_state_maximized_vert);
         }
 
       f->want_fullscreen = FULLSCREEN_NONE;
-- 
1.7.2.3




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/6] xterm: get all atoms in one round-trip
  2010-11-10 13:49 X atoms rework Julien Danjou
                   ` (2 preceding siblings ...)
  2010-11-10 13:49 ` [PATCH 3/6] xterm: use atoms in set_wm_state Julien Danjou
@ 2010-11-10 13:49 ` Julien Danjou
  2010-11-10 13:49 ` [PATCH 5/6] xsmfns: use pre-fetch SM_CLIENT_ID Julien Danjou
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Julien Danjou @ 2010-11-10 13:49 UTC (permalink / raw)
  To: emacs-devel; +Cc: Julien Danjou

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 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  <julien@danjou.info>
+2010-11-10  Julien Danjou  <julien@danjou.info>
 
 	* 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




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/6] xsmfns: use pre-fetch SM_CLIENT_ID
  2010-11-10 13:49 X atoms rework Julien Danjou
                   ` (3 preceding siblings ...)
  2010-11-10 13:49 ` [PATCH 4/6] xterm: get all atoms in one round-trip Julien Danjou
@ 2010-11-10 13:49 ` Julien Danjou
  2010-11-10 13:49 ` [PATCH 6/6] xsettings: prefetch atoms Julien Danjou
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Julien Danjou @ 2010-11-10 13:49 UTC (permalink / raw)
  To: emacs-devel; +Cc: Julien Danjou

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 src/ChangeLog |    5 +++++
 src/xsmfns.c  |    4 ++--
 src/xterm.c   |    3 ++-
 src/xterm.h   |    3 +++
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 13bb320..3975d8b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
 2010-11-10  Julien Danjou  <julien@danjou.info>
 
+	* xterm.h (x_display_info): Add SM_CLIENT_ID atom.
+
+	* xsmfns.c (create_client_leader_window): Use SM_CLIENT_ID atom
+	from dpyinfo.
+
 	* xterm.c (set_wm_state): Use x_send_client_event rather than
 	Fx_send_client_event, using Atom directly.
 	(x_ewmh_activate_frame): Ditto.
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 79dccfa..7b82fd4 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -410,8 +410,8 @@ create_client_leader_window (struct x_display_info *dpyinfo, char *client_id)
   XSetClassHint (dpyinfo->display, w, &class_hints);
   XStoreName (dpyinfo->display, w, class_hints.res_name);
 
-  sm_id = XInternAtom (dpyinfo->display, "SM_CLIENT_ID", False);
-  XChangeProperty (dpyinfo->display, w, sm_id, XA_STRING, 8, PropModeReplace,
+  XChangeProperty (dpyinfo->display, w, dpyinfo->Xatom_SM_CLIENT_ID,
+                   XA_STRING, 8, PropModeReplace,
                    (unsigned char *)client_id, strlen (client_id));
 
   dpyinfo->client_leader_window = w;
diff --git a/src/xterm.c b/src/xterm.c
index 36cbb12..e8a7d07 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10248,7 +10248,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_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
+        "_NET_ACTIVE_WINDOW", &dpyinfo->Xatom_net_active_window,
+        "SM_CLIENT_ID", &dpyinfo->Xatom_SM_CLIENT_ID
       };
 
     int i;
diff --git a/src/xterm.h b/src/xterm.h
index d9ed120..ed873e6 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -352,6 +352,9 @@ struct x_display_info
   Atom Xatom_net_wm_name, Xatom_net_wm_icon_name;
   /* Frame opacity */
   Atom Xatom_net_wm_window_opacity;
+
+  /* SM */
+  Atom Xatom_SM_CLIENT_ID;
 };
 
 #ifdef HAVE_X_I18N
-- 
1.7.2.3




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 6/6] xsettings: prefetch atoms
  2010-11-10 13:49 X atoms rework Julien Danjou
                   ` (4 preceding siblings ...)
  2010-11-10 13:49 ` [PATCH 5/6] xsmfns: use pre-fetch SM_CLIENT_ID Julien Danjou
@ 2010-11-10 13:49 ` Julien Danjou
  2010-11-10 17:19 ` X atoms rework Jan Djärv
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Julien Danjou @ 2010-11-10 13:49 UTC (permalink / raw)
  To: emacs-devel; +Cc: Julien Danjou

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




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: X atoms rework
  2010-11-10 13:49 X atoms rework Julien Danjou
                   ` (5 preceding siblings ...)
  2010-11-10 13:49 ` [PATCH 6/6] xsettings: prefetch atoms Julien Danjou
@ 2010-11-10 17:19 ` Jan Djärv
  2010-11-11  7:22 ` Jan D.
  2010-11-12  9:32 ` Jan Djärv
  8 siblings, 0 replies; 11+ messages in thread
From: Jan Djärv @ 2010-11-10 17:19 UTC (permalink / raw)
  To: Julien Danjou; +Cc: emacs-devel

I think only the fourth part of the patch is worth it.  The atoms that are not 
gotten at startup are not in any critical path, rather the functions that use 
them are called very seldom.  Some atoms are only used once.

	Jan D.


Julien Danjou skrev 2010-11-10 14.49:
> I've been hacking in xterm.c this days, and saw some things I did not
> like that much about the handling of X atoms.
>
> Therefore, I rewrote this part, and here's a set of patch that enhance
> things a bit.  It should make X initialization faster over the
> network, at least, and stop requesting atoms that Emacs should already
> have locally.
>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X atoms rework
  2010-11-10 13:49 X atoms rework Julien Danjou
                   ` (6 preceding siblings ...)
  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
  8 siblings, 1 reply; 11+ messages in thread
From: Jan D. @ 2010-11-11  7:22 UTC (permalink / raw)
  To: Julien Danjou; +Cc: emacs-devel

Julien Danjou skrev 2010-11-10 14:49:
> I've been hacking in xterm.c this days, and saw some things I did not
> like that much about the handling of X atoms.
>
> Therefore, I rewrote this part, and here's a set of patch that enhance
> things a bit.  It should make X initialization faster over the
> network, at least, and stop requesting atoms that Emacs should already
> have locally.
>

Does this count as a tiny change?
Maybe you have signed papers?

	Jan D.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X atoms rework
  2010-11-11  7:22 ` Jan D.
@ 2010-11-11  8:22   ` Julien Danjou
  0 siblings, 0 replies; 11+ messages in thread
From: Julien Danjou @ 2010-11-11  8:22 UTC (permalink / raw)
  To: Jan D.; +Cc: emacs-devel

On Thu, Nov 11 2010, Jan D. wrote:

> Does this count as a tiny change?
> Maybe you have signed papers?

I've signed the papers.

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X atoms rework
  2010-11-10 13:49 X atoms rework Julien Danjou
                   ` (7 preceding siblings ...)
  2010-11-11  7:22 ` Jan D.
@ 2010-11-12  9:32 ` Jan Djärv
  8 siblings, 0 replies; 11+ messages in thread
From: Jan Djärv @ 2010-11-12  9:32 UTC (permalink / raw)
  To: Julien Danjou; +Cc: emacs-devel

2010-11-10 14:49, Julien Danjou skrev:
> I've been hacking in xterm.c this days, and saw some things I did not
> like that much about the handling of X atoms.
>
> Therefore, I rewrote this part, and here's a set of patch that enhance
> things a bit.  It should make X initialization faster over the
> network, at least, and stop requesting atoms that Emacs should already
> have locally.
>

Applied to trunk.

Thanks,

	Jan D.




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-11-12  9:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 6/6] xsettings: prefetch atoms Julien Danjou
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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).