X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=dwm.c;h=a13f07b529870678cab06ec13175e7bcd66845ac;hb=bf76cefe47749f784d4ee3b7b71c1c86460e236b;hp=fe2dc1f10127bfb17c1035d074f5f3587dae24b0;hpb=0c38ec7cd64dfc0bebccfcb0da2a2d250bf5f46e;p=dwm.git diff --git a/dwm.c b/dwm.c index fe2dc1f..a13f07b 100644 --- a/dwm.c +++ b/dwm.c @@ -94,6 +94,8 @@ struct Client { Client *next; Client *snext; Window win; + void *aux; + void (*freeaux)(void *); }; typedef struct { @@ -310,8 +312,8 @@ buttonpress(XEvent *e) { click = ClkRootWin; if(ev->window == barwin) { - for(i = x = 0; ev->x >= x && ++i < LENGTH(tags); i++) - x += TEXTW(tags[i]); + i = x = 0; + do x += TEXTW(tags[i]); while(ev->x >= x && ++i < LENGTH(tags)); if(i < LENGTH(tags)) { click = ClkTagBar; arg.ui = 1 << i; @@ -723,19 +725,18 @@ gettextprop(Window w, Atom atom, char *text, uint size) { void grabbuttons(Client *c, Bool focused) { - int i, j; - uint buttons[] = { Button1, Button2, Button3 }; - uint modifiers[] = { MODKEY, MODKEY|LockMask, MODKEY|numlockmask, MODKEY|numlockmask|LockMask }; + uint i, j; + uint modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; XUngrabButton(dpy, AnyButton, AnyModifier, c->win); - if(focused) + if(focused) { for(i = 0; i < LENGTH(buttons); i++) - for(j = 0; j < LENGTH(modifiers); j++) - XGrabButton(dpy, buttons[i], modifiers[j], c->win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - else + if(buttons[i].click == ClkClientWin) + for(j = 0; j < LENGTH(modifiers); j++) + XGrabButton(dpy, buttons[i].button, buttons[i].mask | modifiers[j], c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); + } else XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); + BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); } void @@ -962,7 +963,7 @@ monocle(void) { Client *c; for(c = nexttiled(clients); c; c = nexttiled(c->next)) - resize(c, wx, wy, ww, wh, resizehints); + resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints); } void @@ -1520,6 +1521,8 @@ unmanage(Client *c) { detachstack(c); if(sel == c) focus(NULL); + if(c->aux && c->freeaux) + c->freeaux(c->aux); XUngrabButton(dpy, AnyButton, AnyModifier, c->win); setclientstate(c, WithdrawnState); free(c); @@ -1643,6 +1646,8 @@ updatewmhints(Client *c) { void view(const Arg *arg) { + if(arg && (arg->i & TAGMASK) == tagset[seltags]) + return; seltags ^= 1; /* toggle sel tagset */ if(arg && (arg->ui & TAGMASK)) tagset[seltags] = arg->i & TAGMASK; @@ -1704,7 +1709,9 @@ main(int argc, char *argv[]) { else if(argc != 1) eprint("usage: dwm [-v]\n"); - setlocale(LC_CTYPE, ""); + if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) + fprintf(stderr, "warning: no locale support\n"); + if(!(dpy = XOpenDisplay(0))) eprint("dwm: cannot open display\n");