#ifndef __LABWC_MOUSEBIND_H
#define __LABWC_MOUSEBIND_H
+#include "ssd.h"
#include <wayland-util.h>
-enum mouse_context {
- MOUSE_CONTEXT_TITLEBAR,
- MOUSE_CONTEXT_NONE
-};
-
-enum mouse_button {
- /*
- * These values match the values returned by button event->button and were
- * obtained experimentally
- */
- MOUSE_BUTTON_LEFT = 272,
- MOUSE_BUTTON_RIGHT = 273,
- MOUSE_BUTTON_MIDDLE = 274,
- MOUSE_BUTTON_NONE = -1
-};
-
enum action_mouse_did {
MOUSE_ACTION_DOUBLECLICK,
MOUSE_ACTION_NONE
};
struct mousebind {
- enum mouse_context context; /* ex: titlebar */
- enum mouse_button button; /* ex: left, right, middle */
+ enum ssd_part_type context; /* ex: titlebar */
+ uint32_t button; /* ex: BTN_LEFT, BTN_RIGHT from linux/input_event_codes.h */
enum action_mouse_did mouse_action; /* ex: doubleclick, press, drag, etc */
const char* action; /* what to do because mouse did previous action */
const char* command;
#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;
}
}
{
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;
}
if (is_double_click(rc.doubleclick_time) && view_area == LAB_SSD_PART_TITLEBAR) {
struct mousebind* mousebind;
wl_list_for_each_reverse(mousebind, &rc.mousebinds, link) {
- if( (mousebind->context == MOUSE_CONTEXT_TITLEBAR) &&
+ if( (mousebind->context == LAB_SSD_PART_TITLEBAR) &&
(mousebind->mouse_action == MOUSE_ACTION_DOUBLECLICK) &&
- (mousebind->button == (enum mouse_button)event->button) ) {
+ (mousebind->button == event->button) ) {
action(server, mousebind->action, mousebind->command);
}
}