Skip to content

Commit

Permalink
Monocle: add cumulative padding settings
Browse files Browse the repository at this point in the history
  • Loading branch information
baskerville committed Sep 29, 2018
1 parent 8573b26 commit bc3649f
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 20 deletions.
2 changes: 1 addition & 1 deletion contrib/bash_completion
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
_bspc() {
local commands='node desktop monitor query rule wm subscribe config quit'

local settings='external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio automatic_scheme initial_polarity directional_focus_tightness borderless_monocle gapless_monocle single_monocle pointer_motion_interval pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus swallow_first_click focus_follows_pointer pointer_follows_focus pointer_follows_monitor mapping_events_count ignore_ewmh_focus ignore_ewmh_fullscreen center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
local settings='external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding top_monocle_padding right_monocle_padding bottom_monocle_padding left_monocle_padding split_ratio automatic_scheme initial_polarity directional_focus_tightness borderless_monocle gapless_monocle single_monocle pointer_motion_interval pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus swallow_first_click focus_follows_pointer pointer_follows_focus pointer_follows_monitor mapping_events_count ignore_ewmh_focus ignore_ewmh_fullscreen center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'

COMPREPLY=()

Expand Down
2 changes: 1 addition & 1 deletion contrib/fish_completion
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ function __fish_bspc_using_command
end

complete -f -c bspc -n '__fish_bspc_needs_command' -a 'node desktop monitor query rule wm subscribe config quit'
complete -f -c bspc -n '__fish_bspc_using_command config' -a 'external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio automatic_scheme initial_polarity directional_focus_tightness borderless_monocle gapless_monocle single_monocle pointer_motion_interval pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus swallow_first_click focus_follows_pointer pointer_follows_focus pointer_follows_monitor mapping_events_count ignore_ewmh_focus ignore_ewmh_fullscreen center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
complete -f -c bspc -n '__fish_bspc_using_command config' -a 'external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding top_monocle_padding right_monocle_padding bottom_monocle_padding left_monocle_padding split_ratio automatic_scheme initial_polarity directional_focus_tightness borderless_monocle gapless_monocle single_monocle pointer_motion_interval pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus swallow_first_click focus_follows_pointer pointer_follows_focus pointer_follows_monitor mapping_events_count ignore_ewmh_focus ignore_ewmh_fullscreen center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
2 changes: 1 addition & 1 deletion contrib/zsh_completion
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ _bspc() {
(config)
local -a {look,behaviour,input}{_bool,}
look_bool=(borderless_monocle gapless_monocle)
look=({normal,active,focused}_border_color {top,right,bottom,left}_padding presel_feedback_color border_width window_gap)
look=({normal,active,focused}_border_color {top,right,bottom,left}_padding {top,right,bottom,left}_monocle_padding presel_feedback_color border_width window_gap)
behaviour_bool=(single_monocle ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors)
behaviour=(mapping_events_count ignore_ewmh_fullscreen external_rules_command split_ratio automatic_scheme initial_polarity directional_focus_tightness status_prefix)
input_bool=(swallow_first_click focus_follows_pointer pointer_follows_{focus,monitor})
Expand Down
10 changes: 5 additions & 5 deletions doc/bspwm.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 08/31/2018
.\" Date: 09/29/2018
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.9.5-14-g56ad57c
.\" Source: Bspwm 0.9.5-17-g8573b26
.\" Language: English
.\"
.TH "BSPWM" "1" "08/31/2018" "Bspwm 0\&.9\&.5\-14\-g56ad57c" "Bspwm Manual"
.TH "BSPWM" "1" "09/29/2018" "Bspwm 0\&.9\&.5\-17\-g8573b26" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -1188,9 +1188,9 @@ Remove gaps of tiled windows for the
desktop layout\&.
.RE
.PP
\fIpaddingless_monocle\fR
\fItop_monocle_padding\fR, \fIright_monocle_padding\fR, \fIbottom_monocle_padding\fR, \fIleft_monocle_padding\fR
.RS 4
Remove padding space for the
Padding space added at the sides of the screen for the
\fBmonocle\fR
desktop layout\&.
.RE
Expand Down
7 changes: 5 additions & 2 deletions doc/bspwm.1.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,11 @@ Global Settings
'gapless_monocle'::
Remove gaps of tiled windows for the *monocle* desktop layout.
'paddingless_monocle'::
Remove padding space for the *monocle* desktop layout.
'top_monocle_padding'::
'right_monocle_padding'::
'bottom_monocle_padding'::
'left_monocle_padding'::
Padding space added at the sides of the screen for the *monocle* desktop layout.
'single_monocle'::
Set the desktop layout to *monocle* if there's only one tiled window in the tree.
Expand Down
26 changes: 24 additions & 2 deletions src/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,22 @@ void set_setting(coordinates_t loc, char *name, char *value, FILE *rsp)
}
SET_DEF_MON_DESK(padding.left, lp)
#undef SET_DEF_MON_DESK
} else if (streq("top_monocle_padding", name)) {
if (sscanf(value, "%i", &monocle_padding.top) != 1) {
fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
}
} else if (streq("right_monocle_padding", name)) {
if (sscanf(value, "%i", &monocle_padding.right) != 1) {
fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
}
} else if (streq("bottom_monocle_padding", name)) {
if (sscanf(value, "%i", &monocle_padding.bottom) != 1) {
fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
}
} else if (streq("left_monocle_padding", name)) {
if (sscanf(value, "%i", &monocle_padding.left) != 1) {
fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
}
#define SET_STR(s) \
} else if (streq(#s, name)) { \
if (snprintf(s, sizeof(s), "%s", value) < 0) { \
Expand Down Expand Up @@ -1652,7 +1668,6 @@ void set_setting(coordinates_t loc, char *name, char *value, FILE *rsp)
}
SET_BOOL(borderless_monocle)
SET_BOOL(gapless_monocle)
SET_BOOL(paddingless_monocle)
SET_BOOL(single_monocle)
SET_BOOL(swallow_first_click)
SET_BOOL(pointer_follows_focus)
Expand Down Expand Up @@ -1733,6 +1748,14 @@ void get_setting(coordinates_t loc, char *name, FILE* rsp)
} else if (streq("left_padding", name)) {
GET_DEF_MON_DESK(padding.left)
#undef GET_DEF_MON_DESK
} else if (streq("top_monocle_padding", name)) {
fprintf(rsp, "%i", monocle_padding.top);
} else if (streq("right_monocle_padding", name)) {
fprintf(rsp, "%i", monocle_padding.right);
} else if (streq("bottom_monocle_padding", name)) {
fprintf(rsp, "%i", monocle_padding.bottom);
} else if (streq("left_monocle_padding", name)) {
fprintf(rsp, "%i", monocle_padding.left);
} else if (streq("external_rules_command", name)) {
fprintf(rsp, "%s", external_rules_command);
} else if (streq("status_prefix", name)) {
Expand Down Expand Up @@ -1771,7 +1794,6 @@ void get_setting(coordinates_t loc, char *name, FILE* rsp)
fprintf(rsp, "%s", BOOL_STR(s));
GET_BOOL(borderless_monocle)
GET_BOOL(gapless_monocle)
GET_BOOL(paddingless_monocle)
GET_BOOL(single_monocle)
GET_BOOL(swallow_first_click)
GET_BOOL(focus_follows_pointer)
Expand Down
2 changes: 1 addition & 1 deletion src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void load_settings(void)
snprintf(presel_feedback_color, sizeof(presel_feedback_color), "%s", PRESEL_FEEDBACK_COLOR);

padding = (padding_t) PADDING;
monocle_padding = (padding_t) MONOCLE_PADDING;
window_gap = WINDOW_GAP;
border_width = BORDER_WIDTH;
split_ratio = SPLIT_RATIO;
Expand All @@ -69,7 +70,6 @@ void load_settings(void)

borderless_monocle = BORDERLESS_MONOCLE;
gapless_monocle = GAPLESS_MONOCLE;
paddingless_monocle = PADDINGLESS_MONOCLE;
single_monocle = SINGLE_MONOCLE;

focus_follows_pointer = FOCUS_FOLLOWS_POINTER;
Expand Down
4 changes: 2 additions & 2 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
#define PRESEL_FEEDBACK_COLOR "#f4d775"

#define PADDING {0, 0, 0, 0}
#define MONOCLE_PADDING {0, 0, 0, 0}
#define WINDOW_GAP 6
#define BORDER_WIDTH 1
#define SPLIT_RATIO 0.5
#define AUTOMATIC_SCHEME SCHEME_LONGEST_SIDE

#define BORDERLESS_MONOCLE false
#define GAPLESS_MONOCLE false
#define PADDINGLESS_MONOCLE false
#define SINGLE_MONOCLE false

#define FOCUS_FOLLOWS_POINTER false
Expand Down Expand Up @@ -73,6 +73,7 @@ char focused_border_color[MAXLEN];
char presel_feedback_color[MAXLEN];

padding_t padding;
padding_t monocle_padding;
int window_gap;
unsigned int border_width;
double split_ratio;
Expand All @@ -87,7 +88,6 @@ int8_t mapping_events_count;

bool borderless_monocle;
bool gapless_monocle;
bool paddingless_monocle;
bool single_monocle;

bool focus_follows_pointer;
Expand Down
15 changes: 10 additions & 5 deletions src/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@ void arrange(monitor_t *m, desktop_t *d)

xcb_rectangle_t rect = m->rectangle;

if (!paddingless_monocle || l != LAYOUT_MONOCLE) {
rect.x += m->padding.left + d->padding.left;
rect.y += m->padding.top + d->padding.top;
rect.width -= m->padding.left + d->padding.left + d->padding.right + m->padding.right;
rect.height -= m->padding.top + d->padding.top + d->padding.bottom + m->padding.bottom;
rect.x += m->padding.left + d->padding.left;
rect.y += m->padding.top + d->padding.top;
rect.width -= m->padding.left + d->padding.left + d->padding.right + m->padding.right;
rect.height -= m->padding.top + d->padding.top + d->padding.bottom + m->padding.bottom;

if (l == LAYOUT_MONOCLE) {
rect.x += monocle_padding.left;
rect.y += monocle_padding.top;
rect.width -= monocle_padding.left + monocle_padding.right;
rect.height -= monocle_padding.top + monocle_padding.bottom;
}

if (!gapless_monocle || l != LAYOUT_MONOCLE) {
Expand Down

0 comments on commit bc3649f

Please sign in to comment.