about summary refs log tree commit diff
path: root/xutil.c
diff options
context:
space:
mode:
authoroga <oga>2009-01-22 15:26:33 +0000
committeroga <oga>2009-01-22 15:26:33 +0000
commite2f3810fe83a7c7fdb4bd245ccdf5e4e343d1a55 (patch)
treeafd3688024ca82fb9f224c3f7b9d1034d2febb19 /xutil.c
parent1b269199c16190c92f9318152c5beb84a854be3c (diff)
downloadcwm-e2f3810fe83a7c7fdb4bd245ccdf5e4e343d1a55.tar.gz
cwm-e2f3810fe83a7c7fdb4bd245ccdf5e4e343d1a55.tar.xz
cwm-e2f3810fe83a7c7fdb4bd245ccdf5e4e343d1a55.zip
Cache all of the X atoms we use at startup.
Do this instead of querying for them every time we use them. This
removes an XXX that has been in there since time began. This will become
more important as we move towards supporting netwm.

ok todd@, okan@.
Diffstat (limited to 'xutil.c')
-rw-r--r--xutil.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/xutil.c b/xutil.c
index 11cde2f..6db1847 100644
--- a/xutil.c
+++ b/xutil.c
@@ -145,12 +145,9 @@ xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p)
 int
 xu_getstate(struct client_ctx *cc, int *state)
 {
-	Atom	 wm_state;
 	long	*p = NULL;
 
-	wm_state = XInternAtom(X_Dpy, "WM_STATE", False);
-
-	if (xu_getprop(cc, wm_state, wm_state, 2L, (u_char **)&p) <= 0)
+	if (xu_getprop(cc, WM_STATE, WM_STATE, 2L, (u_char **)&p) <= 0)
 		return (-1);
 
 	*state = (int)*p;
@@ -162,16 +159,23 @@ xu_getstate(struct client_ctx *cc, int *state)
 void
 xu_setstate(struct client_ctx *cc, int state)
 {
-	Atom	 wm_state;
 	long	 dat[2];
 
-	/* XXX cache */
-	wm_state = XInternAtom(X_Dpy, "WM_STATE", False);
-
 	dat[0] = (long)state;
 	dat[1] = (long)None;
 
 	cc->state = state;
-	XChangeProperty(X_Dpy, cc->win, wm_state, wm_state, 32,
+	XChangeProperty(X_Dpy, cc->win, WM_STATE, WM_STATE, 32,
 	    PropModeReplace, (unsigned char *)dat, 2);
 }
+
+Atom		cwm_atoms[CWM_NO_ATOMS];
+
+void
+xu_getatoms(void)
+{
+	WM_STATE = XInternAtom(X_Dpy, "WM_STATE", False);	
+	WM_DELETE_WINDOW = XInternAtom(X_Dpy, "WM_DELETE_WINDOW", False);	
+	WM_TAKE_FOCUS = XInternAtom(X_Dpy, "WM_TAKE_FOCUS", False);
+	WM_PROTOCOLS = XInternAtom(X_Dpy, "WM_PROTOCOLS", False);
+}