]> git.lizzy.rs Git - bspwm.git/commitdiff
Add new setting: initial_polarity
authorBastien Dejean <nihilhill@gmail.com>
Tue, 6 Jan 2015 19:10:09 +0000 (20:10 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Tue, 6 Jan 2015 19:10:09 +0000 (20:10 +0100)
Fixes #193.

contrib/bash_completion
contrib/zsh_completion
doc/bspwm.1
doc/bspwm.1.txt
messages.c
messages.h
settings.c
settings.h
tree.c
types.h

index 05dbc25abe2d94c16918781aacf9b978a62229e0..ba9c77ceea7d10ebeefee4918f9f956e9d675236 100644 (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=()
 
index b93ae99b445a4f7622cf9884f9da3c92d116cc23..a00e50148dad41b1a4c2202526e8b35b318f5937 100644 (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
index 95fab401142e945d5fdf164dd46fca0d84f28435..fe41e21fb31b53100367feb888fb44c3ff636dee 100644 (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\&.
index 85e511735564a7e26fd774a0cfb5d8734dafe677..89b4d10ab03c36ad5cbd759cce981a65356e70ff 100644 (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.
 
index d859a3f8d91fba99ebee71fb055f92717c200397..c0f773a34449169e3c6d97be491701f62c7e52ee 100644 (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);
index bac39c4784535f2ebb03d35375465b517f891859..dbcd44e4ea559d4ef163ffe5644a71d6419bb37d 100644 (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);
index a18fe9a7f49a3ea5bde72bc85c90ec3aaddce4e5..1d73146628a87378a4d6f8f5739d7cd2676e572b 100644 (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;
index 5fe17b46a32d675dc8329907a70460fa9526aad5..41f2cfc112391877ac87a9d66ec5fac75e5d81fa 100644 (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;
diff --git a/tree.c b/tree.c
index 82786d03d23d1874b9f5b179f7e8f3148283354e..c428a40a6580d8f663d22635f27496e08b95a3d6 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -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
diff --git a/types.h b/types.h
index 9782ede332971287b510e766cb1cbe571e348929..3fca404f7eb91f063f416cb7e68b506dc3172062 100644 (file)
--- a/types.h
+++ b/types.h
@@ -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;