]> git.lizzy.rs Git - bspwm.git/commitdiff
Make mouse button actions configurable
authorCampbell Barton <ideasman42@gmail.com>
Sun, 10 Apr 2016 16:53:05 +0000 (02:53 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 10 Apr 2016 20:03:50 +0000 (06:03 +1000)
Previously this was possible via key bindings, since this operation was removed,
its useful to be able to configure which mouse keys do what.

This example swaps LMB/RMB

```
bspc config pointer_action1 resize_corner
bspc config pointer_action3 move
```

contrib/bash_completion
contrib/zsh_completion
doc/bspwm.1
doc/bspwm.1.asciidoc
events.c
messages.c
settings.c
settings.h

index 99efd9853cc6aa77cb46ef610d2d0c9ab131a30a..7086116074ae227790f2ac0ec97050ce539bea2d 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 leaf_monocle pointer_modifier click_to_focus focus_follows_pointer pointer_follows_focus pointer_follows_monitor history_aware_focus focus_by_distance 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 borderless_monocle gapless_monocle leaf_monocle pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus focus_follows_pointer pointer_follows_focus pointer_follows_monitor history_aware_focus focus_by_distance ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
 
        COMPREPLY=()
 
index fbcbc853d1c1e3c193dde349d2b7a798170f6bfc..ab08a0e895cfdd907c3cb9adc9fd1a22bff51f4b 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' 'leaf_monocle' 'pointer_modifier' 'click_to_focus' 'focus_follows_pointer' 'pointer_follows_focus' 'pointer_follows_monitor' 'history_aware_focus' 'focus_by_distance' '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' 'borderless_monocle' 'gapless_monocle' 'leaf_monocle' 'pointer_modifier' 'pointer_action1' 'pointer_action2' 'pointer_action3' 'click_to_focus' 'focus_follows_pointer' 'pointer_follows_focus' 'pointer_follows_monitor' 'history_aware_focus' 'focus_by_distance' '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 b4f9fd1e90f10c9fc809237166b6cb05237f974e..4c55a514f71b6c41ca00ca1b9e82995ab3d61021 100644 (file)
@@ -1058,6 +1058,15 @@ Keyboard modifier used for moving or resizing windows\&. Accept the following va
 \fBmod5\fR\&.
 .RE
 .PP
+\fIpointer_action1\fR, \fIpointer_action2\fR, \fIpointer_action3\fR
+.RS 4
+Action performed when pressing mouse buttons 1,2 & 3\&. Accept the following values:
+\fBmove\fR,
+\fBresize_side\fR,
+\fBresize_corner\fR,
+\fBfocus\fR\&.
+.RE
+.PP
 \fIclick_to_focus\fR
 .RS 4
 Focus a window (or a monitor) by clicking it\&.
index e324f793c1ff77ffe2dad1def6a433399fee84d0..3087d67b8ae6e27658de2b7b1fcd55a5a46f81fe 100644 (file)
@@ -613,6 +613,9 @@ Global Settings
 'pointer_modifier'::
        Keyboard modifier used for moving or resizing windows. Accept the following values: *shift*, *control*, *lock*, *mod1*, *mod2*, *mod3*, *mod4*, *mod5*.
 
+'pointer_action1', 'pointer_action2', 'pointer_action3'::
+       Action performed when pressing mouse buttons 1,2 & 3. Accept the following values: *move*, *resize_side*, *resize_corner*, *focus*.
+
 'click_to_focus'::
        Focus a window (or a monitor) by clicking it.
 
index e2095d3cbede4a992ad557d818c602763b51401d..42f9805bb1f17bcaa2930a85eb4aa271c1e5c281 100644 (file)
--- a/events.c
+++ b/events.c
@@ -317,14 +317,14 @@ void button_press(xcb_generic_event_t *evt)
                                xcb_flush(dpy);
                                grab_pointer(ACTION_FOCUS);
                        } else {
-                               grab_pointer(ACTION_MOVE);
+                               grab_pointer(pointer_actions[0]);
                        }
                        break;
                case XCB_BUTTON_INDEX_2:
-                       grab_pointer(ACTION_RESIZE_SIDE);
+                       grab_pointer(pointer_actions[1]);
                        break;
                case XCB_BUTTON_INDEX_3:
-                       grab_pointer(ACTION_RESIZE_CORNER);
+                       grab_pointer(pointer_actions[2]);
                        break;
        }
 }
index 903b96ad4025b7e986ccb627dd3f1c5193df3577..f974c353868fc3ed235cda31144c88f082a0b551 100644 (file)
@@ -1389,6 +1389,17 @@ 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("pointer_action1", name) ||
+                  streq("pointer_action2", name) ||
+                  streq("pointer_action3", name)) {
+               int index = name[14] - '1';
+               if (parse_pointer_action(value, &pointer_actions[index])) {
+                       ungrab_buttons();
+                       grab_buttons();
+               } else {
+                       fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
+                       return;
+               }
        } else if (streq("click_to_focus", name)) {
                if (parse_bool(value, &click_to_focus)) {
                        ungrab_buttons();
index 1d988c8a1029bd1ea4766713fd137682e0e5e791..3d40075beee23999f4f1d4e737b0807268bc2139 100644 (file)
@@ -57,6 +57,10 @@ void load_settings(void)
        initial_polarity = FIRST_CHILD;
        pointer_modifier = POINTER_MODIFIER;
 
+       pointer_actions[0] = ACTION_MOVE;
+       pointer_actions[1] = ACTION_RESIZE_SIDE;
+       pointer_actions[2] = ACTION_RESIZE_CORNER;
+
        borderless_monocle = BORDERLESS_MONOCLE;
        gapless_monocle = GAPLESS_MONOCLE;
        paddingless_monocle = PADDINGLESS_MONOCLE;
index ea4dbbcf216866d60566fe332f1236b946068fea..375d8da0b1ecc8e77de6caaa4f6f12c99c79471f 100644 (file)
@@ -77,6 +77,7 @@ double split_ratio;
 
 child_polarity_t initial_polarity;
 uint16_t pointer_modifier;
+pointer_action_t pointer_actions[3];
 
 bool borderless_monocle;
 bool gapless_monocle;