From 400998d6d2bf311f3402faf092154ee8ceac2bf9 Mon Sep 17 00:00:00 2001 From: Josip Janzic Date: Thu, 4 May 2017 22:42:50 +0200 Subject: Add mouse button bindings Adds support for bindings like: bindsym button3 floating toggle bindsym $mod+button3 floating toggle --- sway/commands/bind.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sway/commands/bind.c') diff --git a/sway/commands/bind.c b/sway/commands/bind.c index 8282277b..af5a01e5 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c @@ -1,7 +1,9 @@ #include #include +#include #include "sway/commands.h" #include "sway/config.h" +#include "sway/input_state.h" #include "list.h" #include "log.h" #include "stringop.h" @@ -52,6 +54,12 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) { // Check for xkb key xkb_keysym_t sym = xkb_keysym_from_name(split->items[i], XKB_KEYSYM_CASE_INSENSITIVE); + + // Check for mouse binding + if (strncasecmp(split->items[i], "button", strlen("button")) == 0 && + strlen(split->items[i]) == strlen("button0")) { + sym = ((char *)split->items[i])[strlen("button")] - '1' + M_LEFT_CLICK; + } if (!sym) { free_sway_binding(binding); free_flat_list(split); -- cgit v1.2.3