Only grab scrollwheel buttons if necessary.

With this patch, we only grab the scrollwheel buttons (4 and 5) when
managing a window if a whole window key binding exists for these buttons.

This allows both of these usecases:
  - Bindings to scrollwheel buttons using --whole-window (see #1701).
  - Scrolling in a window without focusing it if no such binding
    exists (see #2049).

Furthermore, we drop all button grabs and regrab them after a config
reload in order to reevaluate the new bindings correctly.

fixes #2049
This commit is contained in:
Ingo Bürk
2015-11-11 20:40:25 +01:00
parent 66882bf445
commit 029d78c0bf
6 changed files with 83 additions and 4 deletions

View File

@ -33,6 +33,13 @@ Binding *configure_binding(const char *bindtype, const char *modifiers, const ch
*/
void grab_all_keys(xcb_connection_t *conn);
/**
* Release the button grabs on all managed windows and regrab them,
* reevaluating which buttons need to be grabbed.
*
*/
void regrab_all_buttons(xcb_connection_t *conn);
/**
* Returns a pointer to the Binding that matches the given xcb event or NULL if
* no such binding exists.
@ -95,3 +102,12 @@ CommandResult *run_binding(Binding *bind, Con *con);
*
*/
bool load_keymap(void);
/**
* Returns true if the current config has any binding to a scroll wheel button
* (4 or 5) which is a whole-window binding.
* We need this to figure out whether we should grab all buttons or just 1-3
* when managing a window. See #2049.
*
*/
bool bindings_should_grab_scrollwheel_buttons(void);