Add new setting: initial_polarity

Fixes #193.
This commit is contained in:
Bastien Dejean 2015-01-06 20:10:09 +01:00
parent b18083cd1e
commit c13c678a54
10 changed files with 50 additions and 6 deletions

View file

@ -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 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 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 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 remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
COMPREPLY=()

View file

@ -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' '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' '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' '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' 'remove_disabled_monitors' 'remove_unplugged_monitors' 'merge_overlapping_monitors')
if (( CURRENT == 2 )) ; then
_values 'command' "$commands[@]"
elif (( CURRENT == 3 )) ; then

View file

@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" Date: 11/23/2014
.\" Date: 01/06/2015
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.8.9
.\" Language: English
.\"
.TH "BSPWM" "1" "11/23/2014" "Bspwm 0\&.8\&.9" "Bspwm Manual"
.TH "BSPWM" "1" "01/06/2015" "Bspwm 0\&.8\&.9" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@ -1061,6 +1061,13 @@ External command used to retrieve rule consequences\&. The command will receive
command)\&.
.RE
.PP
\fIinitial_polarity\fR
.RS 4
On which child should a new window be attached when adding a window on a single window tree in automatic mode\&. Accept the following values:
\fBfirst_child\fR,
\fBsecond_child\fR\&.
.RE
.PP
\fIhistory_aware_focus\fR
.RS 4
Give priority to the focus history when focusing nodes\&.

View file

@ -652,6 +652,9 @@ Global Settings
'external_rules_command'::
External command used to retrieve rule consequences. The command will receive the the ID of the window being processed as its first argument and the class and instance names as second and third arguments. The output of that command must have the following format: *key1=value1 key2=value2 ...* (the valid key/value pairs are given in the description of the 'rule' command).
'initial_polarity'::
On which child should a new window be attached when adding a window on a single window tree in automatic mode. Accept the following values: *first_child*, *second_child*.
'history_aware_focus'::
Give priority to the focus history when focusing nodes.

View file

@ -958,6 +958,13 @@ int set_setting(coordinates_t loc, char *name, char *value)
SETCOLOR(normal_private_border_color)
SETCOLOR(urgent_border_color)
#undef SETCOLOR
} else if (streq("initial_polarity", name)) {
child_polarity_t p;
if (parse_child_polarity(value, &p)) {
initial_polarity = p;
} else {
return MSG_FAILURE;
}
} else if (streq("focus_follows_pointer", name)) {
bool b;
if (parse_bool(value, &b) && b != focus_follows_pointer) {
@ -1037,6 +1044,8 @@ int get_setting(coordinates_t loc, char *name, FILE* rsp)
fprintf(rsp, "%s", external_rules_command);
else if (streq("status_prefix", name))
fprintf(rsp, "%s", status_prefix);
else if (streq("initial_polarity", name))
fprintf(rsp, "%s", initial_polarity == FIRST_CHILD ? "first_child" : "second_child");
#define MONDESKGET(k) \
else if (streq(#k, name)) \
if (loc.desktop != NULL) \
@ -1197,6 +1206,18 @@ bool parse_pointer_action(char *s, pointer_action_t *a)
return false;
}
bool parse_child_polarity(char *s, child_polarity_t *p)
{
if (streq("first_child", s)) {
*p = FIRST_CHILD;
return true;
} else if (streq("second_child", s)) {
*p = SECOND_CHILD;
return true;
}
return false;
}
bool parse_degree(char *s, int *d)
{
int i = atoi(s);

View file

@ -53,6 +53,7 @@ bool parse_circulate_direction(char *s, circulate_dir_t *d);
bool parse_history_direction(char *s, history_dir_t *d);
bool parse_flip(char *s, flip_t *f);
bool parse_pointer_action(char *s, pointer_action_t *a);
bool parse_child_polarity(char *s, child_polarity_t *p);
bool parse_degree(char *s, int *d);
bool parse_window_id(char *s, long int *i);
bool parse_bool_declaration(char *s, char **key, bool *value, alter_state_t *state);

View file

@ -60,6 +60,7 @@ void load_settings(void)
split_ratio = SPLIT_RATIO;
window_gap = WINDOW_GAP;
border_width = BORDER_WIDTH;
initial_polarity = FIRST_CHILD;
borderless_monocle = BORDERLESS_MONOCLE;
gapless_monocle = GAPLESS_MONOCLE;

View file

@ -88,6 +88,7 @@ char urgent_border_color[MAXLEN];
double split_ratio;
int window_gap;
unsigned int border_width;
child_polarity_t initial_polarity;
bool borderless_monocle;
bool gapless_monocle;

9
tree.c
View file

@ -181,8 +181,13 @@ void insert_node(monitor_t *m, desktop_t *d, node_t *n, node_t *f)
switch (f->split_mode) {
case MODE_AUTOMATIC:
if (p == NULL) {
c->first_child = n;
c->second_child = f;
if (initial_polarity == FIRST_CHILD) {
c->first_child = n;
c->second_child = f;
} else {
c->first_child = f;
c->second_child = n;
}
if (m->rectangle.width > m->rectangle.height)
c->split_type = TYPE_VERTICAL;
else

View file

@ -142,6 +142,11 @@ typedef enum {
DESKTOP_URGENCY_OFF
} desktop_urgency_t;
typedef enum {
FIRST_CHILD,
SECOND_CHILD
} child_polarity_t;
typedef struct {
desktop_status_t status;
bool urgent;