centeredmaster layout

Jérôme Andrieux - jerome@gcu.info
    Laslo Hunhold - dev@frign.de (6.1, git ports)
This commit is contained in:
Przemek Grondek 2023-03-19 21:16:09 +01:00
parent a44e464824
commit 021f5f6d9b

56
dwm.c
View File

@ -186,6 +186,7 @@ static void attach(Client *c);
static void attachaside(Client *c); static void attachaside(Client *c);
static void attachstack(Client *c); static void attachstack(Client *c);
static void buttonpress(XEvent *e); static void buttonpress(XEvent *e);
static void centeredmaster(Monitor *m);
static void checkotherwm(void); static void checkotherwm(void);
static void cleanup(void); static void cleanup(void);
static void cleanupmon(Monitor *mon); static void cleanupmon(Monitor *mon);
@ -2069,6 +2070,61 @@ col(Monitor *m) {
} }
} }
void
centeredmaster(Monitor *m)
{
unsigned int i, n, h, mw, mx, my, oty, ety, tw;
Client *c;
/* count number of clients in the selected monitor */
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
/* initialize areas */
mw = m->ww;
mx = 0;
my = 0;
tw = mw;
if (n > m->nmaster) {
/* go mfact box in the center if more than nmaster clients */
mw = m->nmaster ? m->ww * m->mfact : 0;
tw = m->ww - mw;
if (n - m->nmaster > 1) {
/* only one client */
mx = (m->ww - mw) / 2;
tw = (m->ww - mw) / 2;
}
}
oty = 0;
ety = 0;
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
/* nmaster clients are stacked vertically, in the center
* of the screen */
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
resize(c, m->wx + mx, m->wy + my, mw - (2*c->bw),
h - (2*c->bw), 0);
my += HEIGHT(c);
} else {
/* stack clients are stacked vertically */
if ((i - m->nmaster) % 2 ) {
h = (m->wh - ety) / ( (1 + n - i) / 2);
resize(c, m->wx, m->wy + ety, tw - (2*c->bw),
h - (2*c->bw), 0);
ety += HEIGHT(c);
} else {
h = (m->wh - oty) / ((1 + n - i) / 2);
resize(c, m->wx + mx + mw, m->wy + oty,
tw - (2*c->bw), h - (2*c->bw), 0);
oty += HEIGHT(c);
}
}
}
void void
tcl(Monitor * m) { tcl(Monitor * m) {
int x, y, h, w, mw, sw, bdw; int x, y, h, w, mw, sw, bdw;