Good day everybody. This is my first post to this list, but I have
been using dwm for some time and am very pleased with it as my main
window manager. I've made many small changes here and there during my
[blissful :)] time with dwm, so I thought about sharing some. This
particular one was requested by a friend of mine, so I've chosen it to
be the first.

Name:
    Automatic Float On Maximize

Description:
    Automatically toggles floating mode (if required) when calling
togglemax(), and then toggles it once more on the second call.


I hope you find it useful.

- Abel
diff --git a/dwm.h b/dwm.h
index 999f027..3b10067 100644
--- a/dwm.h
+++ b/dwm.h
@@ -50,7 +50,7 @@ struct Client {
 	int minax, maxax, minay, maxay;
 	long flags; 
 	unsigned int border, oldborder;
-	Bool isbanned, isfixed, ismax, isfloating;
+	Bool isbanned, isfixed, ismax, isfloating, wasfloating;
 	Bool *tags;
 	Client *next;
 	Client *prev;
diff --git a/layout.c b/layout.c
index f8c92ee..2e335e1 100644
--- a/layout.c
+++ b/layout.c
@@ -224,17 +224,26 @@ void
 togglemax(const char *arg) {
 	XEvent ev;
 
-	if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed)
+	if(!sel || sel->isfixed)
 		return;
 	if((sel->ismax = !sel->ismax)) {
+		if (lt->arrange != floating && !sel->isfloating) {
+			togglefloating(NULL);
+			sel->wasfloating = False;
+	    	}
+		else
+			sel->wasfloating = True;
 		sel->rx = sel->x;
 		sel->ry = sel->y;
 		sel->rw = sel->w;
 		sel->rh = sel->h;
 		resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
 	}
-	else
+	else {
 		resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
+		if (!sel->wasfloating)
+			togglefloating(NULL);
+	}
 	drawstatus();
 	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
 }

Reply via email to