[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/6] xterm: use atoms in set_wm_state
From: |
Julien Danjou |
Subject: |
[PATCH 3/6] xterm: use atoms in set_wm_state |
Date: |
Wed, 10 Nov 2010 14:49:53 +0100 |
Signed-off-by: Julien Danjou <address@hidden>
---
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
- X atoms rework, Julien Danjou, 2010/11/10
- [PATCH 5/6] xsmfns: use pre-fetch SM_CLIENT_ID, Julien Danjou, 2010/11/10
- [PATCH 3/6] xterm: use atoms in set_wm_state,
Julien Danjou <=
- [PATCH 6/6] xsettings: prefetch atoms, Julien Danjou, 2010/11/10
- [PATCH 4/6] xterm: get all atoms in one round-trip, Julien Danjou, 2010/11/10
- [PATCH 2/6] xselect: split x_send_client_event to use Atom directly, Julien Danjou, 2010/11/10
- [PATCH 1/6] xterm: store atoms in dpyinfo, Julien Danjou, 2010/11/10
- Re: X atoms rework, Jan Djärv, 2010/11/10
- Re: X atoms rework, Jan D., 2010/11/11
- Re: X atoms rework, Jan Djärv, 2010/11/12