Created
October 30, 2024 12:03
-
-
Save Dovias/a406b59ae51021dfd12fd098a2e5dd30 to your computer and use it in GitHub Desktop.
Unofficial dwm 6.5 patch for dwm's smfact patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- config.def.h | |
+++ config.def.h | |
@@ -4,4 +4,5 @@ /* appearance */ | |
static const unsigned int borderpx = 1; /* border pixel of windows */ | |
static const unsigned int snap = 32; /* snap pixel */ | |
+static const unsigned int minwsz = 20; /* Minimal height of a client for smfact */ | |
static const int showbar = 1; /* 0 means no bar */ | |
static const int topbar = 1; /* 0 means bottom bar */ | |
@@ -35,3 +35,4 @@ /* layout(s) */ | |
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ | |
+static const float smfact = 0.00; /* factor of tiled clients [0.00..0.95] */ | |
static const int nmaster = 1; /* number of clients in master area */ | |
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ | |
@@ -71,6 +71,8 @@ static Key keys[] = { | |
{ MODKEY, XK_d, incnmaster, {.i = -1 } }, | |
{ MODKEY, XK_h, setmfact, {.f = -0.05} }, | |
{ MODKEY, XK_l, setmfact, {.f = +0.05} }, | |
+ { MODKEY|ShiftMask, XK_h, setsmfact, {.f = +0.05} }, | |
+ { MODKEY|ShiftMask, XK_l, setsmfact, {.f = -0.05} }, | |
{ MODKEY, XK_Return, zoom, {0} }, | |
{ MODKEY, XK_Tab, view, {0} }, | |
{ MODKEY|ShiftMask, XK_c, killclient, {0} }, | |
--- dwm.c | |
+++ dwm.c | |
@@ -71,6 +71,7 @@ typedef union { | |
int i; | |
unsigned int ui; | |
float f; | |
+ float sf; | |
const void *v; | |
} Arg; | |
@@ -114,6 +114,7 @@ typedef struct { | |
struct Monitor { | |
char ltsymbol[16]; | |
float mfact; | |
+ float smfact; | |
int nmaster; | |
int num; | |
int by; /* bar geometry */ | |
@@ -202,6 +202,7 @@ static void setfocus(Client *c); | |
static void setfullscreen(Client *c, int fullscreen); | |
static void setlayout(const Arg *arg); | |
static void setmfact(const Arg *arg); | |
+static void setsmfact(const Arg *arg); | |
static void setup(void); | |
static void seturgent(Client *c, int urg); | |
static void showhide(Client *c); | |
@@ -638,6 +638,7 @@ createmon(void) | |
m = ecalloc(1, sizeof(Monitor)); | |
m->tagset[0] = m->tagset[1] = 1; | |
m->mfact = mfact; | |
+ m->smfact = smfact; | |
m->nmaster = nmaster; | |
m->showbar = showbar; | |
m->topbar = topbar; | |
@@ -1536,6 +1536,19 @@ setmfact(const Arg *arg) | |
arrange(selmon); | |
} | |
+void | |
+setsmfact(const Arg *arg) { | |
+ float sf; | |
+ | |
+ if(!arg || !selmon->lt[selmon->sellt]->arrange) | |
+ return; | |
+ sf = arg->sf < 1.0 ? arg->sf + selmon->smfact : arg->sf - 1.0; | |
+ if(sf < 0 || sf > 0.9) | |
+ return; | |
+ selmon->smfact = sf; | |
+ arrange(selmon); | |
+} | |
+ | |
void | |
setup(void) | |
{ | |
@@ -1687,7 +1687,7 @@ tagmon(const Arg *arg) | |
void | |
tile(Monitor *m) | |
{ | |
- unsigned int i, n, h, mw, my, ty; | |
+ unsigned int i, n, h, smh, mw, my, ty; | |
Client *c; | |
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); | |
@@ -1705,9 +1705,22 @@ tile(Monitor *m) | |
if (my + HEIGHT(c) < m->wh) | |
my += HEIGHT(c); | |
} else { | |
- h = (m->wh - ty) / (n - i); | |
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); | |
- if (ty + HEIGHT(c) < m->wh) | |
+ smh = m->mh * m->smfact; | |
+ if(!(nexttiled(c->next))) | |
+ h = (m->wh - ty) / (n - i); | |
+ else | |
+ h = (m->wh - smh - ty) / (n - i); | |
+ if(h < minwsz) { | |
+ c->isfloating = True; | |
+ XRaiseWindow(dpy, c->win); | |
+ resize(c, m->mx + (m->mw / 2 - WIDTH(c) / 2), m->my + (m->mh / 2 - HEIGHT(c) / 2), m->ww - mw - (2*c->bw), h - (2*c->bw), False); | |
+ ty -= HEIGHT(c); | |
+ } | |
+ else | |
+ resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False); | |
+ if(!(nexttiled(c->next))) | |
+ ty += HEIGHT(c) + smh; | |
+ else | |
ty += HEIGHT(c); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment