]> git.armaanb.net Git - dwm.git/blobdiff - client.c
made status bar drawing more robust, implemented togglemax and togglemode, works...
[dwm.git] / client.c
index 889daa5002c162ee03d87f1f75fdda2a69a12536..1bdebd2e5b06fa2908bf86ad10637366cb8ecb46 100644 (file)
--- a/client.c
+++ b/client.c
@@ -70,6 +70,9 @@ focusnext(Arg *arg)
        if(!sel)
                return;
 
+       if(sel->ismax)
+               togglemax(NULL);
+
        if(!(c = getnext(sel->next, tsel)))
                c = getnext(clients, tsel);
        if(c) {
@@ -87,6 +90,9 @@ focusprev(Arg *arg)
        if(!sel)
                return;
 
+       if(sel->ismax)
+               togglemax(NULL);
+
        if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
                higher(c);
                focus(c);
@@ -234,8 +240,6 @@ manage(Window w, XWindowAttributes *wa)
        c->next = clients;
        clients = c;
 
-       XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask,
-                       GrabModeAsync, GrabModeSync, None, None);
        XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask,
                        GrabModeAsync, GrabModeSync, None, None);
        XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask,
@@ -263,19 +267,6 @@ manage(Window w, XWindowAttributes *wa)
        }
 }
 
-void
-maximize(Arg *arg)
-{
-       if(!sel)
-               return;
-       sel->x = sx;
-       sel->y = sy + bh;
-       sel->w = sw - 2 * sel->border;
-       sel->h = sh - 2 * sel->border - bh;
-       higher(sel);
-       resize(sel, False, TopLeft);
-}
-
 void
 pop(Client *c)
 {
@@ -404,6 +395,38 @@ settitle(Client *c)
        resizetitle(c);
 }
 
+void
+togglemax(Arg *arg)
+{
+       int ox, oy, ow, oh;
+       XEvent ev;
+
+       if(!sel)
+               return;
+
+       if((sel->ismax = !sel->ismax)) {
+               ox = sel->x;
+               oy = sel->y;
+               ow = sel->w;
+               oh = sel->h;
+               sel->x = sx;
+               sel->y = sy + bh;
+               sel->w = sw - 2 * sel->border;
+               sel->h = sh - 2 * sel->border - bh;
+
+               higher(sel);
+               resize(sel, False, TopLeft);
+
+               sel->x = ox;
+               sel->y = oy;
+               sel->w = ow;
+               sel->h = oh;
+       }
+       else
+               resize(sel, False, TopLeft);
+       while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+}
+
 void
 unmanage(Client *c)
 {