JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
small change to achieve Jukka's last proposal
[dwm.git] / view.c
diff --git a/view.c b/view.c
index 1226f0d..5667134 100644 (file)
--- a/view.c
+++ b/view.c
@@ -3,7 +3,6 @@
  * See LICENSE file for license details.
  */
 #include "dwm.h"
-#include <stdio.h>
 
 /* static */
 
@@ -19,6 +18,12 @@ minclient() {
        return min;
 }
 
+static Client *
+nexttiled(Client *c) {
+       for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
+       return c;
+}
+
 static void
 reorder() {
        Client *c, *newclients, *tail;
@@ -37,10 +42,23 @@ reorder() {
        clients = newclients;
 }
 
-static Client *
-nexttiled(Client *c) {
-       for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
-       return c;
+static void
+togglemax(Client *c)
+{
+       if((c->ismax = !c->ismax)) {
+               c->rx = c->x; c->x = sx;
+               c->ry = c->y; c->y = bh;
+               c->rw = c->w; c->w = sw;
+               c->rh = c->h; c->h = sh;
+       }
+       else {
+               c->x = c->rx;
+               c->y = c->ry;
+               c->w = c->w;
+               c->h = c->h;
+       }
+       resize(c, True, TopLeft);
+       while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
 }
 
 /* extern */
@@ -62,8 +80,6 @@ void
 dofloat(Arg *arg) {
        Client *c;
 
-       maximized = False;
-
        for(c = clients; c; c = c->next) {
                if(isvisible(c)) {
                        resize(c, True, TopLeft);
@@ -83,12 +99,16 @@ dotile(Arg *arg) {
        int h, i, n, w;
        Client *c;
 
-       maximized = False;
-
        w = sw - mw;
        for(n = 0, c = clients; c; c = c->next)
-               if(isvisible(c) && !c->isfloat)
-                       n++;
+               if(isvisible(c)) {
+                       if(c->isfloat) {
+                               if(c->ismax)
+                                       togglemax(c);
+                       }
+                       else
+                               n++;
+               }
 
        if(n > 1)
                h = (sh - bh) / (n - 1);
@@ -191,7 +211,7 @@ resizecol(Arg *arg) {
        for(n = 0, c = clients; c; c = c->next)
                if(isvisible(c) && !c->isfloat)
                        n++;
-       if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized)
+       if(!sel || sel->isfloat || n < 2 || (arrange != dotile))
                return;
 
        if(sel == getnext(clients)) {
@@ -276,11 +296,20 @@ void
 zoom(Arg *arg) {
        unsigned int n;
        Client *c;
+       XEvent ev;
+
+       if(!sel)
+               return;
+
+       if(sel->isfloat || (arrange == dofloat)) {
+               togglemax(sel);
+               return;
+       }
 
        for(n = 0, c = clients; c; c = c->next)
                if(isvisible(c) && !c->isfloat)
                        n++;
-       if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized)
+       if(n < 2 || (arrange != dotile))
                return;
 
        if((c = sel) == nexttiled(clients))