save floats patch

This commit is contained in:
Jakub 2024-05-10 22:51:27 -04:00
parent cb64871955
commit a38e1a252f
2 changed files with 57 additions and 2 deletions

17
dwm.c
View File

@ -90,6 +90,7 @@ struct Client {
char name[256]; char name[256];
float mina, maxa; float mina, maxa;
int x, y, w, h; int x, y, w, h;
int sfx, sfy, sfw, sfh; /* stored float geometry, used on mode revert */
int oldx, oldy, oldw, oldh; int oldx, oldy, oldw, oldh;
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
int bw, oldbw; int bw, oldbw;
@ -1142,6 +1143,10 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c); updatewindowtype(c);
updatesizehints(c); updatesizehints(c);
updatewmhints(c); updatewmhints(c);
c->sfx = c->x;
c->sfy = c->y;
c->sfw = c->w;
c->sfh = c->h;
{ {
int format; int format;
unsigned long *data, n, extra; unsigned long *data, n, extra;
@ -1901,8 +1906,16 @@ togglefloating(const Arg *arg)
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)
resize(selmon->sel, selmon->sel->x, selmon->sel->y, /* restore last known float dimensions */
selmon->sel->w, selmon->sel->h, 0); resize(selmon->sel, selmon->sel->sfx, selmon->sel->sfy,
selmon->sel->sfw, selmon->sel->sfh, False);
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;
}
selmon->sel->x = selmon->sel->mon->mx + (selmon->sel->mon->mw - WIDTH(selmon->sel)) / 2; selmon->sel->x = selmon->sel->mon->mx + (selmon->sel->mon->mw - WIDTH(selmon->sel)) / 2;
selmon->sel->y = selmon->sel->mon->my + (selmon->sel->mon->mh - HEIGHT(selmon->sel)) / 2; selmon->sel->y = selmon->sel->mon->my + (selmon->sel->mon->mh - HEIGHT(selmon->sel)) / 2;

View File

@ -0,0 +1,42 @@
diff --git i/dwm.c w/dwm.c
index 4465af1..96b0b26 100644
--- i/dwm.c
+++ w/dwm.c
@@ -88,6 +88,7 @@ struct Client {
char name[256];
float mina, maxa;
int x, y, w, h;
+ int sfx, sfy, sfw, sfh; /* stored float geometry, used on mode revert */
int oldx, oldy, oldw, oldh;
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
@@ -1056,6 +1057,10 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c);
updatesizehints(c);
updatewmhints(c);
+ c->sfx = c->x;
+ c->sfy = c->y;
+ c->sfw = c->w;
+ c->sfh = c->h;
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
grabbuttons(c, 0);
if (!c->isfloating)
@@ -1714,8 +1719,16 @@ togglefloating(const Arg *arg)
return;
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
if (selmon->sel->isfloating)
- resize(selmon->sel, selmon->sel->x, selmon->sel->y,
- selmon->sel->w, selmon->sel->h, 0);
+ /* restore last known float dimensions */
+ resize(selmon->sel, selmon->sel->sfx, selmon->sel->sfy,
+ selmon->sel->sfw, selmon->sel->sfh, False);
+ 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;
+ }
arrange(selmon);
}