Skip to content

Commit

Permalink
New setting: leaf_monocle
Browse files Browse the repository at this point in the history
Use monocle layout if there is a single node.
  • Loading branch information
fbergroth committed Aug 5, 2015
1 parent dccb5e7 commit 51e09ea
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion 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=()

Expand Down
2 changes: 1 addition & 1 deletion contrib/zsh_completion
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions doc/bspwm.1
Expand Up @@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" 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
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -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\&.
Expand Down
3 changes: 3 additions & 0 deletions doc/bspwm.1.txt
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions messages.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions settings.c
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions settings.h
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions tree.c
Expand Up @@ -43,13 +43,19 @@ 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;
rect.y += m->top_padding + d->top_padding + wg;
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)
Expand Down

0 comments on commit 51e09ea

Please sign in to comment.