]> git.lizzy.rs Git - bspwm.git/commitdiff
Handle mapping notify events
authorBastien Dejean <nihilhill@gmail.com>
Wed, 7 Mar 2018 14:13:06 +0000 (15:13 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Wed, 7 Mar 2018 14:13:06 +0000 (15:13 +0100)
Fixes #766.

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

index f82a752fb0fe96046a09b239203d1acdac6ca05b..d8c41e7b2c1e0e5bdd4be28305f39ec07a777a1d 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 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'
+       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 mapping_events_count ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
 
        COMPREPLY=()
 
index 5add99cc457a6793265a6a13c709abf18b5e708f..b1c37c9cbfc745cdaa21d006da5c29b057d16228 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 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'
+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 mapping_events_count ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
index 673141e6a06995290c2e9aafc0e524261a1f3206..cc97da3bdd605ec131f9f7e5d2bf971c27ccec09 100644 (file)
@@ -315,7 +315,7 @@ _bspc() {
                        local -a look behaviour input
                        # Boolean settings are identified by index!
                        look=(borderless_monocle gapless_monocle {normal,active,focused}_border_color {top,right,bottom,left}_padding presel_feedback_color border_width window_gap)
-                       behaviour=(single_monocle ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors status_prefix external_rules_command split_ratio initial_polarity directional_focus_tightness status_prefix)
+                       behaviour=(single_monocle mapping_events_count ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors status_prefix external_rules_command split_ratio initial_polarity directional_focus_tightness status_prefix)
                        input=({swallow_first_click,focus_follows_pointer,pointer_follows_{focus,monitor}} click_to_focus pointer_motion_interval pointer_modifier pointer_action{1,2,3} )
                        if [[ "$CURRENT" == (2|3) ]];then
                                _arguments \
index 104223a7ebce88bf7eaf8603ae63e57afb4f7e20..a4d7187157867d70f075bd3d64d3b5c7eb2d46ab 100644 (file)
@@ -4,10 +4,10 @@
 .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
 .\"      Date: 03/07/2018
 .\"    Manual: Bspwm Manual
-.\"    Source: Bspwm 0.9.3-55-g7d639d1
+.\"    Source: Bspwm 0.9.3-56-g8d96aff
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "03/07/2018" "Bspwm 0\&.9\&.3\-55\-g7d639d1" "Bspwm Manual"
+.TH "BSPWM" "1" "03/07/2018" "Bspwm 0\&.9\&.3\-56\-g8d96aff" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1254,6 +1254,13 @@ When focusing a window, put the pointer at its center\&.
 When focusing a monitor, put the pointer at its center\&.
 .RE
 .PP
+\fImapping_events_count\fR
+.RS 4
+Handle the next
+\fBmapping_events_count\fR
+mapping notify events\&. A negative value implies that every event needs to be handled\&.
+.RE
+.PP
 \fIignore_ewmh_focus\fR
 .RS 4
 Ignore EWMH focus requests coming from applications\&.
index 376ddf04e7f949375a0859d161411dfd7ac996f3..71ea387ff95f980a9fc7c50093bd87871acfa782 100644 (file)
@@ -718,6 +718,9 @@ Global Settings
 'pointer_follows_monitor'::
        When focusing a monitor, put the pointer at its center.
 
+'mapping_events_count'::
+       Handle the next *mapping_events_count* mapping notify events. A negative value implies that every event needs to be handled.
+
 'ignore_ewmh_focus'::
        Ignore EWMH focus requests coming from applications.
 
index 64a9f76637600fb195cae3c705e77b658edfbfae..7984a7eaac1b6ba2562ad9f796ed60ce9f0df0b4 100644 (file)
@@ -71,6 +71,9 @@ void handle_event(xcb_generic_event_t *evt)
                case XCB_FOCUS_IN:
                        focus_in(evt);
                        break;
+               case XCB_MAPPING_NOTIFY:
+                       mapping_notify(evt);
+                       break;
                case 0:
                        process_error(evt);
                        break;
@@ -519,6 +522,26 @@ void handle_state(monitor_t *m, desktop_t *d, node_t *n, xcb_atom_t state, unsig
 #undef HANDLE_WM_STATE
 }
 
+void mapping_notify(xcb_generic_event_t *evt)
+{
+       if (mapping_events_count == 0) {
+               return;
+       }
+
+       xcb_mapping_notify_event_t *e = (xcb_mapping_notify_event_t *) evt;
+
+       if (e->request == XCB_MAPPING_POINTER) {
+               return;
+       }
+
+       if (mapping_events_count > 0) {
+               mapping_events_count--;
+       }
+
+       ungrab_buttons();
+       grab_buttons();
+}
+
 void process_error(xcb_generic_event_t *evt)
 {
        xcb_request_error_t *e = (xcb_request_error_t *) evt;
index ff47830687f45afbde64af29ebe18164c4f6499a..d450965e64d617388d769c69bce7359b06ffa9d0 100644 (file)
@@ -46,6 +46,7 @@ void button_press(xcb_generic_event_t *evt);
 void enter_notify(xcb_generic_event_t *evt);
 void motion_notify(xcb_generic_event_t *evt);
 void handle_state(monitor_t *m, desktop_t *d, node_t *n, xcb_atom_t state, unsigned int action);
+void mapping_notify(xcb_generic_event_t *evt);
 void process_error(xcb_generic_event_t *evt);
 
 #endif
index f6999acf0630037434094b3844f940527996ea7b..6d9d970323cb749178496157d03ff2b29845a720 100644 (file)
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <stdbool.h>
 #include <stdarg.h>
+#include <inttypes.h>
 #include <unistd.h>
 #include "bspwm.h"
 #include "desktop.h"
@@ -1554,6 +1555,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("mapping_events_count", name)) {
+               if (sscanf(value, "%" SCNi8, &mapping_events_count) != 1) {
+                       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)) {
@@ -1717,6 +1723,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("mapping_events_count", name)) {
+               fprintf(rsp, "%" PRIi8, mapping_events_count);
        } else if (streq("directional_focus_tightness", name)) {
                fprintf(rsp, "%s", TIGHTNESS_STR(directional_focus_tightness));
        } else if (streq("pointer_modifier", name)) {
index 880aebeb512b0d580212e39738a7e2a1e5f08418..857340956ef9038d68f177e657614e59c2f76620 100644 (file)
@@ -60,6 +60,7 @@ void load_settings(void)
        directional_focus_tightness = TIGHTNESS_HIGH;
        pointer_modifier = POINTER_MODIFIER;
        pointer_motion_interval = POINTER_MOTION_INTERVAL;
+       mapping_events_count = MAPPING_EVENTS_COUNT;
 
        pointer_actions[0] = ACTION_MOVE;
        pointer_actions[1] = ACTION_RESIZE_SIDE;
index cb5cf4765fc098ae181811764e16c51196c4a292..df59e56272a3b00b2d36fc11e8d60e12d8c3122d 100644 (file)
@@ -56,6 +56,7 @@
 
 #define CENTER_PSEUDO_TILED         true
 #define HONOR_SIZE_HINTS            false
+#define MAPPING_EVENTS_COUNT        1
 
 #define REMOVE_DISABLED_MONITORS    false
 #define REMOVE_UNPLUGGED_MONITORS   false
@@ -79,6 +80,7 @@ tightness_t directional_focus_tightness;
 uint16_t pointer_modifier;
 uint32_t pointer_motion_interval;
 pointer_action_t pointer_actions[3];
+int8_t mapping_events_count;
 
 bool borderless_monocle;
 bool gapless_monocle;