summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2009-01-22 15:26:34 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2009-01-22 15:26:34 +0000
commitcda7a4e93f341d20401f56ae7b4d13740b46acaf (patch)
treec497552a74bfc76b7bd940fb6e7e52beeb1155e4 /app
parentc0ff7e001a65c3c977fc83db1080a6adc6aee294 (diff)
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 'app')
-rw-r--r--app/cwm/calmwm.c4
-rw-r--r--app/cwm/calmwm.h12
-rw-r--r--app/cwm/client.c28
-rw-r--r--app/cwm/xutil.c24
4 files changed, 36 insertions, 32 deletions
diff --git a/app/cwm/calmwm.c b/app/cwm/calmwm.c
index 82806472e..05c494571 100644
--- a/app/cwm/calmwm.c
+++ b/app/cwm/calmwm.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: calmwm.c,v 1.33 2009/01/16 15:24:14 okan Exp $
+ * $Id: calmwm.c,v 1.34 2009/01/22 15:26:33 oga Exp $
*/
#include "headers.h"
@@ -74,10 +74,12 @@ main(int argc, char **argv)
bzero(&Conf, sizeof(Conf));
conf_setup(&Conf, conf_file);
client_setup();
+ xu_getatoms();
x_setup();
Starting = 0;
xev_init();
+
XEV_QUICK(NULL, NULL, MapRequest, xev_handle_maprequest, NULL);
XEV_QUICK(NULL, NULL, UnmapNotify, xev_handle_unmapnotify, NULL);
XEV_QUICK(NULL, NULL, ConfigureRequest,
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index 96152cd7d..4869890fb 100644
--- a/app/cwm/calmwm.h
+++ b/app/cwm/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: calmwm.h,v 1.77 2009/01/21 15:04:38 todd Exp $
+ * $Id: calmwm.h,v 1.78 2009/01/22 15:26:33 oga Exp $
*/
#ifndef _CALMWM_H_
@@ -373,6 +373,7 @@ struct xevent *xev_new(Window *, Window *, int,
void xev_register(struct xevent *);
void xev_loop(void);
+void xu_getatoms(void);
int xu_ptr_grab(Window, int, Cursor);
void xu_btn_grab(Window, int, u_int);
int xu_ptr_regrab(int, Cursor);
@@ -506,4 +507,13 @@ extern struct client_ctx_q Clientq;
extern int HasXinerama, HasRandr, Randr_ev;
extern struct conf Conf;
+#define WM_STATE cwm_atoms[0]
+#define WM_DELETE_WINDOW cwm_atoms[1]
+#define WM_TAKE_FOCUS cwm_atoms[2]
+#define WM_PROTOCOLS cwm_atoms[3]
+#define _MOTIF_WM_HINTS cwm_atoms[4]
+#define CWM_NO_ATOMS 5
+
+extern Atom cwm_atoms[CWM_NO_ATOMS];
+
#endif /* _CALMWM_H_ */
diff --git a/app/cwm/client.c b/app/cwm/client.c
index 147d93d07..98927f858 100644
--- a/app/cwm/client.c
+++ b/app/cwm/client.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: client.c,v 1.44 2009/01/17 18:41:50 oga Exp $
+ * $Id: client.c,v 1.45 2009/01/22 15:26:33 oga Exp $
*/
#include "headers.h"
@@ -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))
diff --git a/app/cwm/xutil.c b/app/cwm/xutil.c
index a7ec1e967..e19b73b5b 100644
--- a/app/cwm/xutil.c
+++ b/app/cwm/xutil.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: xutil.c,v 1.9 2008/07/22 20:26:12 oga Exp $
+ * $Id: xutil.c,v 1.10 2009/01/22 15:26:33 oga Exp $
*/
#include "headers.h"
@@ -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);
+}