From edd2e2422d9d3bd528ccd4a8edb045eb3b41ca38 Mon Sep 17 00:00:00 2001 From: Bastien Dejean Date: Sun, 4 Nov 2012 14:10:08 +0100 Subject: [PATCH] New setting: 'gapless_monocle' --- README.md | 3 +++ bspwm.1 | 3 +++ messages.c | 6 ++++++ settings.c | 1 + settings.h | 2 ++ tree.c | 12 +++++++----- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0f15bee..13527a6 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,9 @@ Colors are either [X color names](http://en.wikipedia.org/wiki/X11_color_names) borderless_monocle Whether to remove borders for tiled windows in monocle mode. + gapless_monocle + Whether to remove gaps for tiled windows in monocle mode. + focus_follows_mouse Wether to focus the window under the mouse pointer. diff --git a/bspwm.1 b/bspwm.1 index f2823ea..39a7411 100644 --- a/bspwm.1 +++ b/bspwm.1 @@ -296,6 +296,9 @@ The modifier mask used for mouse bindings (possible values: .I borderless_monocle Whether to remove borders for tiled windows in monocle mode. .TP +.I gapless_monocle +Whether to remove gaps for tiled windows in monocle mode. +.TP .I focus_follows_mouse Wether to focus the window under the mouse pointer. .SH MOUSE BINDINGS diff --git a/messages.c b/messages.c index 59cd2a4..b13fe1d 100644 --- a/messages.c +++ b/messages.c @@ -367,6 +367,10 @@ void set_setting(char *name, char *value, char *rsp) bool b; if (parse_bool(value, &b)) borderless_monocle = b; + } else if (strcmp(name, "gapless_monocle") == 0) { + bool b; + if (parse_bool(value, &b)) + gapless_monocle = b; } else if (strcmp(name, "focus_follows_mouse") == 0) { bool b; if (parse_bool(value, &b)) @@ -436,6 +440,8 @@ void get_setting(char *name, char* rsp) snprintf(rsp, BUFSIZ, "%s (%06X)", urgent_border_color, urgent_border_color_pxl); else if (strcmp(name, "borderless_monocle") == 0) snprintf(rsp, BUFSIZ, "%s", BOOLSTR(borderless_monocle)); + else if (strcmp(name, "gapless_monocle") == 0) + snprintf(rsp, BUFSIZ, "%s", BOOLSTR(gapless_monocle)); else if (strcmp(name, "focus_follows_mouse") == 0) snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_follows_mouse)); else if (strcmp(name, "wm_name") == 0) diff --git a/settings.c b/settings.c index f36c511..2a3e4e5 100644 --- a/settings.c +++ b/settings.c @@ -67,5 +67,6 @@ void load_settings(void) bottom_padding = BOTTOM_PADDING; borderless_monocle = BORDERLESS_MONOCLE; + gapless_monocle = GAPLESS_MONOCLE; focus_follows_mouse = FOCUS_FOLLOWS_MOUSE; } diff --git a/settings.h b/settings.h index 1e8ee67..99cda23 100644 --- a/settings.h +++ b/settings.h @@ -30,6 +30,7 @@ #define RIGHT_PADDING 0 #define BORDERLESS_MONOCLE false +#define GAPLESS_MONOCLE false #define FOCUS_FOLLOWS_MOUSE false char focused_border_color[MAXLEN]; @@ -66,6 +67,7 @@ int left_padding; int right_padding; bool borderless_monocle; +bool gapless_monocle; bool focus_follows_mouse; char wm_name[MAXLEN]; diff --git a/tree.c b/tree.c index ab29dd7..0b7bba5 100644 --- a/tree.c +++ b/tree.c @@ -266,10 +266,11 @@ void arrange(monitor_t *m, desktop_t *d) PRINTF("arrange %s%s%s\n", (num_monitors > 1 ? m->name : ""), (num_monitors > 1 ? " " : ""), d->name); xcb_rectangle_t rect = m->rectangle; - rect.x += left_padding + window_gap; - rect.y += top_padding + window_gap; - rect.width -= left_padding + right_padding + window_gap; - rect.height -= top_padding + bottom_padding + window_gap; + int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : window_gap); + rect.x += left_padding + wg; + rect.y += top_padding + wg; + rect.width -= left_padding + right_padding + wg; + rect.height -= top_padding + bottom_padding + wg; if (focus_follows_mouse) get_pointer_position(&pointer_position); apply_layout(m, d, d->root, rect, rect); @@ -303,7 +304,8 @@ void apply_layout(monitor_t *m, desktop_t *d, node_t *n, xcb_rectangle_t rect, x r = rect; else if (d->layout == LAYOUT_MONOCLE) r = root_rect; - int bleed = window_gap + 2 * n->client->border_width; + int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : window_gap); + int bleed = wg + 2 * n->client->border_width; r.width = (bleed < r.width ? r.width - bleed : 1); r.height = (bleed < r.height ? r.height - bleed : 1); n->client->tiled_rectangle = r;