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 3/6] xterm: use atoms in set_wm_state
Date: Wed, 10 Nov 2010 14:49:53 +0100	[thread overview]
Message-ID: <1289396996-26774-4-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/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




  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 ` Julien Danjou [this message]
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

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-4-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.