]> git.lizzy.rs Git - bspwm.git/commitdiff
Add setting: removal_adjustment
authorBastien Dejean <nihilhill@gmail.com>
Wed, 14 Nov 2018 18:17:22 +0000 (19:17 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Wed, 14 Nov 2018 18:17:22 +0000 (19:17 +0100)
Fixes #872.

16 files changed:
contrib/bash_completion
contrib/fish_completion
contrib/zsh_completion
doc/bspwm.1
doc/bspwm.1.asciidoc
src/bspwm.c
src/bspwm.h
src/helpers.h
src/messages.c
src/parse.c
src/parse.h
src/settings.c
src/settings.h
src/tree.c
src/types.h
src/window.c

index 11e855a672dbf146396c5d3e7e4ab430f57d09da..99908075d221b0b802a66135c425c71c65923d60 100644 (file)
@@ -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 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'
+       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 removal_adjustment 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=()
 
index 87c05eb995c337abb189fa0730e23cc1e776ae93..6bf479fdf942a462b05b17b6e2cd819238315a65 100644 (file)
@@ -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 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'
+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 removal_adjustment 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'
index e16fbc8ee43d471810b50fbe3e7cddd4d8008c93..e696288acfe4b38a3e0a7a887bf450d9ecdaf0c4 100644 (file)
@@ -318,7 +318,7 @@ _bspc() {
                        look_bool=(borderless_monocle gapless_monocle)
                        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)
+                       behaviour=(mapping_events_count ignore_ewmh_fullscreen external_rules_command split_ratio automatic_scheme removal_adjustment initial_polarity directional_focus_tightness status_prefix)
                        input_bool=(swallow_first_click focus_follows_pointer pointer_follows_{focus,monitor})
                        input=(click_to_focus pointer_motion_interval pointer_modifier pointer_action{1,2,3})
                        if [[ "$CURRENT" == (2|3) ]];then
index 7611c772b85f01b6062697c00d4cfa993c80b4ff..0600972e9fe0de9861864da5e0933f9937dfa2a9 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: bspwm
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
-.\"      Date: 09/29/2018
+.\"      Date: 11/14/2018
 .\"    Manual: Bspwm Manual
-.\"    Source: Bspwm 0.9.5-17-g8573b26
+.\"    Source: Bspwm 0.9.5-20-gdb27b84
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "09/29/2018" "Bspwm 0\&.9\&.5\-17\-g8573b26" "Bspwm Manual"
+.TH "BSPWM" "1" "11/14/2018" "Bspwm 0\&.9\&.5\-20\-gdb27b84" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1158,6 +1158,13 @@ The insertion scheme used when the insertion point is in automatic mode\&. Accep
 \fBspiral\fR\&.
 .RE
 .PP
+\fIremoval_adjustment\fR
+.RS 4
+The adjustment applied on the split types of a tree, after removing one of its nodes\&. Accept the following values:
+\fBlongest_side\fR,
+\fBnone\fR\&.
+.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:
index 7b57f421abd211bf87dccfdb4464092d2a89287a..b5c75d6c4c104da3d27697aaa90a2b79c7ba8038 100644 (file)
@@ -680,6 +680,9 @@ Global Settings
 'automatic_scheme'::
        The insertion scheme used when the insertion point is in automatic mode. Accept the following values: *longest_side*, *spiral*.
 
+'removal_adjustment'::
+       The adjustment applied on the split types of a tree, after removing one of its nodes. Accept the following values: *longest_side*, *none*.
+
 '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*.
 
index b23eacc73248741c89fb84739e732bda89ae8de7..3bd82e655838d2fd5c99470f3e99eecbd3eb7baf 100644 (file)
@@ -216,6 +216,7 @@ void init(void)
        subscribe_head = subscribe_tail = NULL;
        pending_rule_head = pending_rule_tail = NULL;
        auto_raise = sticky_still = record_history = true;
+       auto_split_type = false;
        randr_base = 0;
        exit_status = 0;
 }
