[dwm] dotile_noresize

From: Seth Graham <sether_AT_tru7h.org>
Date: Tue, 03 Oct 2006 15:49:14 -0500

I did a hack this afternoon to prevent dwm resizing my xterms when
switching windows to/from the main window spot.

The work I do on my laptop is sensitive to resizes (lots of serial
console connections) but I like the forced management when several
xterms are up.

The hack arrays the windows to try and keep the last line of each window
visible (usually where the important action is taking place). If a
window is made that is larger than the main window space, it is resized
to fit the width.

When using a standard 80x25 xterm this results in a lot of wasted
desktop space, but I couldn't think of any easy way around that.
Toggling float mode, resizing the xterm, and going back to tile mode
works well enough for my purposes.

Thought I'd send the patch along just in case there was any interest.
Works against 1.7.1 view.c.

99c99
< dotile(Arg *arg) {

---
> dotile_orig(Arg *arg) {
159a160,217
> dotile(Arg *arg) {
> 	int h, i, n, w;
> 	Client *c;
> 
> 	w = sw - mw;
>         for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
> 		n++;
> 
> 	if(n > 1)
> 		h = sh / (n - 1);
> 	else
> 		h = sh - bh;
> 
> 	for(i = 0, c = clients; c; c = c->next) {
> 		if(isvisible(c)) {
> 			if(c->isfloat) {
> 				resize(c, True, TopLeft);
> 				continue;
> 			}
> 			c->ismax = False;
> 			if(n == 1) {
> 				c->x = sx;
> 				c->y = sy + bh;
> 				if(c->w >= (mw - 2)) {
> 					c->w = mw - 2;
> 					c->h = sh - 2 - bh;
> 				}
> 			}
> 			else if(i == 0) {
> 				c->x = sx;
> 				c->y = sy + bh;
> 				if(c->w >= (mw - 2)) {
> 					c->w = mw - 2;
> 					c->h = sh - 2 - bh;
> 				}
> 			}
> 			else if(h > bh) {
> 				c->x = sx + mw;
> 				c->y = (i * h) - c->h;
> 			}
> 			else { /* fallback if h < bh */
> 				c->x = sx + mw;
> 				c->y = sy + bh;
> 			}
> 			resize(c, False, TopLeft);
> 			i++;
> 		}
> 		else
> 			ban(c);
> 	}
> 	if(!sel || !isvisible(sel)) {
> 		for(c = stack; c && !isvisible(c); c = c->snext);
> 		focus(c);
> 	}
> 	restack();
> }
> 
> void
Received on Tue Oct 03 2006 - 22:49:16 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:31:48 UTC