summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2019-09-07 23:08:53 +0200
committerbakkeby <[email protected]>2019-09-07 23:08:53 +0200
commitffe8da4273b3cb5c96397f7b2718fb78cb5271bb (patch)
treec52d75b61207f23547a31e9a32c8e5b2374aa4c3
parent7c23a59c38d01a0fae1edf360b4553fe3a0d9e23 (diff)
downloaddwm-flexipatch-ffe8da4273b3cb5c96397f7b2718fb78cb5271bb.tar.gz
dwm-flexipatch-ffe8da4273b3cb5c96397f7b2718fb78cb5271bb.zip
Adding savefloats patch
-rw-r--r--README.md6
-rw-r--r--dwm.c61
-rw-r--r--patches.h7
3 files changed, 71 insertions, 3 deletions
diff --git a/README.md b/README.md
index 4bbdeea..ec48c86 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
-2019-09-07 - Added cyclelayouts, resizecorners and rotatestack patch
+2019-09-07 - Added cyclelayouts, resizecorners, rotatestack and savefloats patches
2019-09-06 - Added attachabove, attachaside, attachbelow, attachbottom, autostart, fancybar, focusonnetactive and losefullscreen patches
@@ -62,6 +62,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [rotatestack](https://dwm.suckless.org/patches/rotatestack/)
- let's you rotate through the stack using keyboard shortcuts
+ - [savefloats](https://dwm.suckless.org/patches/save_floats/)
+ - saves size and position of every floating window before it is forced into tiled mode
+ - if the window is made floating again then the old dimensions will be restored
+
- [systray](https://dwm.suckless.org/patches/systray/)
- adds system tray in the status bar
diff --git a/dwm.c b/dwm.c
index a3978e3..66bcab9 100644
--- a/dwm.c
+++ b/dwm.c
@@ -100,6 +100,9 @@ struct Client {
char name[256];
float mina, maxa;
int x, y, w, h;
+ #if SAVEFLOATS_PATCH
+ int sfx, sfy, sfw, sfh; /* stored float geometry, used on mode revert */
+ #endif // SAVEFLOATS_PATCH
int oldx, oldy, oldw, oldh;
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
@@ -1312,6 +1315,13 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c);
updatesizehints(c);
updatewmhints(c);
+ #if SAVEFLOATS_PATCH
+ c->sfx = -9999;
+ c->sfy = -9999;
+ c->sfw = c->w;
+ c->sfh = c->h;
+ #endif // SAVEFLOATS_PATCH
+
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
grabbuttons(c, 0);
if (!c->isfloating)
@@ -1447,8 +1457,16 @@ movemouse(const Arg *arg)
if (!c->isfloating && selmon->lt[selmon->sellt]->arrange
&& (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
togglefloating(NULL);
- if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+ if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) {
+ #if SAVEFLOATS_PATCH
+ resize(c, nx, ny, c->w, c->h, 1);
+ /* save last known float coordinates */
+ c->sfx = nx;
+ c->sfy = ny;
+ #else
resize(c, nx, ny, c->w, c->h, 1);
+ #endif // SAVEFLOATS_PATCH
+ }
break;
}
} while (ev.type != ButtonRelease);
@@ -1641,8 +1659,21 @@ resizemouse(const Arg *arg)
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) {
#if RESIZECORNERS_PATCH
resize(c, nx, ny, nw, nh, 1);
+ #if SAVEFLOATS_PATCH
+ /* save last known float dimensions */
+ c->sfx = nx;
+ c->sfy = ny;
+ c->sfw = nw;
+ c->sfh = nh;
+ #endif // SAVEFLOATS_PATCH
#else
resize(c, c->x, c->y, nw, nh, 1);
+ #if SAVEFLOATS_PATCH
+ c->sfx = c->x;
+ c->sfy = c->y;
+ c->sfw = nw;
+ c->sfh = nh;
+ #endif // SAVEFLOATS_PATCH
#endif // RESIZECORNERS_PATCH
}
break;
@@ -2020,6 +2051,14 @@ showhide(Client *c)
return;
if (ISVISIBLE(c)) {
/* show clients top down */
+ #if SAVEFLOATS_PATCH
+ if (!c->mon->lt[c->mon->sellt]->arrange && c->sfx != -9999 && !c->isfullscreen) {
+ XMoveWindow(dpy, c->win, c->sfx, c->sfy);
+ resize(c, c->sfx, c->sfy, c->sfw, c->sfh, 0);
+ showhide(c->snext);
+ return;
+ }
+ #endif // SAVEFLOATS_PATCH
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);
@@ -2144,9 +2183,27 @@ togglefloating(const Arg *arg)
if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
return;
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
- if (selmon->sel->isfloating)
+ if (selmon->sel->isfloating) {
+ #if SAVEFLOATS_PATCH
+ if (selmon->sel->sfx != -9999) {
+ /* restore last known float dimensions */
+ resize(selmon->sel, selmon->sel->sfx, selmon->sel->sfy,
+ selmon->sel->sfw, selmon->sel->sfh, 0);
+ arrange(selmon);
+ return;
+ }
+ #endif // SAVEFLOATS_PATCH
resize(selmon->sel, selmon->sel->x, selmon->sel->y,
selmon->sel->w, selmon->sel->h, 0);
+ #if SAVEFLOATS_PATCH
+ } else {
+ /* save last known float dimensions */
+ selmon->sel->sfx = selmon->sel->x;
+ selmon->sel->sfy = selmon->sel->y;
+ selmon->sel->sfw = selmon->sel->w;
+ selmon->sel->sfh = selmon->sel->h;
+ #endif // SAVEFLOATS_PATCH
+ }
arrange(selmon);
}
diff --git a/patches.h b/patches.h
index ece7226..e2b25e7 100644
--- a/patches.h
+++ b/patches.h
@@ -92,6 +92,13 @@
*/
#define ROTATESTACK_PATCH 0
+/* This patch aves size and position of every floating window before it is forced
+ * into tiled mode. If the window is made floating again then the old dimensions
+ * will be restored.
+ * https://dwm.suckless.org/patches/save_floats/
+ */
+#define SAVEFLOATS_PATCH 1
+
/* The systray patch adds systray for the status bar.
* https://dwm.suckless.org/patches/systray/
*/