change mousebind code to use already existing enums

Also added an #include statement to ssd.h so it would compile without
depending on other headers to be #included before it
This commit is contained in:
alex 2021-08-30 18:42:38 -04:00 committed by Johan Malm
parent 36f5b49f2a
commit 92891b4dfa
4 changed files with 22 additions and 34 deletions

View file

@ -4,34 +4,35 @@
#include <wlr/util/log.h>
#include <strings.h>
#include <unistd.h>
#include <linux/input-event-codes.h>
static enum mouse_context
static enum ssd_part_type
context_from_str(const char* str)
{
if(str == NULL) {
return MOUSE_CONTEXT_NONE;
return LAB_SSD_NONE;
}
else if(strcasecmp(str, "Titlebar") == 0) {
return MOUSE_CONTEXT_TITLEBAR;
return LAB_SSD_PART_TITLEBAR;
} else {
return MOUSE_CONTEXT_NONE;
return LAB_SSD_NONE;
}
}
static enum mouse_button
static uint32_t
mouse_button_from_str(const char* str)
{
if(str == NULL) {
return MOUSE_BUTTON_NONE;
return UINT32_MAX;
}
else if(strcasecmp(str, "Left") == 0) {
return MOUSE_BUTTON_LEFT;
return BTN_LEFT;
} else if(strcasecmp(str, "Right") == 0) {
return MOUSE_BUTTON_RIGHT;
return BTN_RIGHT;
} else if(strcasecmp(str, "Middle") == 0) {
return MOUSE_BUTTON_MIDDLE;
return BTN_MIDDLE;
} else {
return MOUSE_BUTTON_NONE;
return UINT32_MAX;
}
}
@ -55,15 +56,15 @@ mousebind_create(const char* context_str, const char* mouse_button_str,
{
struct mousebind* m = calloc(1, sizeof(struct mousebind));
enum mouse_context context = context_from_str(context_str);
enum mouse_button button = mouse_button_from_str(mouse_button_str);
enum ssd_part_type context = context_from_str(context_str);
uint32_t button = mouse_button_from_str(mouse_button_str);
enum action_mouse_did action_mouse_did = action_mouse_did_from_str(action_mouse_did_str);
if(context == MOUSE_CONTEXT_NONE) {
if(context == LAB_SSD_NONE) {
wlr_log(WLR_ERROR, "unknown mouse context (%s)", context_str);
goto CREATE_ERROR;
}
if(button == MOUSE_BUTTON_NONE) {
if(button == UINT32_MAX) {
wlr_log(WLR_ERROR, "unknown button (%s)", mouse_button_str);
goto CREATE_ERROR;
}