bakkeby / dwm-flexipatch

A dwm build with preprocessor directives to decide which patches to include during build time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SAVEFLOATS_PATCH doesn't work

LaptopDev opened this issue · comments

The floating position is "saved", but is forgotten if you enter tile mode.
It will warp to that position only after the unresponsive floating window has been closed and then is re-opened in floating layout.
It should automatically warp to its last position in floating layout when entering floating layout, and warp to tiling layout when entering tiling layout.

That is not the functionality of the save_floats patch for dwm though.

The description only refers to a tiled layout where the user toggles the floating state of a window.

The reason why this does not happen when moving between tiled and floating layout has to do with that there is no arrangement for a floating layout - windows are left where they are.

Dang, ok

would like that feature though

I think that it should be fairly straightforward to add.

Example patch for the original save floats patch:

diff --git a/dwm.c b/dwm.c
index c8c02a2..32278f7 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1639,8 +1639,13 @@ showhide(Client *c)
        if (ISVISIBLE(c)) {
                /* show clients top down */
                XMoveWindow(dpy, c->win, c->x, c->y);
-               if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
-                       resize(c, c->x, c->y, c->w, c->h, 0);
+               if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) {
+                       if (c->sfw) {
+                               resize(c, c->sfx, c->sfy, c->sfw, c->sfh, 0);
+                       } else {
+                               resize(c, c->x, c->y, c->w, c->h, 0);
+                       }
+               }
                showhide(c->snext);
        } else {
                /* hide clients bottom up */

The original save floats patch also only saves float position when togglefloating is used. Would need this to happen when switching from floating to other layout as well.

One would probably end up with something like this as well then.

diff --git a/dwm.c b/dwm.c
index c8c02a2..aa4195f 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1515,6 +1515,18 @@ setfullscreen(Client *c, int fullscreen)
 void
 setlayout(const Arg *arg)
 {
+       Client *c;
+       if (!selmon->lt[selmon->sellt]->arrange) {
+               for (c = selmon->stack; c; c = c->snext) {
+                       if (ISVISIBLE(c)) {
+                               /* save last known float dimensions */
+                               c->sfx = c->x;
+                               c->sfy = c->y;
+                               c->sfw = c->w;
+                               c->sfh = c->h;
+                       }
+               }
+       }
        if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
                selmon->sellt ^= 1;
        if (arg && arg->v)

The saving of float coordinates could be moved to a standalone function to avoid duplication.