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