From 754372c3de1f5b357850cb58cc8ddc1aee596bd6 Mon Sep 17 00:00:00 2001 From: frsfnrrg Date: Tue, 17 Jul 2018 22:01:06 -0400 Subject: Parse mouse binding options First, the existing sway_binding structure is given an enumerated type code. As all flags to bindsym/bindcode are boolean, a single uint32 is used to hold all flags. The _BORDER, _CONTENTS, _TITLEBAR flags, when active, indicate in which part of a container the binding can trigger; to localize complexity, they do not overlap with the command line arguments, which center around _TITLEBAR being set by default. The keyboard handling code is adjusted for this change, as is binding_key_compare; note that BINDING_LOCKED is *not* part of the key portion of the binding. Next, list of mouse bindings is introduced and cleaned up. Finally, the binding command parsing code is extended to handle the case where bindsym is used to describe a mouse binding rather than a keysym binding; the difference between the two may be detected as late as when the first key/button is parsed, or as early as the first flag. As bindings can have multiple keycodes/keysyms/buttons, mixed keysym/button sequences are prohibited. --- include/sway/config.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'include/sway') diff --git a/include/sway/config.h b/include/sway/config.h index b8da29c5..92536d10 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -22,14 +22,28 @@ struct sway_variable { char *value; }; + +enum binding_input_type { + BINDING_KEYCODE, + BINDING_KEYSYM, + BINDING_MOUSE, +}; + +enum binding_flags { + BINDING_RELEASE=1, + BINDING_LOCKED=2, // keyboard only + BINDING_BORDER=4, // mouse only; trigger on container border + BINDING_CONTENTS=8, // mouse only; trigger on container contents + BINDING_TITLEBAR=16 // mouse only; trigger on container titlebar +}; + /** * A key binding and an associated command. */ struct sway_binding { + enum binding_input_type type; int order; - bool release; - bool locked; - bool bindcode; + uint32_t flags; list_t *keys; // sorted in ascending order uint32_t modifiers; char *command; @@ -50,6 +64,7 @@ struct sway_mode { char *name; list_t *keysym_bindings; list_t *keycode_bindings; + list_t *mouse_bindings; bool pango; }; -- cgit v1.2.3