From aa1c838f9733f9b5e90e8267a10e455790cd2642 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Thu, 10 Jan 2019 11:47:34 -0500 Subject: seat_cmd_cursor: utilize mouse button helpers This modifies `seat_cmd_cursor` to utilize `get_mouse_button` when parsing mouse buttons for the `press` and `release` operations. All x11 buttons, button event names, and button event codes are supported. For x11 axis buttons, `dispatch_cursor_axis` is used instead of `dispatch_cursor_button`. However the `press`/`release` state is ignored and the either axis event is processed. This also removes support for `left` and `right` in favor of `BTN_LEFT` and `BTN_RIGHT`. --- sway/input/cursor.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sway/input/cursor.c') diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 9af7ef57..c1c8b6bf 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -1082,11 +1082,13 @@ static uint32_t wl_axis_to_button(struct wlr_event_pointer_axis *event) { } } -static void dispatch_cursor_axis(struct sway_cursor *cursor, +void dispatch_cursor_axis(struct sway_cursor *cursor, struct wlr_event_pointer_axis *event) { struct sway_seat *seat = cursor->seat; - struct sway_input_device *input_device = event->device->data; - struct input_config *ic = input_device_get_config(input_device); + struct sway_input_device *input_device = + event->device ? event->device->data : NULL; + struct input_config *ic = + input_device ? input_device_get_config(input_device) : NULL; // Determine what's under the cursor struct wlr_surface *surface = NULL; @@ -1109,7 +1111,8 @@ static void dispatch_cursor_axis(struct sway_cursor *cursor, // Gather information needed for mouse bindings struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); uint32_t modifiers = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0; - struct wlr_input_device *device = input_device->wlr_device; + struct wlr_input_device *device = + input_device ? input_device->wlr_device : NULL; char *dev_id = device ? input_device_get_identifier(device) : strdup("*"); uint32_t button = wl_axis_to_button(event); -- cgit v1.2.3-54-g00ecf