From 0a98de6624d4aa74ef6098754976a08bcc0a182d Mon Sep 17 00:00:00 2001 From: Bastien Dejean Date: Sat, 28 May 2016 09:43:05 +0200 Subject: [PATCH] Add setting: pointer_motion_interval Fixes #482. --- contrib/bash_completion | 2 +- contrib/fish_completion | 2 +- contrib/zsh_completion | 2 +- doc/bspwm.1 | 11 ++++++++--- doc/bspwm.1.asciidoc | 3 +++ messages.c | 7 +++++++ pointer.c | 4 ++-- settings.c | 1 + settings.h | 14 ++++++++------ 9 files changed, 32 insertions(+), 14 deletions(-) diff --git a/contrib/bash_completion b/contrib/bash_completion index 0654f1f..c04fa57 100644 --- a/contrib/bash_completion +++ b/contrib/bash_completion @@ -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_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus 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 borderless_monocle gapless_monocle single_monocle pointer_motion_interval pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus 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=() diff --git a/contrib/fish_completion b/contrib/fish_completion index 6488d11..eb936f8 100644 --- a/contrib/fish_completion +++ b/contrib/fish_completion @@ -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_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus 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 borderless_monocle gapless_monocle single_monocle pointer_motion_interval pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus 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' diff --git a/contrib/zsh_completion b/contrib/zsh_completion index c8eaee8..57281d8 100644 --- a/contrib/zsh_completion +++ b/contrib/zsh_completion @@ -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_modifier' 'pointer_action1' 'pointer_action2' 'pointer_action3' 'click_to_focus' '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' 'borderless_monocle' 'gapless_monocle' 'single_monocle' 'pointer_motion_interval' 'pointer_modifier' 'pointer_action1' 'pointer_action2' 'pointer_action3' 'click_to_focus' '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 diff --git a/doc/bspwm.1 b/doc/bspwm.1 index 8bd250e..7e66d33 100644 --- a/doc/bspwm.1 +++ b/doc/bspwm.1 @@ -2,12 +2,12 @@ .\" Title: bspwm .\" Author: [see the "Author" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 -.\" Date: 05/24/2016 +.\" Date: 05/28/2016 .\" Manual: Bspwm Manual -.\" Source: Bspwm 0.9.1-78-gfd6d090 +.\" Source: Bspwm 0.9.1-80-g4583587 .\" Language: English .\" -.TH "BSPWM" "1" "05/24/2016" "Bspwm 0\&.9\&.1\-78\-gfd6d090" "Bspwm Manual" +.TH "BSPWM" "1" "05/28/2016" "Bspwm 0\&.9\&.1\-80\-g4583587" "Bspwm Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -1065,6 +1065,11 @@ Set the desktop layout to if there\(cqs only one tiled window in the tree\&. .RE .PP +\fIpointer_motion_interval\fR +.RS 4 +The minimum interval, in milliseconds, between two motion notify events\&. +.RE +.PP \fIpointer_modifier\fR .RS 4 Keyboard modifier used for moving or resizing windows\&. Accept the following values: diff --git a/doc/bspwm.1.asciidoc b/doc/bspwm.1.asciidoc index c2ba4c5..3282069 100644 --- a/doc/bspwm.1.asciidoc +++ b/doc/bspwm.1.asciidoc @@ -630,6 +630,9 @@ Global Settings 'single_monocle':: Set the desktop layout to *monocle* if there's only one tiled window in the tree. +'pointer_motion_interval':: + The minimum interval, in milliseconds, between two motion notify events. + 'pointer_modifier':: Keyboard modifier used for moving or resizing windows. Accept the following values: *shift*, *control*, *lock*, *mod1*, *mod2*, *mod3*, *mod4*, *mod5*. diff --git a/messages.c b/messages.c index 1a92558..d0739c6 100644 --- a/messages.c +++ b/messages.c @@ -1435,6 +1435,11 @@ 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_motion_interval", name)) { + if (sscanf(value, "%u", &pointer_motion_interval) != 1) { + 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)) { @@ -1568,6 +1573,8 @@ void get_setting(coordinates_t loc, char *name, FILE* rsp) fprintf(rsp, "%s", CHILD_POL_STR(initial_polarity)); } else if (streq("pointer_modifier", name)) { print_modifier_mask(pointer_modifier, rsp); + } else if (streq("pointer_motion_interval", name)) { + fprintf(rsp, "%u", pointer_motion_interval); } else if (streq("pointer_action1", name) || streq("pointer_action2", name) || streq("pointer_action3", name)) { diff --git a/pointer.c b/pointer.c index 284875e..a132e66 100644 --- a/pointer.c +++ b/pointer.c @@ -239,8 +239,8 @@ void track_pointer(coordinates_t loc, pointer_action_t pac, xcb_point_t pos) uint8_t resp_type = XCB_EVENT_RESPONSE_TYPE(evt); if (resp_type == XCB_MOTION_NOTIFY) { xcb_motion_notify_event_t *e = (xcb_motion_notify_event_t*) evt; - int64_t dtime = e->time - last_motion_time; - if (dtime < 20) { + uint32_t dtime = e->time - last_motion_time; + if (dtime < pointer_motion_interval) { continue; } last_motion_time = e->time; diff --git a/settings.c b/settings.c index 7e509dd..1af156a 100644 --- a/settings.c +++ b/settings.c @@ -56,6 +56,7 @@ void load_settings(void) split_ratio = SPLIT_RATIO; initial_polarity = FIRST_CHILD; pointer_modifier = POINTER_MODIFIER; + pointer_motion_interval = POINTER_MOTION_INTERVAL; pointer_actions[0] = ACTION_MOVE; pointer_actions[1] = ACTION_RESIZE_SIDE; diff --git a/settings.h b/settings.h index c4075d9..47ebb6e 100644 --- a/settings.h +++ b/settings.h @@ -27,12 +27,13 @@ #include "types.h" -#define WM_NAME "bspwm" -#define CONFIG_NAME WM_NAME "rc" -#define CONFIG_HOME_ENV "XDG_CONFIG_HOME" -#define POINTER_MODIFIER XCB_MOD_MASK_4 -#define EXTERNAL_RULES_COMMAND "" -#define STATUS_PREFIX "W" +#define WM_NAME "bspwm" +#define CONFIG_NAME WM_NAME "rc" +#define CONFIG_HOME_ENV "XDG_CONFIG_HOME" +#define POINTER_MODIFIER XCB_MOD_MASK_4 +#define POINTER_MOTION_INTERVAL 17 +#define EXTERNAL_RULES_COMMAND "" +#define STATUS_PREFIX "W" #define NORMAL_BORDER_COLOR "#30302f" #define ACTIVE_BORDER_COLOR "#474645" @@ -74,6 +75,7 @@ double split_ratio; child_polarity_t initial_polarity; uint16_t pointer_modifier; +uint32_t pointer_motion_interval; pointer_action_t pointer_actions[3]; bool borderless_monocle;