aboutsummaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2025-04-22 16:42:19 +0200
committerJoe <rbo@gmx.us>2025-04-22 16:42:19 +0200
commit58a39f924cc8eaf32f0e24c0f5fcdfd24522a6e6 (patch)
tree9eb9c74795b8313c3cfac90b6f09170be9e071fc /dwm.c
parentnogapx (diff)
downloaddwm-58a39f924cc8eaf32f0e24c0f5fcdfd24522a6e6.tar.gz
dwm-58a39f924cc8eaf32f0e24c0f5fcdfd24522a6e6.tar.bz2
dwm-58a39f924cc8eaf32f0e24c0f5fcdfd24522a6e6.tar.xz
dwm-58a39f924cc8eaf32f0e24c0f5fcdfd24522a6e6.tar.zst
dwm-58a39f924cc8eaf32f0e24c0f5fcdfd24522a6e6.zip
up
Diffstat (limited to '')
-rw-r--r--dwm.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/dwm.c b/dwm.c
index 475e2a0..65bbd20 100644
--- a/dwm.c
+++ b/dwm.c
@@ -113,6 +113,7 @@ typedef struct Client Client;
struct Client {
char name[256];
float mina, maxa;
+ float cfact;
int x, y, w, h;
int sfx, sfy, sfw, sfh; /* stored float geometry, used on mode revert */
int oldx, oldy, oldw, oldh;
@@ -260,6 +261,7 @@ static void setfocus(Client *c);
static void setfullscreen(Client *c, int fullscreen);
static void setgaps(const Arg *arg);
static void setlayout(const Arg *arg);
+static void setcfact(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
static void seturgent(Client *c, int urg);
@@ -1611,6 +1613,7 @@ manage(Window w, XWindowAttributes *wa)
c->w = c->oldw = wa->width;
c->h = c->oldh = wa->height;
c->oldbw = wa->border_width;
+ c->cfact = 1.0;
updatetitle(c);
if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
@@ -2525,6 +2528,23 @@ setlayout(const Arg *arg)
drawbar(selmon);
}
+void setcfact(const Arg *arg) {
+ float f;
+ Client *c;
+
+ c = selmon->sel;
+
+ if(!arg || !c || !selmon->lt[selmon->sellt]->arrange)
+ return;
+ f = arg->f + c->cfact;
+ if(arg->f == 0.0)
+ f = 1.0;
+ else if(f < 0.25 || f > 4.0)
+ return;
+ c->cfact = f;
+ arrange(selmon);
+}
+
/* arg > 1.0 will set mfact absolutely */
void
setmfact(const Arg *arg)
@@ -2846,9 +2866,15 @@ void
tile(Monitor *m)
{
unsigned int i, n, h, mw, my, ty;
+ float mfacts = 0, sfacts = 0;
Client *c;
- for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
+ if (n < m->nmaster)
+ mfacts += c->cfact;
+ else
+ sfacts += c->cfact;
+ }
if (n == 0)
return;
@@ -2858,15 +2884,17 @@ tile(Monitor *m)
mw = m->ww - m->gappx;
for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
- h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
+ h = (m->wh - my) * (c->cfact / mfacts) - m->gappx;
resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
if (my + HEIGHT(c) + m->gappx < m->wh)
my += HEIGHT(c) + m->gappx;
+ mfacts -= c->cfact;
} else {
- h = (m->wh - ty) / (n - i) - m->gappx;
+ h = (m->wh - ty) * (c->cfact / sfacts) - m->gappx;
resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
if (ty + HEIGHT(c) + m->gappx < m->wh)
ty += HEIGHT(c) + m->gappx;
+ sfacts -= c->cfact;
}
}