added personal centeredfirstwindow layout

This commit is contained in:
Alexander Bocken 2021-05-06 16:27:41 +02:00
parent 69c6c91743
commit f3ed1812e5
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8
2 changed files with 39 additions and 2 deletions

View File

@ -87,11 +87,11 @@ static const Layout layouts[] = {
/* symbol arrange function */
{ "[@]", spiral }, /* first entry is default */
{ "[\\]", dwindle }, /* Default: Master on left, slaves on right */
{ "H[]", deck }, /* Master on left, slaves in monocle-like mode on right */
{ "1[\\]", centeredfirstwindow}, /* Master in middle, dwindle if more than masters*/
{ ">M>", centeredfloatingmaster }, /* Same but master floats */
{ "H[]", deck }, /* Master on left, slaves in monocle-like mode on right */
{ "[]=", tile }, /* Default: Master on left, slaves on right */
{ "TTT", bstack }, /* Master on top, slaves on bottom */
{ "|M|", centeredmaster }, /* Master in middle, slaves on sides */
{ "[M]", monocle },
{ "===", bstackhoriz },
{ "><>", NULL }, /* no layout function means floating behavior */

37
dwm.c
View File

@ -252,6 +252,7 @@ static void bstack(Monitor *m);
static void bstackhoriz(Monitor *m);
static void centeredmaster(Monitor *m);
static void centeredfloatingmaster(Monitor *m);
static void centeredfirstwindow(Monitor *m);
/* variables */
static Client *prevzoom = NULL;
@ -2492,6 +2493,42 @@ centeredmaster(Monitor *m)
}
}
void
centeredfirstwindow(Monitor *m)
{
unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx;
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 nmaster area */
if (m->ww > m->wh) {
mw = m->nmaster ? m->ww * m->mfact : 0;
mh = m->nmaster ? m->wh : 0;
} else {
mh = m->nmaster ? m->wh * m->mfact : 0;
mw = m->nmaster ? m->ww : 0;
}
mx = mxo = (m->ww - mw) / 2;
my = myo = (m->wh - mh) / 2;
if ( n > m->nmaster){
fibonacci(m, 1);
return;
}
for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
/* nmaster clients are stacked horizontally, in the center
* of the screen */
w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i);
resize(c, m->wx + mx, m->wy + my, w - (2*c->bw),
mh - (2*c->bw), 0);
mx += WIDTH(c);
} }
void
centeredfloatingmaster(Monitor *m)
{