Adding savefloats patch

This commit is contained in:
bakkeby 2019-09-07 23:08:53 +02:00
parent 7c23a59c38
commit ffe8da4273
3 changed files with 71 additions and 3 deletions

View File

@ -11,7 +11,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog: ### 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 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/) - [rotatestack](https://dwm.suckless.org/patches/rotatestack/)
- let's you rotate through the stack using keyboard shortcuts - 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/) - [systray](https://dwm.suckless.org/patches/systray/)
- adds system tray in the status bar - adds system tray in the status bar

61
dwm.c
View File

@ -100,6 +100,9 @@ struct Client {
char name[256]; char name[256];
float mina, maxa; float mina, maxa;
int x, y, w, h; 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 oldx, oldy, oldw, oldh;
int basew, baseh, incw, inch, maxw, maxh, minw, minh; int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw; int bw, oldbw;
@ -1312,6 +1315,13 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c); updatewindowtype(c);
updatesizehints(c); updatesizehints(c);
updatewmhints(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); XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
grabbuttons(c, 0); grabbuttons(c, 0);
if (!c->isfloating) if (!c->isfloating)
@ -1447,8 +1457,16 @@ movemouse(const Arg *arg)
if (!c->isfloating && selmon->lt[selmon->sellt]->arrange if (!c->isfloating && selmon->lt[selmon->sellt]->arrange
&& (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
togglefloating(NULL); 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); 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; break;
} }
} while (ev.type != ButtonRelease); } while (ev.type != ButtonRelease);
@ -1641,8 +1659,21 @@ resizemouse(const Arg *arg)
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) { if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) {
#if RESIZECORNERS_PATCH #if RESIZECORNERS_PATCH
resize(c, nx, ny, nw, nh, 1); 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 #else
resize(c, c->x, c->y, nw, nh, 1); 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 #endif // RESIZECORNERS_PATCH
} }
break; break;
@ -2020,6 +2051,14 @@ showhide(Client *c)
return; return;
if (ISVISIBLE(c)) { if (ISVISIBLE(c)) {
/* show clients top down */ /* 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); XMoveWindow(dpy, c->win, c->x, c->y);
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
resize(c, c->x, c->y, c->w, c->h, 0); 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 */ if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
return; return;
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; 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, resize(selmon->sel, selmon->sel->x, selmon->sel->y,
selmon->sel->w, selmon->sel->h, 0); 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); arrange(selmon);
} }

View File

@ -92,6 +92,13 @@
*/ */
#define ROTATESTACK_PATCH 0 #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. /* The systray patch adds systray for the status bar.
* https://dwm.suckless.org/patches/systray/ * https://dwm.suckless.org/patches/systray/
*/ */