diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2019-01-15 21:25:28 -0500 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-01-16 11:12:45 +0100 |
commit | 02bbefda20b9a4f86e740d33bbaa21c661bb2fac (patch) | |
tree | 1b753e414749374be1e144a326a744c4b6812480 /sway/commands/bar/tray_bindsym.c | |
parent | 247817f68c69c8f4533d948502ae300520dcad59 (diff) |
bar_cmd_tray_bind: Use mouse button helpers
This modifies `bar_cmd_tray_bindsym` to use `get_mouse_bindsym` for
parsing mouse buttons. This also introduces `bar_cmd_tray_bindcode`,
which will use `get_mouse_bindcode` for parsing mouse buttons. Like with
sway bindings, the two commands are encapsulated in a single file to
maximize shared code.
This also modifies tray bindings to work off of events codes rather than
x11 buttons, which allows for any mouse buttons to be used.
For `get_bar_config`, `event_code` has been added to the `tray_bindings`
section and will include to event code for the button. If the event code
can be mapped to a x11 button, `input_code` will still be the x11 button
number. Otherwise, `input_code` will be `0`.
Diffstat (limited to 'sway/commands/bar/tray_bindsym.c')
-rw-r--r-- | sway/commands/bar/tray_bindsym.c | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/sway/commands/bar/tray_bindsym.c b/sway/commands/bar/tray_bindsym.c deleted file mode 100644 index 4e57e35e..00000000 --- a/sway/commands/bar/tray_bindsym.c +++ /dev/null @@ -1,55 +0,0 @@ -#include <strings.h> -#include "config.h" -#include "sway/commands.h" -#include "sway/config.h" -#include "log.h" - -struct cmd_results *bar_cmd_tray_bindsym(int argc, char **argv) { -#if HAVE_TRAY - struct cmd_results *error = NULL; - if ((error = checkarg(argc, "tray_bindsym", EXPECTED_EQUAL_TO, 2))) { - return error; - } - - if (!config->current_bar) { - return cmd_results_new(CMD_FAILURE, "No bar defined."); - } - - int button = 0; - if (strncasecmp(argv[0], "button", strlen("button")) == 0 && - strlen(argv[0]) == strlen("button0")) { - button = argv[0][strlen("button")] - '0'; - } - if (button < 1 || button > 9) { - return cmd_results_new(CMD_FAILURE, - "[Bar %s] Only buttons 1 to 9 are supported", - config->current_bar->id); - } - - static const char *commands[] = { - "ContextMenu", - "Activate", - "SecondaryActivate", - "ScrollDown", - "ScrollLeft", - "ScrollRight", - "ScrollUp", - "nop" - }; - - for (size_t i = 0; i < sizeof(commands) / sizeof(commands[0]); ++i) { - if (strcasecmp(argv[1], commands[i]) == 0) { - wlr_log(WLR_DEBUG, "[Bar %s] Binding button %d to %s", - config->current_bar->id, button, commands[i]); - config->current_bar->tray_bindings[button] = commands[i]; - return cmd_results_new(CMD_SUCCESS, NULL); - } - } - - return cmd_results_new(CMD_INVALID, - "[Bar %s] Invalid command %s", config->current_bar->id, argv[1]); -#else - return cmd_results_new(CMD_INVALID, - "Sway has been compiled without tray support"); -#endif -} |