parse and respect modifiers for mouse bindings

This commit is contained in:
bi4k8 2021-12-01 02:32:24 +00:00 committed by ARDiDo
parent c34a2fc976
commit 8eab1e8132
4 changed files with 31 additions and 10 deletions

View file

@ -9,9 +9,22 @@
#include "config/rcxml.h"
uint32_t
mousebind_button_from_str(const char *str)
mousebind_button_from_str(const char *str, uint32_t *modifiers)
{
assert(str);
if (modifiers) {
*modifiers = 0;
while (strlen(str) >= 2 && str[1] == '-') {
char modname[2] = {str[0], 0};
uint32_t parsed_modifier = parse_modifier(modname);
if (!parsed_modifier)
goto invalid;
*modifiers |= parsed_modifier;
str += 2;
}
}
if (!strcasecmp(str, "Left")) {
return BTN_LEFT;
} else if (!strcasecmp(str, "Right")) {
@ -19,6 +32,7 @@ mousebind_button_from_str(const char *str)
} else if (!strcasecmp(str, "Middle")) {
return BTN_MIDDLE;
}
invalid:
wlr_log(WLR_ERROR, "unknown button (%s)", str);
return UINT32_MAX;
}