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(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw, RESIZEHINTS);
 }
 
@@ -1110,8 +1108,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 +1272,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 +1301,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 +1858,8 @@ view(const char *arg) {
 		memcpy(seltags, tmp, TAGSZ);
 		arrange();
 	}
+	else
+		viewprevtag(NULL);
 }
 
 void

Reply via email to