I've updated the patch to work with the latest version of dwm (4.4.1).
There was also a problem with explicitly floating windows, which is
now fixed.
Enjoy.
- Abel
diff --git a/client.c b/client.c
index cd16e11..c0d55ca 100644
--- a/client.c
+++ b/client.c
@@ -185,11 +185,12 @@ manage(Window w, XWindowAttributes *wa) {
c = emallocz(sizeof(Client));
c->tags = emallocz(ntags * sizeof(Bool));
+ c->ftview = True;
c->win = w;
- c->x = wa->x;
- c->y = wa->y;
- c->w = wa->width;
- c->h = wa->height;
+ c->x = c->rx = wa->x;
+ c->y = c->ry = wa->y;
+ c->w = c->rw = wa->width;
+ c->h = c->rh = wa->height;
c->oldborder = wa->border_width;
if(c->w == sw && c->h == sh) {
c->x = sx;
@@ -198,13 +199,13 @@ manage(Window w, XWindowAttributes *wa) {
}
else {
if(c->x + c->w + 2 * c->border > wax + waw)
- c->x = wax + waw - c->w - 2 * c->border;
+ c->x = c->rx = wax + waw - c->w - 2 * c->border;
if(c->y + c->h + 2 * c->border > way + wah)
- c->y = way + wah - c->h - 2 * c->border;
+ c->y = c->ry = way + wah - c->h - 2 * c->border;
if(c->x < wax)
- c->x = wax;
+ c->x = c->rx = wax;
if(c->y < way)
- c->y = way;
+ c->y = c->ry = way;
c->border = BORDERPX;
}
wc.border_width = c->border;
diff --git a/dwm.h b/dwm.h
index 1a12322..7d2540d 100644
--- a/dwm.h
+++ b/dwm.h
@@ -56,6 +56,7 @@ struct Client {
Client *prev;
Client *snext;
Window win;
+ Bool ftview; /* first time viewed on new layout */
};
typedef struct {
diff --git a/screen.c b/screen.c
index 255184a..90afd6e 100644
--- a/screen.c
+++ b/screen.c
@@ -47,8 +47,14 @@ 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);
+ if(isvisible(c)) {
+ if (c->ftview && !c->isfloating) {
+ resize(c, c->rx, c->ry, c->rw, c->rh, True);
+ c->ftview = False;
+ }
+ else
+ resize(c, c->x, c->y, c->w, c->h, True);
+ }
}
LAYOUTS
@@ -239,6 +245,7 @@ restack(void) {
void
setlayout(const char *arg) {
unsigned int i;
+ Client *c;
if(!arg) {
if(++ltidx == nlayouts)
@@ -252,6 +259,8 @@ setlayout(const char *arg) {
return;
ltidx = i;
}
+ for(c = clients; c; c = c->next)
+ c->ftview = True;
if(sel)
arrange();
else
@@ -288,7 +297,14 @@ togglefloating(const char *arg) {
return;
sel->isfloating = !sel->isfloating;
if(sel->isfloating)
- resize(sel, sel->x, sel->y, sel->w, sel->h, True);
+ resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
+ else {
+ sel->rx = sel->x;
+ sel->ry = sel->y;
+ sel->rw = sel->w;
+ sel->rh = sel->h;
+ }
+
arrange();
}
diff --git a/tile.c b/tile.c
index 7915441..88ccf31 100644
--- a/tile.c
+++ b/tile.c
@@ -63,6 +63,13 @@ tile(void) {
else
nh = th - 2 * c->border;
}
+ if (c->ftview) {
+ c->rx = c->x;
+ c->ry = c->y;
+ c->rw = c->w;
+ c->rh = c->h;
+ c->ftview = False;
+ }
resize(c, nx, ny, nw, nh, False);
if(n > 1 && th != wah)
ny += nh + 2 * c->border;