about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--client.c53
-rw-r--r--draw.c13
-rw-r--r--dwm.h4
-rw-r--r--event.c11
-rw-r--r--tag.c11
5 files changed, 59 insertions, 33 deletions
diff --git a/client.c b/client.c
index 889daa5..1bdebd2 100644
--- 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,
@@ -264,19 +268,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)
 {
 	Client **l;
@@ -405,6 +396,38 @@ settitle(Client *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)
 {
 	Client **l;
diff --git a/draw.c b/draw.c
index b5d8bd2..0c920e5 100644
--- a/draw.c
+++ b/draw.c
@@ -107,7 +107,7 @@ drawall()
 void
 drawstatus()
 {
-	int i;
+	int i, x;
 	Bool istile = arrange == dotile;
 
 	dc.x = dc.y = 0;
@@ -123,15 +123,14 @@ drawstatus()
 		else
 			drawtext(tags[i], (i != tsel), True);
 	}
-	if(sel) {
-		dc.x += dc.w;
-		dc.w = textw(sel->name);
-		drawtext(sel->name, istile, True);
-	}
+	x = dc.x + dc.w;
 	dc.w = textw(stext);
 	dc.x = bx + bw - dc.w;
 	drawtext(stext, !istile, False);
-
+	if(sel && ((dc.w = dc.x - x) >= bh)) {
+		dc.x = x;
+		drawtext(sel->name, istile, True);
+	}
 	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
 	XSync(dpy, False);
 }
diff --git a/dwm.h b/dwm.h
index a410f4e..1529d17 100644
--- a/dwm.h
+++ b/dwm.h
@@ -74,6 +74,7 @@ struct Client {
 	unsigned int border;
 	long flags; 
 	Bool isfloat;
+	Bool ismax;
 	Client *next;
 	Client *revert;
 	Window win;
@@ -104,11 +105,11 @@ extern void higher(Client *c);
 extern void killclient(Arg *arg);
 extern void lower(Client *c);
 extern void manage(Window w, XWindowAttributes *wa);
-extern void maximize(Arg *arg);
 extern void pop(Client *c);
 extern void resize(Client *c, Bool inc, Corner sticky);
 extern void setsize(Client *c);
 extern void settitle(Client *c);
+extern void togglemax(Arg *arg);
 extern void unmanage(Client *c);
 extern void zoom(Arg *arg);
 
@@ -137,6 +138,7 @@ extern Client *getnext(Client *c, unsigned int t);
 extern void heretag(Arg *arg);
 extern void replacetag(Arg *arg);
 extern void settags(Client *c);
+extern void togglemode(Arg *arg);
 extern void view(Arg *arg);
 
 /* util.c */
diff --git a/event.c b/event.c
index 2736903..5d7c8a7 100644
--- a/event.c
+++ b/event.c
@@ -40,8 +40,8 @@ static Key key[] = {
 	{ MODKEY,		XK_3,		view,		{ .i = Twork } }, 
 	{ MODKEY,		XK_j,		focusnext,	{ 0 } }, 
 	{ MODKEY,		XK_k,		focusprev,	{ 0 } },
-	{ MODKEY,		XK_m,		maximize,	{ 0 } }, 
-	{ MODKEY,		XK_space,	dotile,		{ 0 } }, 
+	{ MODKEY,		XK_m,		togglemax,	{ 0 } }, 
+	{ MODKEY,		XK_space,	togglemode,	{ 0 } }, 
 	{ MODKEY,		XK_Return,	zoom,		{ 0 } },
 	{ ControlMask|ShiftMask,XK_0,		heretag,	{ .i = Tscratch } }, 
 	{ ControlMask|ShiftMask,XK_1,		heretag,	{ .i = Tdev } }, 
@@ -55,7 +55,6 @@ static Key key[] = {
 	{ MODKEY|ShiftMask,	XK_g,		spawn,		{ .argv = gimp } },
 	{ MODKEY|ShiftMask,	XK_l,		spawn,		{ .argv = xlock } },
 	{ MODKEY|ShiftMask,	XK_q,		quit,		{ 0 } },
-	{ MODKEY|ShiftMask,	XK_space,	dofloat,	{ 0 } }, 
 	{ MODKEY|ShiftMask,	XK_w,		spawn,		{ .argv = browse } },
 	{ MODKEY|ShiftMask,	XK_Return,	spawn,		{ .argv = term } },
 };
@@ -170,11 +169,7 @@ buttonpress(XEvent *e)
 		default:
 			break;
 		case Button1:
-			if(arrange == dotile && !c->isfloat) {
-				if((ev->state & ControlMask) && (ev->button == Button1))
-					zoom(NULL);
-			}
-			else {
+			if(arrange == dofloat || c->isfloat) {
 				higher(c);
 				movemouse(c);
 			}
diff --git a/tag.c b/tag.c
index 186a5ae..d6c349b 100644
--- a/tag.c
+++ b/tag.c
@@ -51,8 +51,8 @@ dofloat(Arg *arg)
 {
 	Client *c;
 
-	arrange = dofloat;
 	for(c = clients; c; c = c->next) {
+		c->ismax = False;
 		if(c->tags[tsel]) {
 			resize(c, True, TopLeft);
 		}
@@ -75,7 +75,6 @@ dotile(Arg *arg)
 	Client *c;
 
 	w = sw - mw;
-	arrange = dotile;
 	for(n = 0, c = clients; c; c = c->next)
 		if(c->tags[tsel] && !c->isfloat)
 			n++;
@@ -86,6 +85,7 @@ dotile(Arg *arg)
 		h = sh - bh;
 
 	for(i = 0, c = clients; c; c = c->next) {
+		c->ismax = False;
 		if(c->tags[tsel]) {
 			if(c->isfloat) {
 				higher(c);
@@ -213,6 +213,13 @@ settags(Client *c)
 }
 
 void
+togglemode(Arg *arg)
+{
+	arrange = arrange == dofloat ? dotile : dofloat;
+	arrange(NULL);
+}
+
+void
 view(Arg *arg)
 {
 	tsel = arg->i;