X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=bb017f53de61fbd4074092a1fdc4361b819f6c05;hp=d0883279e644286fb869557684932796f39b73fa;hb=212f417e44f631d406d65156b0d244f60598b8cc;hpb=c14d293e516fa9aebffb63f9775c3be38178ccb3 diff --git a/dwm.c b/dwm.c index d088327..bb017f5 100644 --- a/dwm.c +++ b/dwm.c @@ -42,7 +42,7 @@ /* macros */ #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) -#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) +#define CLEANMASK(mask) (mask & ~numlockmask & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) #define LENGTH(X) (sizeof X / sizeof X[0]) @@ -556,8 +556,8 @@ clientmessage(XEvent *e) { } else if(cme->message_type == netatom[NetActiveWindow]) { if(!ISVISIBLE(c)) { - c->mon->seltags ^= 1; - c->mon->tagset[c->mon->seltags] = c->tags; + c->mon->seltags ^= 1; + c->mon->tagset[c->mon->seltags] = c->tags; } pop(c); } @@ -585,11 +585,13 @@ void configurenotify(XEvent *e) { Monitor *m; XConfigureEvent *ev = &e->xconfigure; + Bool dirty; if(ev->window == root) { + dirty = (sw != ev->width); sw = ev->width; sh = ev->height; - if(updategeom()) { + if(updategeom() || dirty) { if(dc.drawable != 0) XFreePixmap(dpy, dc.drawable); dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); @@ -780,32 +782,22 @@ drawbars(void) { void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) { int x; - XGCValues gcv; - XRectangle r = { dc.x, dc.y, dc.w, dc.h }; - gcv.foreground = col[invert ? ColBG : ColFG]; - XChangeGC(dpy, dc.gc, GCForeground, &gcv); + XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]); x = (dc.font.ascent + dc.font.descent + 2) / 4; - r.x = dc.x + 1; - r.y = dc.y + 1; - if(filled) { - r.width = r.height = x + 1; - XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); - } - else if(empty) { - r.width = r.height = x; - XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1); - } + if(filled) + XFillRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x+1, x+1); + else if(empty) + XDrawRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x, x); } void drawtext(const char *text, unsigned long col[ColLast], Bool invert) { char buf[256]; int i, x, y, h, len, olen; - XRectangle r = { dc.x, dc.y, dc.w, dc.h }; XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]); - XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); + XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h); if(!text) return; olen = strlen(text); @@ -828,15 +820,19 @@ drawtext(const char *text, unsigned long col[ColLast], Bool invert) { void enternotify(XEvent *e) { + Client *c; Monitor *m; XCrossingEvent *ev = &e->xcrossing; if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) return; + c = wintoclient(ev->window); if((m = wintomon(ev->window)) && m != selmon) { unfocus(selmon->sel, True); selmon = m; } + else if(c == selmon->sel || c == NULL) + return; focus((wintoclient(ev->window))); } @@ -1213,7 +1209,7 @@ movemouse(const Arg *arg) { return; do { XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); - switch (ev.type) { + switch(ev.type) { case ConfigureRequest: case Expose: case MapRequest: @@ -1274,7 +1270,7 @@ propertynotify(XEvent *e) { else if(ev->state == PropertyDelete) return; /* ignore */ else if((c = wintoclient(ev->window))) { - switch (ev->atom) { + switch(ev->atom) { default: break; case XA_WM_TRANSIENT_FOR: if(!c->isfloating && (XGetTransientForHint(dpy, c->win, &trans)) && @@ -1542,8 +1538,8 @@ setup(void) { wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); - netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False); + netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); @@ -1612,7 +1608,7 @@ spawn(const Arg *arg) { execvp(((char **)arg->v)[0], (char **)arg->v); fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]); perror(" failed"); - exit(0); + exit(EXIT_SUCCESS); } } @@ -1760,11 +1756,11 @@ unmapnotify(XEvent *e) { void updatebars(void) { Monitor *m; - XSetWindowAttributes wa; - - wa.override_redirect = True; - wa.background_pixmap = ParentRelative; - wa.event_mask = ButtonPressMask|ExposureMask; + XSetWindowAttributes wa = { + .override_redirect = True, + .background_pixmap = ParentRelative, + .event_mask = ButtonPressMask|ExposureMask + }; for(m = mons; m; m = m->next) { m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), @@ -2044,7 +2040,6 @@ zoom(const Arg *arg) { Client *c = selmon->sel; if(!selmon->lt[selmon->sellt]->arrange - || selmon->lt[selmon->sellt]->arrange == monocle || (selmon->sel && selmon->sel->isfloating)) return; if(c == nexttiled(selmon->clients)) @@ -2056,7 +2051,7 @@ zoom(const Arg *arg) { int main(int argc, char *argv[]) { if(argc == 2 && !strcmp("-v", argv[1])) - die("dwm-"VERSION", © 2006-2010 dwm engineers, see LICENSE for details\n"); + die("dwm-"VERSION", © 2006-2011 dwm engineers, see LICENSE for details\n"); else if(argc != 1) die("usage: dwm [-v]\n"); if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) @@ -2069,5 +2064,5 @@ main(int argc, char *argv[]) { run(); cleanup(); XCloseDisplay(dpy); - return 0; + return EXIT_SUCCESS; }