]> git.lizzy.rs Git - bspwm.git/commitdiff
Add setting: directional_focus_tightness
authorBastien Dejean <nihilhill@gmail.com>
Sun, 4 Jun 2017 08:25:11 +0000 (10:25 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Sun, 4 Jun 2017 08:25:11 +0000 (10:25 +0200)
13 files changed:
contrib/bash_completion
contrib/fish_completion
contrib/zsh_completion
doc/bspwm.1
doc/bspwm.1.asciidoc
src/geometry.c
src/helpers.h
src/messages.c
src/parse.c
src/parse.h
src/settings.c
src/settings.h
src/types.h

index 4bc76c738c549ef71b786688de885ed7d37a2dde..088eab05dade807883e71c8f44c3d992bf6eae2c 100644 (file)
@@ -1,7 +1,7 @@
 _bspc() {
        local commands='node desktop monitor query rule restore 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 initial_polarity 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 ignore_ewmh_focus 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 split_ratio 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 ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
 
        COMPREPLY=()
 
index 78da934d6146776dc64b8a73f0755972530fbf27..ff5a59d1503572cee3a8f013bc308abf44313272 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 restore 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 initial_polarity 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 ignore_ewmh_focus 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 split_ratio 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 ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
index f97a2488d5950cc9f34777b7d98e030eb53bcef5..69c25952442d3e4fa5fe792873610a8104a8d7d1 100644 (file)
@@ -3,7 +3,7 @@
 _bspc() {
        local -a commands settings
        commands=('node' 'desktop' 'monitor' 'query' 'rule' 'restore' 'wm' 'subscribe' 'config' 'quit')
-       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' 'initial_polarity' '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' 'ignore_ewmh_focus' 'center_pseudo_tiled' 'honor_size_hints' 'remove_disabled_monitors' 'remove_unplugged_monitors' 'merge_overlapping_monitors')
+       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' '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' 'ignore_ewmh_focus' 'center_pseudo_tiled' 'honor_size_hints' 'remove_disabled_monitors' 'remove_unplugged_monitors' 'merge_overlapping_monitors')
        if (( CURRENT == 2 )) ; then
                _values 'command' "$commands[@]"
        elif (( CURRENT == 3 )) ; then
index 4a0681cc15aeeb87f76c5f4ebf9389daaf6abbd9..1859d219e4e64be7813bb496ef90268854dfba2e 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: 01/30/2017
+.\"      Date: 06/04/2017
 .\"    Manual: Bspwm Manual
-.\"    Source: Bspwm 0.9.2-25-g048230e
+.\"    Source: Bspwm 0.9.2-48-gfab441b
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "01/30/2017" "Bspwm 0\&.9\&.2\-25\-g048230e" "Bspwm Manual"
+.TH "BSPWM" "1" "06/04/2017" "Bspwm 0\&.9\&.2\-48\-gfab441b" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1053,6 +1053,15 @@ On which child should a new window be attached when adding a window on a single
 \fBsecond_child\fR\&.
 .RE
 .PP
+\fIdirectional_focus_tightness\fR
+.RS 4
+The tightness of the algorithm used to decide whether a window is on the
+\fIDIR\fR
+side of another window\&. Accept the following values:
+\fBhigh\fR,
+\fBlow\fR\&.
+.RE
+.PP
 \fIborderless_monocle\fR
 .RS 4
 Remove borders of tiled windows for the
index 46a2b829bd2d28244c79e80b09cb99dccc485786..3478663421ebf8aacf46335d685a5b87f0558052 100644 (file)
@@ -624,6 +624,9 @@ Global Settings
 '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*.
 
+'directional_focus_tightness'::
+       The tightness of the algorithm used to decide whether a window is on the 'DIR' side of another window. Accept the following values: *high*, *low*.
+
 'borderless_monocle'::
        Remove borders of tiled windows for the *monocle* desktop layout.
 
index ffd90cd950568791c609ac37ed9a7d0f9b80bebb..a19dfcf4a27213a06431592e8aaa0e7314a662ee 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <math.h>
 #include "types.h"
+#include "settings.h"
 #include "geometry.h"
 
 bool is_inside(xcb_point_t p, xcb_rectangle_t r)
@@ -63,33 +64,61 @@ uint32_t boundary_distance(xcb_rectangle_t r1, xcb_rectangle_t r2, direction_t d
 /* Is `r2` on the `dir` side of `r1`? */
 bool on_dir_side(xcb_rectangle_t r1, xcb_rectangle_t r2, direction_t dir)
 {
-       if (rect_eq(r1, r2)) {
-               return false;
-       }
-
        xcb_point_t r1_max = {r1.x + r1.width - 1, r1.y + r1.height - 1};
        xcb_point_t r2_max = {r2.x + r2.width - 1, r2.y + r2.height - 1};
 
        /* Eliminate rectangles on the opposite side */
-       switch (dir) {
-               case DIR_NORTH:
-                       if (r2.y > r1_max.y) {
-                               return false;
+       switch (directional_focus_tightness) {
+               case TIGHTNESS_LOW:
+                       switch (dir) {
+                               case DIR_NORTH:
+                                       if (r2.y > r1_max.y) {
+                                               return false;
+                                       }
+                                       break;
+                               case DIR_WEST:
+                                       if (r2.x > r1_max.x) {
+                                               return false;
+                                       }
+                                       break;
+                               case DIR_SOUTH:
+                                       if (r2_max.y < r1.y) {
+                                               return false;
+                                       }
+                                       break;
+                               case DIR_EAST:
+                                       if (r2_max.x < r1.x) {
+                                               return false;
+                                       }
+                                       break;
+                               default:
+                                       return false;
                        }
                        break;
-               case DIR_WEST:
-                       if (r2.x > r1_max.x) {
-                               return false;
-                       }
-                       break;
-               case DIR_SOUTH:
-                       if (r2_max.y < r1.y) {
-                               return false;
-                       }
-                       break;
-               case DIR_EAST:
-                       if (r2_max.x < r1.x) {
-                               return false;
+               case TIGHTNESS_HIGH:
+                       switch (dir) {
+                               case DIR_NORTH:
+                                       if (r2.y >= r1.y) {
+                                               return false;
+                                       }
+                                       break;
+                               case DIR_WEST:
+                                       if (r2.x >= r1.x) {
+                                               return false;
+                                       }
+                                       break;
+                               case DIR_SOUTH:
+                                       if (r2_max.y <= r1_max.y) {
+                                               return false;
+                                       }
+                                       break;
+                               case DIR_EAST:
+                                       if (r2_max.x <= r1_max.x) {
+                                               return false;
+                                       }
+                                       break;
+                               default:
+                                       return false;
                        }
                        break;
                default:
index 23d29fbcaa9e4b6b6d29481c6bea98a1fdf4f25c..0f82c329df095fa6142d54647de426b2323369ab 100644 (file)
@@ -47,6 +47,7 @@
 #define LAYOUT_STR(A)     ((A) == LAYOUT_TILED ? "tiled" : "monocle")
 #define LAYOUT_CHR(A)     ((A) == LAYOUT_TILED ? 'T' : 'M')
 #define CHILD_POL_STR(A)  ((A) == FIRST_CHILD ? "first_child" : "second_child")
+#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")
 #define SPLIT_DIR_STR(A)  ((A) == DIR_NORTH ? "north" : ((A) == DIR_WEST ? "west" : ((A) == DIR_SOUTH ? "south" : "east")))
index a1934e6696bd15c3103211018ccfdb0883c274a7..e8edb99e6897e5e14f4b61ac26e7eba669d36788 100644 (file)
@@ -1454,6 +1454,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("directional_focus_tightness", name)) {
+               tightness_t p;
+               if (parse_tightness(value, &p)) {
+                       directional_focus_tightness = p;
+               } else {
+                       fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
+                       return;
+               }
        } else if (streq("pointer_modifier", name)) {
                if (parse_modifier_mask(value, &pointer_modifier)) {
                        ungrab_buttons();
@@ -1609,6 +1617,8 @@ void get_setting(coordinates_t loc, char *name, FILE* rsp)
                fprintf(rsp, "%s", status_prefix);
        } else if (streq("initial_polarity", name)) {
                fprintf(rsp, "%s", CHILD_POL_STR(initial_polarity));
+       } else if (streq("directional_focus_tightness", name)) {
+               fprintf(rsp, "%s", TIGHTNESS_STR(directional_focus_tightness));
        } else if (streq("pointer_modifier", name)) {
                print_modifier_mask(pointer_modifier, rsp);
        } else if (streq("pointer_motion_interval", name)) {
index c5328e8ee47566966dbb83852c08791daaf84d6d..97c2ab9a7fa0737296661654abb32fc816d6e721 100644 (file)
@@ -246,6 +246,18 @@ bool parse_child_polarity(char *s, child_polarity_t *p)
        return false;
 }
 
+bool parse_tightness(char *s, tightness_t *t)
+{
+       if (streq("high", s)) {
+               *t = TIGHTNESS_HIGH;
+               return true;
+       } else if (streq("low", s)) {
+               *t = TIGHTNESS_LOW;
+               return true;
+       }
+       return false;
+}
+
 bool parse_degree(char *s, int *d)
 {
        int i = atoi(s);
index bb257998293feb7820286df5c653816bbdd6730f..bf16c2f780be03484543919746900bfd7b9a884a 100644 (file)
@@ -24,6 +24,7 @@ bool parse_resize_handle(char *s, resize_handle_t *h);
 bool parse_modifier_mask(char *s, uint16_t *m);
 bool parse_pointer_action(char *s, pointer_action_t *a);
 bool parse_child_polarity(char *s, child_polarity_t *p);
+bool parse_tightness(char *s, tightness_t *t);
 bool parse_degree(char *s, int *d);
 bool parse_id(char *s, uint32_t *id);
 bool parse_bool_declaration(char *s, char **key, bool *value, alter_state_t *state);
index 82090d4e147710dd00eb844c7d99ce02fd2a0d37..a97267eb88ba67624f41b34ee1f70b2a4d45bdc7 100644 (file)
@@ -57,6 +57,7 @@ void load_settings(void)
        border_width = BORDER_WIDTH;
        split_ratio = SPLIT_RATIO;
        initial_polarity = FIRST_CHILD;
+       directional_focus_tightness = TIGHTNESS_HIGH;
        pointer_modifier = POINTER_MODIFIER;
        pointer_motion_interval = POINTER_MOTION_INTERVAL;
 
index f8ed182a2d3878f5b4c7fc754a7b4a9147d78f88..5845f05400abfbf4fcfb42306c0fee630bc2fb61 100644 (file)
@@ -75,6 +75,7 @@ unsigned int border_width;
 double split_ratio;
 
 child_polarity_t initial_polarity;
+tightness_t directional_focus_tightness;
 uint16_t pointer_modifier;
 uint32_t pointer_motion_interval;
 pointer_action_t pointer_actions[3];
index 0d2264303b40a46c352a7d93e5fac78321c031fa..620bf5a776c8937e5d4eae7f0f52113b0de04e6f 100644 (file)
@@ -139,6 +139,11 @@ typedef enum {
        SECOND_CHILD
 } child_polarity_t;
 
+typedef enum {
+       TIGHTNESS_LOW,
+       TIGHTNESS_HIGH,
+} tightness_t;
+
 typedef struct {
        option_bool_t automatic;
        option_bool_t focused;