Refactor binding accessor

Change the primary binding accessor to `get_binding_from_xcb_event`.

This function gets a binding from a generic xcb event of type KeyPress,
KeyRelease, ButtonPress, or ButtonRelease by determining the input type
(keyboard or mouse), the modifiers pressed from the filtered event
`state`, managing the proper fall back in case mode switch is enabled,
and finally querying the bindings for a binding that matches the event.

The logic of querying keyboard bindings is not intended to be altered by
this change.

The general accessor has been slightly modified to work with mouse
bindings and made private because it is only used in bindings.c
This commit is contained in:
Tony Crisci
2014-05-02 10:22:40 -04:00
committed by Michael Stapelberg
parent c3d46c9145
commit 5fc1b5d02d
4 changed files with 91 additions and 64 deletions

View File

@ -91,6 +91,14 @@ typedef enum {
L_SPLITH = 6
} layout_t;
/**
* Binding input types. See Binding::input_type.
*/
typedef enum {
B_KEYBOARD = 0,
B_MOUSE = 1
} input_type_t;
/**
* Stores a rectangle, for example the size of a window, the child window etc.
* It needs to be packed so that the compiler will not add any padding bytes.
@ -215,12 +223,7 @@ struct regex {
struct Binding {
/* The type of input this binding is for. (Mouse bindings are not yet
* implemented. All bindings are currently assumed to be keyboard bindings.) */
enum {
/* Created with "bindsym", "bindcode", and "bind" */
B_KEYBOARD = 0,
/* Created with "bindmouse" (not yet implemented). */
B_MOUSE = 1,
} input_type;
input_type_t input_type;
/** If true, the binding should be executed upon a KeyRelease event, not a
* KeyPress (the default). */