From 3ec665c5936316f8672ccb939ee7e6fe29b3be63 Mon Sep 17 00:00:00 2001 From: Anas Elgarhy Date: Sun, 10 Jul 2022 20:54:48 +0200 Subject: [PATCH] =?UTF-8?q?Move=20the=20monocle=20layout=20function=20to?= =?UTF-8?q?=20a=20separate=20file=20=F0=9F=A5=B0=F0=9F=A5=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dwm.c | 15 --------------- layouts/layouts.h | 2 ++ layouts/monocle.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 layouts/monocle.c diff --git a/dwm.c b/dwm.c index 29dc51f..21f5e6d 100644 --- a/dwm.c +++ b/dwm.c @@ -1328,21 +1328,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) { diff --git a/layouts/layouts.h b/layouts/layouts.h index 062c2f6..9f30d4f 100644 --- a/layouts/layouts.h +++ b/layouts/layouts.h @@ -1,7 +1,9 @@ #ifndef layouts_H #define layouts_H +// Include all layouts #include "tile.c" +#include "monocle.c" #include "grid.c" #include "fibonacci.c" diff --git a/layouts/monocle.c b/layouts/monocle.c new file mode 100644 index 0000000..41db214 --- /dev/null +++ b/layouts/monocle.c @@ -0,0 +1,14 @@ +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); +}