Merge branch 'stairs' into patched

This commit is contained in:
GasparVardanyan 2024-10-01 05:39:36 +04:00
commit e7429435b9
2 changed files with 43 additions and 0 deletions

View file

@ -10,6 +10,9 @@ static const unsigned int snap = DWM_SNAP; /* snap pixel */
static const int showbar = DWM_SHOWBAR; /* 0 means no bar */
static const int topbar = DWM_TOPBAR; /* 0 means bottom bar */
static const char *fonts[] = DWM_FONT;
static const unsigned int stairpx = 20; /* depth of the stairs layout */
static const int stairdirection = 1; /* 0: left-aligned, 1: right-aligned */
static const int stairsamesize = 1; /* 1 means shrink all the staired windows to the same size */
static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
@ -58,6 +61,7 @@ static const Layout layouts[] = {
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
{ "[S]", stairs },
};
/* key definitions */
@ -125,6 +129,7 @@ static const Key keys[] = {
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_s, setlayout, {.v = &layouts[3]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY|ShiftMask, XK_f, togglefullscr, {0} },

38
dwm.c
View file

@ -221,6 +221,7 @@ static void sigterm(int unused);
static void showhide(Client *c);
static void spawn(const Arg *arg);
static void spawnscratch(const Arg *arg);
static void stairs(Monitor *m);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
@ -1898,6 +1899,43 @@ void spawnscratch(const Arg *arg)
}
}
void
stairs(Monitor *m)
{
unsigned int i, n, h, mw, my;
unsigned int ox, oy, ow, oh; /* stair offset values */
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
if (n > m->nmaster)
mw = m->nmaster ? m->ww * m->mfact : 0;
else
mw = m->ww;
for (i = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
if (i < m->nmaster) {
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
resize(c, m->wx, m->wy + my, mw - (2 * c->bw), h - (2 * c->bw), 0);
if (my + HEIGHT(c) < m->wh)
my += HEIGHT(c);
} else {
oy = i - m->nmaster;
ox = stairdirection ? n - i - 1 : (stairsamesize ? i - m->nmaster : 0);
ow = stairsamesize ? n - m->nmaster - 1 : n - i - 1;
oh = stairsamesize ? ow : i - m->nmaster;
resize(c,
m->wx + mw + (ox * stairpx),
m->wy + (oy * stairpx),
m->ww - mw - (2 * c->bw) - (ow * stairpx),
m->wh - (2 * c->bw) - (oh * stairpx),
0);
}
}
}
void
tag(const Arg *arg)
{