From 58ab50845d5af725700dcfb1ef8c1f1053a78a88 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 7 Mar 2020 17:03:19 +0100 Subject: [PATCH] Adding option to enable gaps for monocle layout, ref. issue #11 --- patch/flextile-deluxe.c | 4 ++-- patch/monocle.c | 21 ++++++++++++++++++++- patch/vanitygaps.c | 2 +- patch/vanitygaps.h | 2 +- patches.def.h | 6 ++++++ 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/patch/flextile-deluxe.c b/patch/flextile-deluxe.c index ae6a870..909f3b2 100644 --- a/patch/flextile-deluxe.c +++ b/patch/flextile-deluxe.c @@ -545,13 +545,13 @@ flextile(Monitor *m) if (n == 0) return; - #if VANITYGAPS_PATCH + #if VANITYGAPS_PATCH && !VANITYGAPS_MONOCLE_PATCH /* No outer gap if full screen monocle */ if (abs(m->ltaxis[MASTER]) == MONOCLE && (abs(m->ltaxis[LAYOUT]) == NO_SPLIT || n <= m->nmaster)) { oh = 0; ov = 0; } - #endif // VANITYGAPS_PATCH + #endif // VANITYGAPS_PATCH && !VANITYGAPS_MONOCLE_PATCH (&flexlayouts[abs(m->ltaxis[LAYOUT])])->arrange(m, m->wx + ov, m->wy + oh, m->wh - 2*oh, m->ww - 2*ov, ih, iv, n); return; diff --git a/patch/monocle.c b/patch/monocle.c index d132f44..1533aa9 100644 --- a/patch/monocle.c +++ b/patch/monocle.c @@ -1,3 +1,21 @@ +#if VANITYGAPS_PATCH && VANITYGAPS_MONOCLE_PATCH +void +monocle(Monitor *m) +{ + unsigned int n; + int oh, ov, ih, iv; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + + #if !MONOCLESYMBOL_PATCH + if (n > 0) /* override layout symbol */ + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); + #endif // MONOCLESYMBOL_PATCH + for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) + resize(c, m->wx + ov, m->wy + oh, m->ww - 2 * c->bw - 2 * ov, m->wh - 2 * c->bw - 2 * oh, 0); +} +#else void monocle(Monitor *m) { @@ -15,4 +33,5 @@ monocle(Monitor *m) #endif // MONOCLESYMBOL_PATCH 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); -} \ No newline at end of file +} +#endif // VANITYGAPS_PATCH \ No newline at end of file diff --git a/patch/vanitygaps.c b/patch/vanitygaps.c index bbbee6e..d1f0505 100644 --- a/patch/vanitygaps.c +++ b/patch/vanitygaps.c @@ -112,7 +112,7 @@ incrivgaps(const Arg *arg) ); } -#if CENTEREDMASTER_LAYOUT || CENTEREDFLOATINGMASTER_LAYOUT || COLUMNS_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || NROWGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT || TILE_LAYOUT +#if CENTEREDMASTER_LAYOUT || CENTEREDFLOATINGMASTER_LAYOUT || COLUMNS_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || NROWGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT || TILE_LAYOUT || (VANITYGAPS_MONOCLE_PATCH && MONOCLE_LAYOUT) static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc) { diff --git a/patch/vanitygaps.h b/patch/vanitygaps.h index 569c602..5667be2 100644 --- a/patch/vanitygaps.h +++ b/patch/vanitygaps.h @@ -10,7 +10,7 @@ static void incrivgaps(const Arg *arg); static void togglegaps(const Arg *arg); /* Internals */ -#if CENTEREDMASTER_LAYOUT || CENTEREDFLOATINGMASTER_LAYOUT || COLUMNS_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || NROWGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT || TILE_LAYOUT +#if CENTEREDMASTER_LAYOUT || CENTEREDFLOATINGMASTER_LAYOUT || COLUMNS_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || NROWGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT || TILE_LAYOUT || (VANITYGAPS_MONOCLE_PATCH && MONOCLE_LAYOUT) static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc); #endif static void setgaps(int oh, int ov, int ih, int iv); \ No newline at end of file diff --git a/patches.def.h b/patches.def.h index a6f86ed..816f300 100644 --- a/patches.def.h +++ b/patches.def.h @@ -580,6 +580,12 @@ */ #define VANITYGAPS_PATCH 0 +/* This patch adds outer gaps for the monocle layout. + * Most gaps patches tries to avoid gaps on the monocle layout, as it is often used as a + * fullscreen mode, hence this is enabled separately from the main vanitygaps patch. + */ +#define VANITYGAPS_MONOCLE_PATCH 0 + /* Follow a window to the tag it is being moved to. * https://dwm.suckless.org/patches/viewontag/ */