From d567a56b4d41d8609487b31d526be06de3c8c780 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Fri, 23 Aug 2024 21:10:27 -0400 Subject: [PATCH] dwm: Add save floats patch Now it's possible to float and unfloat windows and those windows will preserve their floating window size. Note that this patch was merged with the alwayscenter patch so the diff applies cleanly. --- assets/dwm-savefloats-alwayscenter.patch | 44 ++++++++++++++++++++++++ specializations/dwm.nix | 6 +--- 2 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 assets/dwm-savefloats-alwayscenter.patch diff --git a/assets/dwm-savefloats-alwayscenter.patch b/assets/dwm-savefloats-alwayscenter.patch new file mode 100644 index 00000000..9420d266 --- /dev/null +++ b/assets/dwm-savefloats-alwayscenter.patch @@ -0,0 +1,44 @@ +diff --git a/dwm.c b/dwm.c +index 67c6b2b..ed46374 100644 +--- a/dwm.c ++++ b/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, hintsvalid; + int bw, oldbw; +@@ -1068,6 +1069,12 @@ manage(Window w, XWindowAttributes *wa) + updatewindowtype(c); + updatesizehints(c); + updatewmhints(c); ++ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2; ++ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2; ++ 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) +@@ -1730,8 +1737,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); + } + diff --git a/specializations/dwm.nix b/specializations/dwm.nix index cb1bc8ab..560694b7 100644 --- a/specializations/dwm.nix +++ b/specializations/dwm.nix @@ -256,17 +256,13 @@ in ../assets/dwm-adjacenttag.patch ../assets/dwm-remove-layout-indicator.patch ../assets/dwm-remove-floating-indicator.patch + ../assets/dwm-savefloats-alwayscenter.patch (pkgs.fetchpatch { url = "https://dwm.suckless.org/patches/hide_vacant_tags/dwm-hide_vacant_tags-6.4.diff"; hash = "sha256-GIbRW0Inwbp99rsKLfIDGvPwZ3pqihROMBp5vFlHx5Q="; }) - (pkgs.fetchpatch { - url = "https://dwm.suckless.org/patches/alwayscenter/dwm-alwayscenter-20200625-f04cac6.diff"; - hash = "sha256-xQEwrNphaLOkhX3ER09sRPB3EEvxC73oNWMVkqo4iSY="; - }) - (pkgs.fetchpatch { url = "https://dwm.suckless.org/patches/alpha/dwm-alpha-20230401-348f655.diff"; hash = "sha256-ZhuqyDpY+nQQgrjniQ9DNheUgE9o/MUXKaJYRU3Uyl4=";