index 54864d41b147f0f5262917f1a81bb292efb2343e..ca33dd9e2e8c18fbdf52350ab9776cb7bd62f3a7 100644 (file)
@@ -77,6 +77,7 @@ xcb_atom_t WM_DELETE_WINDOW;
 int exit_status;
 
 bool auto_raise;
+bool auto_split_type;
 bool sticky_still;
 bool record_history;
 bool running;
index 8b933bef2dd8889fed5778661b0e73adbfcadca4..4478797184632932257078532bc844f0c3ff1fe5 100644 (file)
@@ -48,6 +48,7 @@
 #define LAYOUT_CHR(A)     ((A) == LAYOUT_TILED ? 'T' : 'M')
 #define CHILD_POL_STR(A)  ((A) == FIRST_CHILD ? "first_child" : "second_child")
 #define AUTO_SCM_STR(A)   ((A) == SCHEME_LONGEST_SIDE ? "longest_side" : "spiral")
+#define REM_ADJ_STR(A)    ((A) == ADJUSTMENT_LONGEST_SIDE ? "longest_side" : "none")
 #define TIGHTNESS_STR(A)  ((A) == TIGHTNESS_HIGH ? "high" : "low")
 #define SPLIT_TYPE_STR(A) ((A) == TYPE_HORIZONTAL ? "horizontal" : "vertical")
 #define SPLIT_MODE_STR(A) ((A) == MODE_AUTOMATIC ? "automatic" : "manual")
index cd4b2f0248968dc510859174e72aa366da303e9a..7c3d4e39182fd6382ae4561a6a36598dbf669798 100644 (file)
@@ -1579,6 +1579,14 @@ void set_setting(coordinates_t loc, char *name, char *value, FILE *rsp)
                        fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
                        return;
                }
