Handle mapping notify events

Fixes #766.
This commit is contained in:
Bastien Dejean 2018-03-07 15:13:06 +01:00
parent 8d96affaf4
commit 582a843128
10 changed files with 50 additions and 5 deletions

View 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=()

View 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'

View 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 \

View 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\&.

View 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.

View 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;

View 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

View 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)) {

View 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;

View 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;