Re: [dwm] fgeom patch

2008-04-27 Thread Anselm R. Garbe
On Tue, Apr 15, 2008 at 12:05:53PM +0200, yy wrote:
> There was an error in monocle, and the floating() definition hadn't
> been removed... (ok, ok, yesterday it was not my day...). I have also
> changed zoom() so that it does an arrange if lt->isfloating or
> sel->isfloating; this way, after having manually resized windows while
> in "[M]" (or "<>=" or "<>|") you can rearrange your windows without
> toggling layouts. I think the changes (which now only adds one loc if
> you don't count the example layouts) allows much more flexibility in
> dwm, especially in floating layouts (now you can have floating layouts
> to arrange your windows in a grid, for example), and I won't need
> defines to not remember floating layout (I can use "<>=").
> Well, now I will really wait to see what you have to say, going back
> to plan9,,, sorry again for all this noise.

Applied.
-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361



Re: [dwm] fgeom patch

2008-04-20 Thread Anselm R. Garbe
On Tue, Apr 15, 2008 at 12:05:53PM +0200, yy wrote:
> There was an error in monocle, and the floating() definition hadn't
> been removed... (ok, ok, yesterday it was not my day...). I have also
> changed zoom() so that it does an arrange if lt->isfloating or
> sel->isfloating; this way, after having manually resized windows while
> in "[M]" (or "<>=" or "<>|") you can rearrange your windows without
> toggling layouts. I think the changes (which now only adds one loc if
> you don't count the example layouts) allows much more flexibility in
> dwm, especially in floating layouts (now you can have floating layouts
> to arrange your windows in a grid, for example), and I won't need
> defines to not remember floating layout (I can use "<>=").
> Well, now I will really wait to see what you have to say, going back
> to plan9,,, sorry again for all this noise.

It took me a while, but I will integrate your patch with some
modifications. Thanks a lot for your work! I'm not sure if I'm
able to integrate your patch into the current code-base until
tomorrow, but I hope so.

Kind regards,
-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361



Re: [dwm] fgeom patch

2008-04-15 Thread yy
There was an error in monocle, and the floating() definition hadn't
been removed... (ok, ok, yesterday it was not my day...). I have also
changed zoom() so that it does an arrange if lt->isfloating or
sel->isfloating; this way, after having manually resized windows while
in "[M]" (or "<>=" or "<>|") you can rearrange your windows without
toggling layouts. I think the changes (which now only adds one loc if
you don't count the example layouts) allows much more flexibility in
dwm, especially in floating layouts (now you can have floating layouts
to arrange your windows in a grid, for example), and I won't need
defines to not remember floating layout (I can use "<>=").
Well, now I will really wait to see what you have to say, going back
to plan9,,, sorry again for all this noise.


-- 


- yiyus || JGL .
diff -r 595ed1a4447c config.def.h
--- a/config.def.h	Tue Apr 08 11:49:35 2008 +0100
+++ b/config.def.h	Tue Apr 15 11:38:28 2008 +0200
@@ -35,8 +35,11 @@ Layout layouts[] = {
 Layout layouts[] = {
 	/* symbol		function	isfloating */
 	{ "[]=",		tilev,		False }, /* first entry is default */
+	{ "<>=",		tilev,		True },
 	{ "[]|",		tileh,		False },
-	{ "><>",		floating,	True },
+	{ "<>|",		tileh,		True },
+	{ "><>",		NULL,	True },
+	{ "[m]",		monocle,	False },
 	{ "[M]",		monocle,	True },
 };
 
diff -r 595ed1a4447c dwm.c
--- a/dwm.c	Tue Apr 08 11:49:35 2008 +0100
+++ b/dwm.c	Tue Apr 15 11:38:28 2008 +0200
@@ -66,6 +66,7 @@ struct Client {
 struct Client {
 	char name[256];
 	int x, y, w, h;
+	int fx, fy, fw, fh;
 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
 	int minax, maxax, minay, maxay;
 	long flags;
@@ -142,7 +143,6 @@ void enternotify(XEvent *e);
 void enternotify(XEvent *e);
 void eprint(const char *errstr, ...);
 void expose(XEvent *e);
-void floating(void); /* default floating layout */
 void focus(Client *c);
 void focusin(XEvent *e);
 void focusnext(const char *arg);
@@ -285,13 +285,17 @@ arrange(void) {
 	Client *c;
 
 	for(c = clients; c; c = c->next)
-		if(isvisible(c))
+		if(isvisible(c)) {
 			unban(c);
+			if(lt->isfloating || c->isfloating)
+resize(c, c->fx, c->fy, c->fw, c->fh, True);
+		}
 		else
 			ban(c);
 
 	focus(NULL);
-	lt->arrange();
+	if(lt->arrange)
+		lt->arrange();
 	restack();
 }
 
@@ -359,7 +363,7 @@ buttonpress(XEvent *e) {
 			movemouse(c);
 		}
 		else if(ev->button == Button2) {
-			if((floating != lt->arrange) && c->isfloating)
+			if(!lt->isfloating && c->isfloating)
 togglefloating(NULL);
 			else
 zoom(NULL);
@@ -668,15 +672,6 @@ expose(XEvent *e) {
 
 	if(ev->count == 0 && (ev->window == barwin))
 		drawbar();
-}
-
-void
-floating(void) { /* default floating layout */
-	Client *c;
-
-	for(c = clients; c; c = c->next)
-		if(isvisible(c))
-			resize(c, c->x, c->y, c->w, c->h, True);
 }
 
 void
@@ -996,8 +991,8 @@ manage(Window w, XWindowAttributes *wa) 
 	/* geometry */
 	c->x = wa->x;
 	c->y = wa->y;
-	c->w = wa->width;
-	c->h = wa->height;
+	c->w = c->fw = wa->width;
+	c->h = c->fh = wa->height;
 	c->oldbw = wa->border_width;
 	if(c->w == sw && c->h == sh) {
 		c->x = sx;
@@ -1015,6 +1010,8 @@ manage(Window w, XWindowAttributes *wa) 
 			c->y = wy;
 		c->bw = BORDERPX;
 	}
+	c->fx = c->x;
+	c->fy = c->y;
 
 	wc.border_width = c->bw;
 	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
@@ -1110,8 +1107,11 @@ movemouse(Client *c) {
 ny = wy + wh - c->h - 2 * c->bw;
 			if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP))
 togglefloating(NULL);
-			if((lt->isfloating) || c->isfloating)
+			if(lt->isfloating || c->isfloating) {
+c->fx = nx;
+c->fy = ny;
 resize(c, nx, ny, c->w, c->h, False);
+			}
 			break;
 		}
 	}
@@ -1271,10 +1271,16 @@ resizemouse(Client *c) {
 nw = 1;
 			if((nh = ev.xmotion.y - ocy - 2 * c->bw + 1) <= 0)
 nh = 1;
-			if(!c->isfloating && !lt->isfloating && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP))
+			if(!c->isfloating && !lt->isfloating && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) {
+c->fx = c->x;
+c->fy = c->y;
 togglefloating(NULL);
-			if((lt->isfloating) || c->isfloating)
+			}
+			if(lt->isfloating || c->isfloating) {
 resize(c, c->x, c->y, nw, nh, True);
+c->fw = nw;
+c->fh = nh;
+			}
 			break;
 		}
 	}
@@ -1294,16 +1300,11 @@ restack(void) {
 	if(!lt->isfloating) {
 		wc.stack_mode = Below;
 		wc.sibling = barwin;
-		if(!sel->isfloating) {
-			XConfigureWindow(dpy, sel->win, CWSibling|CWStackMode, &wc);
-			wc.sibling = sel->win;
-		}
-		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
-			if(c == sel)
-continue;
-			XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
-			wc.sibling = c->win;
-		}
+		for(c = stack; c; c = c->snext)
+			if(!c->isfloating && isvisible(c)) {
+XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
+wc.sibling = c->win;
+			}
 	}
 	XSync(dpy, False);
 	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
@@ -1856,6 +1857,8 @@ view(const char *arg) {
 		memcpy(selta

Re: [dwm] fgeom patch

2008-04-14 Thread yy
2008/4/14, yy <[EMAIL PROTECTED]>:
> 2008/4/14, Anselm R. Garbe <[EMAIL PROTECTED]>:
>
> > On Wed, Apr 09, 2008 at 07:41:53PM +0200, yy wrote:
>  >  > As discussed before, this is the patch with the floating geometry
>  >  > functionality. I removed some loc in restack, but I had to add more in
>  >  > other places to correctly manage mouse actions when in monocle layout
>  >
>  >
>  > I like the restack() simplification.
>  >
>
>
> I have noticed that it lets you to get rid of floating(), saving some
>  loc. Have a look at the attached patch.
>
>
>  >
>  >  > (isn't a bug the current possibility of moving and resizing windows
>  >  > while in monocle layout?).
>  >
>  >
>  > I'd like to keep mouse manipulations dependend on
>  >  lt->isfloating, instead of performing a hardcoded floating
>  >  layout check.
>  >
>
>
> Well, since I have completely removed the floating layout, it is done
>  in base on lt->isfloating in the new patch.
>
>
>  >
>  >  > Basically, the patch makes dwm to remember floating geometries when
>  >  > you change to tiled or monocle layout.
>  >  > I'm not sure about setting fx and fy on tileresize(), but note that if
>  >  > you don't do it you will need to add them in movemouse() and
>  >  > resizemouse() before togglefloating().
>  >
>  >
>  > Hmm I don't think that tileresize is the right place for setting
>  >  fx, and fy.  Instead fx/fy/fw/fh should be used depending on
>  >  lt->isfloating in resize and the layout itself, that's why I'd
>  >  consider doing the following in struct Client:
>  >
>  >  typdef struct {
>  >  ...
>  > int x[2], y[2], w[2], h[2];
>  >  ...
>  >  } Client;
>  >
>  >  #define BOOLTOIDX(x) (x) ? 1 : 0
>  >
>  >  And then in resize:
>  >
>  > c->x[BOOLTOIDX(lt->isfloating || c->isfloating)] = x;
>  > ...
>  >
>  >  etc.
>  >
>  >  Kind regards,
>  >
>
>
> I will think about it once you implement it in hg tip, this new
>  version of the patch doesn't touch the client floating geometry in
>  tileresize(), I think it works like expected, but I see the possible
>  simplification with the BOOLTOIDX method. And you would have the
>  possibility of having a #define REMEMBERFLOATS in config.h and then
>  BOOLTOIDX(REMEMBERFLOATS && (lt->isfloating || c->isfloating)), so
>  that this is configurable... (just rambling).
>
>  slds,
>
>
>  --
>

Sorry for the noise, but there were some little errors in the previous
patch. Now it only adds 2 loc (plus 2 from my previous patch, plus 3
layout examples in config.def.h, they should be commented).

-- 


- yiyus || JGL .
diff -r 595ed1a4447c config.def.h
--- a/config.def.h	Tue Apr 08 11:49:35 2008 +0100
+++ b/config.def.h	Mon Apr 14 20:14:32 2008 +0200
@@ -35,8 +35,11 @@ Layout layouts[] = {
 Layout layouts[] = {
 	/* symbol		function	isfloating */
 	{ "[]=",		tilev,		False }, /* first entry is default */
+	{ "<>=",		tilev,		True },
 	{ "[]|",		tileh,		False },
-	{ "><>",		floating,	True },
+	{ "<>|",		tileh,		True },
+	{ "><>",		NULL,	True },
+	{ "[m]",		monocle,	False },
 	{ "[M]",		monocle,	True },
 };
 
diff -r 595ed1a4447c dwm.c
--- a/dwm.c	Tue Apr 08 11:49:35 2008 +0100
+++ b/dwm.c	Mon Apr 14 20:14:32 2008 +0200
@@ -66,6 +66,7 @@ struct Client {
 struct Client {
 	char name[256];
 	int x, y, w, h;
+	int fx, fy, fw, fh;
 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
 	int minax, maxax, minay, maxay;
 	long flags;
@@ -285,13 +286,17 @@ arrange(void) {
 	Client *c;
 
 	for(c = clients; c; c = c->next)
-		if(isvisible(c))
+		if(isvisible(c)) {
 			unban(c);
+			if(lt->isfloating || c->isfloating)
+resize(c, c->fx, c->fy, c->fw, c->fh, True);
+		}
 		else
 			ban(c);
 
 	focus(NULL);
-	lt->arrange();
+	if(lt->arrange)
+		lt->arrange();
 	restack();
 }
 
@@ -359,7 +364,7 @@ buttonpress(XEvent *e) {
 			movemouse(c);
 		}
 		else if(ev->button == Button2) {
-			if((floating != lt->arrange) && c->isfloating)
+			if(!lt->isfloating && c->isfloating)
 togglefloating(NULL);
 			else
 zoom(NULL);
@@ -668,15 +673,6 @@ expose(XEvent *e) {
 
 	if(ev->count == 0 && (ev->window == barwin))
 		drawbar();
-}
-
-void
-floating(void) { /* default floating layout */
-	Client *c;
-
-	for(c = clients; c; c = c->next)
-		if(isvisible(c))
-			resize(c, c->x, c->y, c->w, c->h, True);
 }
 
 void
@@ -996,8 +992,8 @@ manage(Window w, XWindowAttributes *wa) 
 	/* geometry */
 	c->x = wa->x;
 	c->y = wa->y;
-	c->w = wa->width;
-	c->h = wa->height;
+	c->w = c->fw = wa->width;
+	c->h = c->fh = wa->height;
 	c->oldbw = wa->border_width;
 	if(c->w == sw && c->h == sh) {
 		c->x = sx;
@@ -1015,6 +1011,8 @@ manage(Window w, XWindowAttributes *wa) 
 			c->y = wy;
 		c->bw = BORDERPX;
 	}
+	c->fx = c->x;
+	c->fy = c->y;
 
 	wc.border_width = c->bw;
 	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
@@ -1068,7 +1066,7 @@ monocle(void) {
 	Client *c;
 
 	for(c = clients; c; c = c->next)
-		if((lt->isfloating || !c->isfloating) &&  isvisible(c))
+		if((lt->isfloating || !c->isfloating) &&  isvisible(c)) {
 			resize

Re: [dwm] fgeom patch

2008-04-14 Thread yy
2008/4/14, Anselm R. Garbe <[EMAIL PROTECTED]>:
> On Wed, Apr 09, 2008 at 07:41:53PM +0200, yy wrote:
>  > As discussed before, this is the patch with the floating geometry
>  > functionality. I removed some loc in restack, but I had to add more in
>  > other places to correctly manage mouse actions when in monocle layout
>
>
> I like the restack() simplification.
>

I have noticed that it lets you to get rid of floating(), saving some
loc. Have a look at the attached patch.

>
>  > (isn't a bug the current possibility of moving and resizing windows
>  > while in monocle layout?).
>
>
> I'd like to keep mouse manipulations dependend on
>  lt->isfloating, instead of performing a hardcoded floating
>  layout check.
>

Well, since I have completely removed the floating layout, it is done
in base on lt->isfloating in the new patch.

>
>  > Basically, the patch makes dwm to remember floating geometries when
>  > you change to tiled or monocle layout.
>  > I'm not sure about setting fx and fy on tileresize(), but note that if
>  > you don't do it you will need to add them in movemouse() and
>  > resizemouse() before togglefloating().
>
>
> Hmm I don't think that tileresize is the right place for setting
>  fx, and fy.  Instead fx/fy/fw/fh should be used depending on
>  lt->isfloating in resize and the layout itself, that's why I'd
>  consider doing the following in struct Client:
>
>  typdef struct {
>  ...
> int x[2], y[2], w[2], h[2];
>  ...
>  } Client;
>
>  #define BOOLTOIDX(x) (x) ? 1 : 0
>
>  And then in resize:
>
> c->x[BOOLTOIDX(lt->isfloating || c->isfloating)] = x;
> ...
>
>  etc.
>
>  Kind regards,
>

I will think about it once you implement it in hg tip, this new
version of the patch doesn't touch the client floating geometry in
tileresize(), I think it works like expected, but I see the possible
simplification with the BOOLTOIDX method. And you would have the
possibility of having a #define REMEMBERFLOATS in config.h and then
BOOLTOIDX(REMEMBERFLOATS && (lt->isfloating || c->isfloating)), so
that this is configurable... (just rambling).

slds,

-- 


- yiyus || JGL .
diff -r 595ed1a4447c config.def.h
--- a/config.def.h	Tue Apr 08 11:49:35 2008 +0100
+++ b/config.def.h	Mon Apr 14 18:27:12 2008 +0200
@@ -36,7 +36,7 @@ Layout layouts[] = {
 	/* symbol		function	isfloating */
 	{ "[]=",		tilev,		False }, /* first entry is default */
 	{ "[]|",		tileh,		False },
-	{ "><>",		floating,	True },
+	{ "><>",		NULL,	True },
 	{ "[M]",		monocle,	True },
 };
 
diff -r 595ed1a4447c dwm.c
--- a/dwm.c	Tue Apr 08 11:49:35 2008 +0100
+++ b/dwm.c	Mon Apr 14 18:27:12 2008 +0200
@@ -66,6 +66,7 @@ struct Client {
 struct Client {
 	char name[256];
 	int x, y, w, h;
+	int fx, fy, fw, fh;
 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
 	int minax, maxax, minay, maxay;
 	long flags;
@@ -285,13 +286,17 @@ arrange(void) {
 	Client *c;
 
 	for(c = clients; c; c = c->next)
-		if(isvisible(c))
+		if(isvisible(c)) {
 			unban(c);
+			if(lt->isfloating || !lt->isfloating && c->isfloating)
+resize(c, c->fx, c->fy, c->fw, c->fh, True);
+		}
 		else
 			ban(c);
 
 	focus(NULL);
-	lt->arrange();
+	if(lt->arrange)
+		lt->arrange();
 	restack();
 }
 
@@ -359,7 +364,7 @@ buttonpress(XEvent *e) {
 			movemouse(c);
 		}
 		else if(ev->button == Button2) {
-			if((floating != lt->arrange) && c->isfloating)
+			if(!lt->isfloating && c->isfloating)
 togglefloating(NULL);
 			else
 zoom(NULL);
@@ -668,15 +673,6 @@ expose(XEvent *e) {
 
 	if(ev->count == 0 && (ev->window == barwin))
 		drawbar();
-}
-
-void
-floating(void) { /* default floating layout */
-	Client *c;
-
-	for(c = clients; c; c = c->next)
-		if(isvisible(c))
-			resize(c, c->x, c->y, c->w, c->h, True);
 }
 
 void
@@ -996,8 +992,8 @@ manage(Window w, XWindowAttributes *wa) 
 	/* geometry */
 	c->x = wa->x;
 	c->y = wa->y;
-	c->w = wa->width;
-	c->h = wa->height;
+	c->w = c->fw = wa->width;
+	c->h = c->fh = wa->height;
 	c->oldbw = wa->border_width;
 	if(c->w == sw && c->h == sh) {
 		c->x = sx;
@@ -1015,6 +1011,8 @@ manage(Window w, XWindowAttributes *wa) 
 			c->y = wy;
 		c->bw = BORDERPX;
 	}
+	c->fx = c->x;
+	c->fy = c->y;
 
 	wc.border_width = c->bw;
 	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
@@ -1068,8 +1066,12 @@ monocle(void) {
 	Client *c;
 
 	for(c = clients; c; c = c->next)
-		if((lt->isfloating || !c->isfloating) &&  isvisible(c))
-			resize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw, RESIZEHINTS);
+		if(isvisible(c)) {
+			if(lt->isfloating)
+resize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw, RESIZEHINTS);
+			else if(!c->isfloating)
+tileresize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw);
+		}
 }
 
 void
@@ -1110,8 +1112,11 @@ movemouse(Client *c) {
 ny = wy + wh - c->h - 2 * c->bw;
 			if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP))
 togglefloating(NULL);
-			if((lt->isfloating) || c->isfloating)
+			if(lt->isfloating || (!lt->isfloating && c->isfloati

Re: [dwm] fgeom patch

2008-04-14 Thread Anselm R. Garbe
On Wed, Apr 09, 2008 at 07:41:53PM +0200, yy wrote:
> As discussed before, this is the patch with the floating geometry
> functionality. I removed some loc in restack, but I had to add more in
> other places to correctly manage mouse actions when in monocle layout

I like the restack() simplification.

> (isn't a bug the current possibility of moving and resizing windows
> while in monocle layout?).

I'd like to keep mouse manipulations dependend on
lt->isfloating, instead of performing a hardcoded floating
layout check.

> Basically, the patch makes dwm to remember floating geometries when
> you change to tiled or monocle layout.
> I'm not sure about setting fx and fy on tileresize(), but note that if
> you don't do it you will need to add them in movemouse() and
> resizemouse() before togglefloating().

Hmm I don't think that tileresize is the right place for setting
fx, and fy.  Instead fx/fy/fw/fh should be used depending on
lt->isfloating in resize and the layout itself, that's why I'd
consider doing the following in struct Client:

typdef struct {
...
int x[2], y[2], w[2], h[2];
...
} Client;

#define BOOLTOIDX(x) (x) ? 1 : 0

And then in resize:

c->x[BOOLTOIDX(lt->isfloating || c->isfloating)] = x;
...

etc.

Kind regards,
-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361



[dwm] fgeom patch

2008-04-09 Thread yy
As discussed before, this is the patch with the floating geometry
functionality. I removed some loc in restack, but I had to add more in
other places to correctly manage mouse actions when in monocle layout
(isn't a bug the current possibility of moving and resizing windows
while in monocle layout?).
Basically, the patch makes dwm to remember floating geometries when
you change to tiled or monocle layout.
I'm not sure about setting fx and fy on tileresize(), but note that if
you don't do it you will need to add them in movemouse() and
resizemouse() before togglefloating().
I don't really like the idea of remembering floating geometries (at
least floating positions), as I don't like the idea of resizing
floating clients in the tile layout (as in monocle) but this is how I
would implement it.

I'd like to hear what do you think, greetings,

-- 


- yiyus || JGL .

PS: The patch adds 15 lines to dwm.c, but 2 of them comes from my
previous patch to viewprevtag() when you try to view the only selected
tag(s).
diff -r 595ed1a4447c dwm.c
--- a/dwm.c	Tue Apr 08 11:49:35 2008 +0100
+++ b/dwm.c	Wed Apr 09 19:18:24 2008 +0200
@@ -66,6 +66,7 @@ struct Client {
 struct Client {
 	char name[256];
 	int x, y, w, h;
+	int fx, fy, fw, fh;
 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
 	int minax, maxax, minay, maxay;
 	long flags;
@@ -285,8 +286,11 @@ arrange(void) {
 	Client *c;
 
 	for(c = clients; c; c = c->next)
-		if(isvisible(c))
+		if(isvisible(c)) {
 			unban(c);
+			if(!lt->isfloating && c->isfloating)
+resize(c, c->fx, c->fy, c->fw, c->fh, True);
+		}
 		else
 			ban(c);
 
@@ -676,7 +680,7 @@ floating(void) { /* default floating lay
 
 	for(c = clients; c; c = c->next)
 		if(isvisible(c))
-			resize(c, c->x, c->y, c->w, c->h, True);
+			resize(c, c->fx, c->fy, c->fw, c->fh, True);
 }
 
 void
@@ -996,8 +1000,8 @@ manage(Window w, XWindowAttributes *wa) 
 	/* geometry */
 	c->x = wa->x;
 	c->y = wa->y;
-	c->w = wa->width;
-	c->h = wa->height;
+	c->w = c->fw = wa->width;
+	c->h = c->fh = wa->height;
 	c->oldbw = wa->border_width;
 	if(c->w == sw && c->h == sh) {
 		c->x = sx;
@@ -1015,6 +1019,8 @@ manage(Window w, XWindowAttributes *wa) 
 			c->y = wy;
 		c->bw = BORDERPX;
 	}
+	c->fx = c->x;
+	c->fy = c->y;
 
 	wc.border_width = c->bw;
 	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
@@ -1068,8 +1074,12 @@ monocle(void) {
 	Client *c;
 
 	for(c = clients; c; c = c->next)
-		if((lt->isfloating || !c->isfloating) &&  isvisible(c))
-			resize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw, RESIZEHINTS);
+		if(isvisible(c)) {
+			if(lt->isfloating)
+resize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw, RESIZEHINTS);
+			else if(!c->isfloating)
+tileresize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw);
+		}
 }
 
 void
@@ -1110,8 +1120,11 @@ movemouse(Client *c) {
 ny = wy + wh - c->h - 2 * c->bw;
 			if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP))
 togglefloating(NULL);
-			if((lt->isfloating) || c->isfloating)
+			if((lt->arrange == floating) || (!lt->isfloating && c->isfloating)) {
 resize(c, nx, ny, c->w, c->h, False);
+c->fx = nx;
+c->fy = ny;
+			}
 			break;
 		}
 	}
@@ -1273,8 +1286,11 @@ resizemouse(Client *c) {
 nh = 1;
 			if(!c->isfloating && !lt->isfloating && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP))
 togglefloating(NULL);
-			if((lt->isfloating) || c->isfloating)
+			if((lt->arrange == floating) || (!lt->isfloating && c->isfloating)) {
 resize(c, c->x, c->y, nw, nh, True);
+c->fw = nw;
+c->fh = nh;
+			}
 			break;
 		}
 	}
@@ -1294,16 +1310,11 @@ restack(void) {
 	if(!lt->isfloating) {
 		wc.stack_mode = Below;
 		wc.sibling = barwin;
-		if(!sel->isfloating) {
-			XConfigureWindow(dpy, sel->win, CWSibling|CWStackMode, &wc);
-			wc.sibling = sel->win;
-		}
-		for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
-			if(c == sel)
-continue;
-			XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
-			wc.sibling = c->win;
-		}
+		for(c = stack; c; c = c->snext)
+			if(!c->isfloating && isvisible(c)) {
+XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
+wc.sibling = c->win;
+			}
 	}
 	XSync(dpy, False);
 	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
@@ -1657,6 +1668,8 @@ tileresize(Client *c, int x, int y, int 
 	if((RESIZEHINTS) && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
 		/* client doesn't accept size constraints */
 		resize(c, x, y, w, h, False);
+	c->fx = x;
+	c->fy = y;
 }
 
 void
@@ -1856,6 +1869,8 @@ view(const char *arg) {
 		memcpy(seltags, tmp, TAGSZ);
 		arrange();
 	}
+	else
+		viewprevtag(NULL);
 }
 
 void