+       } else if (streq("removal_adjustment", name)) {
+               removal_adjustment_t r;
+               if (parse_removal_adjustment(value, &r)) {
+                       removal_adjustment = r;
+               } else {
+                       fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
+                       return;
+               }
        } else if (streq("mapping_events_count", name)) {
                if (sscanf(value, "%" SCNi8, &mapping_events_count) != 1) {
                        fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
@@ -1764,6 +1772,8 @@ void get_setting(coordinates_t loc, char *name, FILE* rsp)
                fprintf(rsp, "%s", CHILD_POL_STR(initial_polarity));
        } else if (streq("automatic_scheme", name)) {
                fprintf(rsp, "%s", AUTO_SCM_STR(automatic_scheme));
+       } else if (streq("removal_adjustment", name)) {
+               fprintf(rsp, "%s", REM_ADJ_STR(removal_adjustment));
        } else if (streq("mapping_events_count", name)) {
                fprintf(rsp, "%" PRIi8, mapping_events_count);
        } else if (streq("directional_focus_tightness", name)) {
index 886f944fca7572d574e9b119c1dba0ca5709fa01..c75f9221f6b6137566e41ea7f5d9bbdd5363b32c 100644 (file)
@@ -279,6 +279,18 @@ bool parse_automatic_scheme(char *s, automatic_scheme_t *a)
        return false;
 }
 
+bool parse_removal_adjustment(char *s, removal_adjustment_t *r)
+{
+       if (streq("longest_side", s)) {
+               *r = ADJUSTMENT_LONGEST_SIDE;
+               return true;
+       } else if (streq("none", s)) {
+               *r = ADJUSTMENT_NONE;
+               return true;
+       }
+       return false;
+}
+
 bool parse_state_transition(char *s, state_transition_t *m)
 {
        if (streq("none", s)) {
index 89ba6e1c5699f092629dd2c842f63dcf03c8266c..b33c5f959832229cd1f025e2698098947deb6187 100644 (file)
@@ -26,6 +26,7 @@ bool parse_button_index(char *s, int8_t *b);
 bool parse_pointer_action(char *s, pointer_action_t *a);
 bool parse_child_polarity(char *s, child_polarity_t *p);
 bool parse_automatic_scheme(char *s, automatic_scheme_t *a);
+bool parse_removal_adjustment(char *s, removal_adjustment_t *r);
 bool parse_state_transition(char *s, state_transition_t *m);
 bool parse_tightness(char *s, tightness_t *t);
 bool parse_degree(char *s, int *d);
index 3a5021cb8cca3007cc153d7cd45b394f51fa4003..a9375445c2c4e49cae2c013b2743dd2b1f361e14 100644 (file)
@@ -58,7 +58,8 @@ void load_settings(void)
        border_width = BORDER_WIDTH;
        split_ratio = SPLIT_RATIO;
        initial_polarity = SECOND_CHILD;
-       automatic_scheme = SCHEME_LONGEST_SIDE;
+       automatic_scheme = AUTOMATIC_SCHEME;
+       removal_adjustment = REMOVAL_ADJUSTMENT;
        directional_focus_tightness = TIGHTNESS_HIGH;
 
        pointer_modifier = POINTER_MODIFIER;
index 4968a3cafa10a1c5fb6b44bf43fac4c55bbf0f18..b19518ec901f0412253ea40f1216a12d5186c12d 100644 (file)
@@ -43,6 +43,7 @@
 #define BORDER_WIDTH         1
 #define SPLIT_RATIO          0.5
 #define AUTOMATIC_SCHEME     SCHEME_LONGEST_SIDE
+#define REMOVAL_ADJUSTMENT   ADJUSTMENT_LONGEST_SIDE
 
 #define BORDERLESS_MONOCLE          false
 #define GAPLESS_MONOCLE             false
@@ -79,6 +80,7 @@ unsigned int border_width;
 double split_ratio;
 child_polarity_t initial_polarity;
 automatic_scheme_t automatic_scheme;
+removal_adjustment_t removal_adjustment;
 tightness_t directional_focus_tightness;
 
 uint16_t pointer_modifier;
index 2e61078d9343eca89d09b12f3aff9fbd1b042ab7..14ee95cae68dbba4ea4eb83ecee29afacf0b5f48 100644 (file)
@@ -160,6 +160,9 @@ void apply_layout(monitor_t *m, desktop_t *d, node_t *n, layout_t l, xcb_rectang
                        first_rect = second_rect = rect;
                } else {
                        unsigned int fence;
+                       if (auto_split_type) {
+                               n->split_type = n->rectangle.width > n->rectangle.height ? TYPE_VERTICAL : TYPE_HORIZONTAL;
+                       }
                        if (n->split_type == TYPE_VERTICAL) {
                                fence = rect.width * n->split_ratio;
                                if ((n->first_child->constraints.min_width + n->second_child->constraints.min_width) <= rect.width) {
index 1aebc7754cd2cbc631b43a986ac39c29307dde76..b7445c41d12101da3095dde51f5a35e49f6ca919 100644 (file)
@@ -49,6 +49,11 @@ typedef enum {
        SCHEME_SPIRAL
 } automatic_scheme_t;
 
+typedef enum {
+       ADJUSTMENT_LONGEST_SIDE,
+       ADJUSTMENT_NONE
+} removal_adjustment_t;
+
 typedef enum {
        STATE_TILED,
        STATE_PSEUDO_TILED,
index 1229a0771112915988d26fe6ad8ae8facacee091..982c0281b04d984987aeed6ebd1eed56530e45b5 100644 (file)
@@ -231,8 +231,12 @@ void unmanage_window(xcb_window_t win)
        coordinates_t loc;
        if (locate_window(win, &loc)) {
                put_status(SBSC_MASK_NODE_REMOVE, "node_remove 0x%08X 0x%08X 0x%08X\n", loc.monitor->id, loc.desktop->id, win);
+               if (removal_adjustment == ADJUSTMENT_LONGEST_SIDE) {
+                       auto_split_type = true;
+               }
                remove_node(loc.monitor, loc.desktop, loc.node);
                arrange(loc.monitor, loc.desktop);
+               auto_split_type = false;
        } else {
                for (pending_rule_t *pr = pending_rule_head; pr != NULL; pr = pr->next) {
                        if (pr->win == win) {