From 51e09ea11e57458a64b004ca3a127df972bb7f0d Mon Sep 17 00:00:00 2001 From: Fredrik Bergroth Date: Wed, 5 Aug 2015 23:20:07 +0200 Subject: [PATCH] New setting: leaf_monocle Use monocle layout if there is a single node. --- contrib/bash_completion | 2 +- contrib/zsh_completion | 2 +- doc/bspwm.1 | 9 +++++++-- doc/bspwm.1.txt | 3 +++ messages.c | 2 ++ settings.c | 1 + settings.h | 2 ++ tree.c | 6 ++++++ 8 files changed, 23 insertions(+), 4 deletions(-) diff --git a/contrib/bash_completion b/contrib/bash_completion index 7599d48..027c587 100644 --- a/contrib/bash_completion +++ b/contrib/bash_completion @@ -1,7 +1,7 @@ _bspc() { local commands='window desktop monitor query pointer rule restore control config quit' - local settings='external_rules_command status_prefix focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color focused_sticky_border_color normal_sticky_border_color focused_private_border_color active_private_border_color normal_private_border_color urgent_border_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio initial_polarity borderless_monocle gapless_monocle focus_follows_pointer pointer_follows_focus pointer_follows_monitor apply_floating_atom auto_alternate auto_cancel history_aware_focus focus_by_distance ignore_ewmh_focus center_pseudo_tiled remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors' + local settings='external_rules_command status_prefix focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color focused_sticky_border_color normal_sticky_border_color focused_private_border_color active_private_border_color normal_private_border_color urgent_border_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio initial_polarity borderless_monocle gapless_monocle leaf_monocle focus_follows_pointer pointer_follows_focus pointer_follows_monitor apply_floating_atom auto_alternate auto_cancel history_aware_focus focus_by_distance ignore_ewmh_focus center_pseudo_tiled remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors' COMPREPLY=() diff --git a/contrib/zsh_completion b/contrib/zsh_completion index 7e6bf74..04b886b 100644 --- a/contrib/zsh_completion +++ b/contrib/zsh_completion @@ -3,7 +3,7 @@ _bspc() { local -a commands settings commands=('window' 'desktop' 'monitor' 'query' 'pointer' 'rule' 'restore' 'control' 'config' 'quit') - settings=('external_rules_command' 'status_prefix' 'focused_border_color' 'active_border_color' 'normal_border_color' 'presel_border_color' 'focused_locked_border_color' 'active_locked_border_color' 'normal_locked_border_color' 'focused_sticky_border_color' 'normal_sticky_border_color' 'focused_private_border_color' 'active_private_border_color' 'normal_private_border_color' 'urgent_border_color' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'initial_polarity' 'borderless_monocle' 'gapless_monocle' 'focus_follows_pointer' 'pointer_follows_focus' 'pointer_follows_monitor' 'apply_floating_atom' 'auto_alternate' 'auto_cancel' 'history_aware_focus' 'focus_by_distance' 'ignore_ewmh_focus' 'center_pseudo_tiled' 'remove_disabled_monitors' 'remove_unplugged_monitors' 'merge_overlapping_monitors') + settings=('external_rules_command' 'status_prefix' 'focused_border_color' 'active_border_color' 'normal_border_color' 'presel_border_color' 'focused_locked_border_color' 'active_locked_border_color' 'normal_locked_border_color' 'focused_sticky_border_color' 'normal_sticky_border_color' 'focused_private_border_color' 'active_private_border_color' 'normal_private_border_color' 'urgent_border_color' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'initial_polarity' 'borderless_monocle' 'gapless_monocle' 'leaf_monocle' 'focus_follows_pointer' 'pointer_follows_focus' 'pointer_follows_monitor' 'apply_floating_atom' 'auto_alternate' 'auto_cancel' 'history_aware_focus' 'focus_by_distance' 'ignore_ewmh_focus' 'center_pseudo_tiled' 'remove_disabled_monitors' 'remove_unplugged_monitors' 'merge_overlapping_monitors') if (( CURRENT == 2 )) ; then _values 'command' "$commands[@]" elif (( CURRENT == 3 )) ; then diff --git a/doc/bspwm.1 b/doc/bspwm.1 index 64a0bb5..52034c2 100644 --- a/doc/bspwm.1 +++ b/doc/bspwm.1 @@ -2,12 +2,12 @@ .\" Title: bspwm .\" Author: [see the "Author" section] .\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 05/26/2015 +.\" Date: 08/05/2015 .\" Manual: Bspwm Manual .\" Source: Bspwm 0.9 .\" Language: English .\" -.TH "BSPWM" "1" "05/26/2015" "Bspwm 0\&.9" "Bspwm Manual" +.TH "BSPWM" "1" "08/05/2015" "Bspwm 0\&.9" "Bspwm Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -1093,6 +1093,11 @@ Remove borders for tiled windows in monocle mode\&. Remove gaps for tiled windows in monocle mode\&. .RE .PP +\fIleaf_monocle\fR +.RS 4 +Use monocle layout if there is a single node\&. +.RE +.PP \fIfocus_follows_pointer\fR .RS 4 Focus the window under the pointer\&. diff --git a/doc/bspwm.1.txt b/doc/bspwm.1.txt index 651486c..ae073f9 100644 --- a/doc/bspwm.1.txt +++ b/doc/bspwm.1.txt @@ -670,6 +670,9 @@ Global Settings 'gapless_monocle':: Remove gaps for tiled windows in monocle mode. +'leaf_monocle':: + Use monocle layout if there is a single node. + 'focus_follows_pointer':: Focus the window under the pointer. diff --git a/messages.c b/messages.c index 02d809b..66bcd87 100644 --- a/messages.c +++ b/messages.c @@ -1044,6 +1044,7 @@ int set_setting(coordinates_t loc, char *name, char *value) return MSG_FAILURE; SETBOOL(borderless_monocle) SETBOOL(gapless_monocle) + SETBOOL(leaf_monocle) SETBOOL(pointer_follows_focus) SETBOOL(pointer_follows_monitor) SETBOOL(apply_floating_atom) @@ -1130,6 +1131,7 @@ int get_setting(coordinates_t loc, char *name, FILE* rsp) fprintf(rsp, "%s", BOOLSTR(s)); GETBOOL(borderless_monocle) GETBOOL(gapless_monocle) + GETBOOL(leaf_monocle) GETBOOL(focus_follows_pointer) GETBOOL(pointer_follows_focus) GETBOOL(pointer_follows_monitor) diff --git a/settings.c b/settings.c index e6ab7cc..c20f3d7 100644 --- a/settings.c +++ b/settings.c @@ -64,6 +64,7 @@ void load_settings(void) borderless_monocle = BORDERLESS_MONOCLE; gapless_monocle = GAPLESS_MONOCLE; + leaf_monocle = LEAF_MONOCLE; focus_follows_pointer = FOCUS_FOLLOWS_POINTER; pointer_follows_focus = POINTER_FOLLOWS_FOCUS; pointer_follows_monitor = POINTER_FOLLOWS_MONITOR; diff --git a/settings.h b/settings.h index b6d9ed4..8608b76 100644 --- a/settings.h +++ b/settings.h @@ -56,6 +56,7 @@ #define FOCUS_BY_DISTANCE false #define BORDERLESS_MONOCLE false #define GAPLESS_MONOCLE false +#define LEAF_MONOCLE false #define FOCUS_FOLLOWS_POINTER false #define POINTER_FOLLOWS_FOCUS false #define POINTER_FOLLOWS_MONITOR false @@ -93,6 +94,7 @@ child_polarity_t initial_polarity; bool borderless_monocle; bool gapless_monocle; +bool leaf_monocle; bool focus_follows_pointer; bool pointer_follows_focus; bool pointer_follows_monitor; diff --git a/tree.c b/tree.c index c409a5b..1531930 100644 --- a/tree.c +++ b/tree.c @@ -43,6 +43,10 @@ void arrange(monitor_t *m, desktop_t *d) PRINTF("arrange %s %s\n", m->name, d->name); + layout_t set_layout = d->layout; + if (leaf_monocle && is_leaf(d->root)) + d->layout = LAYOUT_MONOCLE; + xcb_rectangle_t rect = m->rectangle; int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : d->window_gap); rect.x += m->left_padding + d->left_padding + wg; @@ -50,6 +54,8 @@ void arrange(monitor_t *m, desktop_t *d) rect.width -= m->left_padding + d->left_padding + d->right_padding + m->right_padding + wg; rect.height -= m->top_padding + d->top_padding + d->bottom_padding + m->bottom_padding + wg; apply_layout(m, d, d->root, rect, rect); + + d->layout = set_layout; } void apply_layout(monitor_t *m, desktop_t *d, node_t *n, xcb_rectangle_t rect, xcb_rectangle_t root_rect)