summary refs log tree commit diff
path: root/client.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 /client.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 'client.c')
-rw-r--r--client.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/client.c b/client.c
index ab3bd3d..6495d01 100644
--- a/client.c
+++ b/client.c
@@ -426,23 +426,18 @@ client_draw_border(struct client_ctx *cc)
 void
 client_update(struct client_ctx *cc)
 {
-	Atom	*p, wm_delete, wm_protocols, wm_take_focus;
+	Atom	*p; 
 	int	 i;
 	long	 n;
 
-	/* XXX cache these. */
-	wm_delete = XInternAtom(X_Dpy, "WM_DELETE_WINDOW", False);
-	wm_protocols = XInternAtom(X_Dpy, "WM_PROTOCOLS", False);
-	wm_take_focus = XInternAtom(X_Dpy, "WM_TAKE_FOCUS", False);
-
-	if ((n = xu_getprop(cc, wm_protocols,
+	if ((n = xu_getprop(cc, WM_PROTOCOLS,
 		 XA_ATOM, 20L, (u_char **)&p)) <= 0)
 		return;
 
 	for (i = 0; i < n; i++)
-		if (p[i] == wm_delete)
+		if (p[i] == WM_DELETE_WINDOW)
 			cc->xproto |= CLIENT_PROTO_DELETE;
-		else if (p[i] == wm_take_focus)
+		else if (p[i] == WM_TAKE_FOCUS)
 			cc->xproto |= CLIENT_PROTO_TAKEFOCUS;
 
 	XFree(p);
@@ -451,14 +446,9 @@ client_update(struct client_ctx *cc)
 void
 client_send_delete(struct client_ctx *cc)
 {
-	Atom	 wm_delete, wm_protocols;
-
-	/* XXX - cache */
-	wm_delete = XInternAtom(X_Dpy, "WM_DELETE_WINDOW", False);
-	wm_protocols = XInternAtom(X_Dpy, "WM_PROTOCOLS", False);
 
 	if (cc->xproto & CLIENT_PROTO_DELETE)
-		xu_sendmsg(cc, wm_protocols, wm_delete);
+		xu_sendmsg(cc, WM_PROTOCOLS, WM_DELETE_WINDOW);
 	else
 		XKillClient(X_Dpy, cc->win);
 }
@@ -665,7 +655,6 @@ client_gethints(struct client_ctx *cc)
 	XClassHint		 xch;
 	int			 argc;
 	char			**argv;
-	Atom			 mha;
 	struct mwm_hints	*mwmh;
 
 	if (XGetClassHint(X_Dpy, cc->win, &xch)) {
@@ -675,9 +664,8 @@ client_gethints(struct client_ctx *cc)
 			cc->app_class = xch.res_class;
 	}
 
-	mha = XInternAtom(X_Dpy, "_MOTIF_WM_HINTS", False);
-	if (xu_getprop(cc, mha, mha, PROP_MWM_HINTS_ELEMENTS,
-	    (u_char **)&mwmh) == MWM_NUMHINTS)
+	if (xu_getprop(cc, _MOTIF_WM_HINTS, _MOTIF_WM_HINTS,
+	    PROP_MWM_HINTS_ELEMENTS, (u_char **)&mwmh) == MWM_NUMHINTS)
 		if (mwmh->flags & MWM_HINTS_DECORATIONS &&
 		    !(mwmh->decorations & MWM_DECOR_ALL) &&
 		    !(mwmh->decorations & MWM_DECOR_BORDER))