New setting: 'gapless_monocle'

This commit is contained in:
Bastien Dejean 2012-11-04 14:10:08 +01:00
parent ce4c9f5887
commit edd2e2422d
6 changed files with 22 additions and 5 deletions

View file

@ -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.

View file

@ -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

View file

@ -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)

View file

@ -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;
}

View file

@ -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];

12
tree.c
View file

@ -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;