Move all layouts to layouts.c

This commit is contained in:
BitHeaven 2023-05-28 10:45:41 +05:00
parent a2751e5d2d
commit b0cfc76821
2 changed files with 43 additions and 45 deletions

45
dwm.c
View File

@ -208,7 +208,6 @@ static void loadxrdb(void);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e);
static void monocle(Monitor *m);
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
static Client *nexttiled(Client *c);
@ -238,7 +237,6 @@ static void sigchld(int unused);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscr(const Arg *arg);
@ -1422,21 +1420,6 @@ maprequest(XEvent *e)
manage(ev->window, &wa);
}
void
monocle(Monitor *m)
{
unsigned int n = 0;
Client *c;
for (c = m->clients; c; c = c->next)
if (ISVISIBLE(c))
n++;
if (n > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
}
void
motionnotify(XEvent *e)
{
@ -2058,34 +2041,6 @@ tagmon(const Arg *arg)
sendmon(selmon->sel, dirtomon(arg->i));
}
void
tile(Monitor *m)
{
unsigned int i, n, h, mw, my, ty;
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 - 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;
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;
} else {
h = (m->wh - ty) / (n - i) - 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;
}
}
void
togglebar(const Arg *arg)
{

View File

@ -62,3 +62,46 @@ gaplessgrid(Monitor *m) {
}
}
}
void
tile(Monitor *m)
{
unsigned int i, n, h, mw, my, ty;
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 - 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;
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;
} else {
h = (m->wh - ty) / (n - i) - 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;
}
}
void
monocle(Monitor *m)
{
unsigned int n = 0;
Client *c;
for (c = m->clients; c; c = c->next)
if (ISVISIBLE(c))
n++;
if (n > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
}