From 08ea82d301768eb571f1508ee6085345bdc2db18 Mon Sep 17 00:00:00 2001 From: Anas Elgarhy Date: Sun, 10 Jul 2022 20:29:52 +0200 Subject: [PATCH] =?UTF-8?q?Move=20the=20tile=20layout=20function=20into=20?= =?UTF-8?q?splated=20file=F0=9F=98=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dwm.c | 28 ---------------------------- layouts/layouts.h | 1 + layouts/tile.c | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 layouts/tile.c diff --git a/dwm.c b/dwm.c index 02fa4d9..29dc51f 100644 --- a/dwm.c +++ b/dwm.c @@ -2010,34 +2010,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; - for (i = my = ty = 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 { - h = (m->wh - ty) / (n - i); - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); - if (ty + HEIGHT(c) < m->wh) - ty += HEIGHT(c); - } -} - void togglebar(const Arg *arg) { diff --git a/layouts/layouts.h b/layouts/layouts.h index 5c1d1ec..062c2f6 100644 --- a/layouts/layouts.h +++ b/layouts/layouts.h @@ -1,6 +1,7 @@ #ifndef layouts_H #define layouts_H +#include "tile.c" #include "grid.c" #include "fibonacci.c" diff --git a/layouts/tile.c b/layouts/tile.c new file mode 100644 index 0000000..ec2e945 --- /dev/null +++ b/layouts/tile.c @@ -0,0 +1,27 @@ +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; + for (i = my = ty = 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 { + h = (m->wh - ty) / (n - i); + resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); + if (ty + HEIGHT(c) < m->wh) + ty += HEIGHT(c); + } +}