JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
minor fix to view()
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index b7e937d..a13f07b 100644 (file)
--- 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 {
@@ -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
@@ -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");