From 812451cd8fd858cb2aa0630532266f229d934bf2 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 28 Feb 2024 10:26:38 +0100 Subject: [PATCH] pointer: use enum wl_pointer_button_state --- backend/libinput/pointer.c | 4 ++-- backend/x11/input_device.c | 14 +++++++------- examples/pointer.c | 2 +- include/wlr/types/wlr_pointer.h | 2 +- include/wlr/types/wlr_seat.h | 6 +++--- tinywl/tinywl.c | 2 +- types/seat/wlr_seat_pointer.c | 10 +++++----- types/wlr_virtual_pointer_v1.c | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index 01bfc190..57a2f4a3 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -69,13 +69,13 @@ void handle_pointer_button(struct libinput_event *event, uint32_t seat_count = libinput_event_pointer_get_seat_button_count(pevent); switch (libinput_event_pointer_get_button_state(pevent)) { case LIBINPUT_BUTTON_STATE_PRESSED: - wlr_event.state = WLR_BUTTON_PRESSED; + wlr_event.state = WL_POINTER_BUTTON_STATE_PRESSED; if (seat_count != 1) { return; } break; case LIBINPUT_BUTTON_STATE_RELEASED: - wlr_event.state = WLR_BUTTON_RELEASED; + wlr_event.state = WL_POINTER_BUTTON_STATE_RELEASED; if (seat_count != 0) { return; } diff --git a/backend/x11/input_device.c b/backend/x11/input_device.c index 8526ae9b..82d9c151 100644 --- a/backend/x11/input_device.c +++ b/backend/x11/input_device.c @@ -29,7 +29,7 @@ static void send_key_event(struct wlr_x11_backend *x11, uint32_t key, } static void send_button_event(struct wlr_x11_output *output, uint32_t key, - enum wlr_button_state st, xcb_timestamp_t time) { + enum wl_pointer_button_state st, xcb_timestamp_t time) { struct wlr_pointer_button_event ev = { .pointer = &output->pointer, .time_msec = time, @@ -155,15 +155,15 @@ void handle_x11_xinput_event(struct wlr_x11_backend *x11, switch (ev->detail) { case XCB_BUTTON_INDEX_1: - send_button_event(output, BTN_LEFT, WLR_BUTTON_PRESSED, + send_button_event(output, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED, ev->time); break; case XCB_BUTTON_INDEX_2: - send_button_event(output, BTN_MIDDLE, WLR_BUTTON_PRESSED, + send_button_event(output, BTN_MIDDLE, WL_POINTER_BUTTON_STATE_PRESSED, ev->time); break; case XCB_BUTTON_INDEX_3: - send_button_event(output, BTN_RIGHT, WLR_BUTTON_PRESSED, + send_button_event(output, BTN_RIGHT, WL_POINTER_BUTTON_STATE_PRESSED, ev->time); break; case XCB_BUTTON_INDEX_4: @@ -188,15 +188,15 @@ void handle_x11_xinput_event(struct wlr_x11_backend *x11, switch (ev->detail) { case XCB_BUTTON_INDEX_1: - send_button_event(output, BTN_LEFT, WLR_BUTTON_RELEASED, + send_button_event(output, BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED, ev->time); break; case XCB_BUTTON_INDEX_2: - send_button_event(output, BTN_MIDDLE, WLR_BUTTON_RELEASED, + send_button_event(output, BTN_MIDDLE, WL_POINTER_BUTTON_STATE_RELEASED, ev->time); break; case XCB_BUTTON_INDEX_3: - send_button_event(output, BTN_RIGHT, WLR_BUTTON_RELEASED, + send_button_event(output, BTN_RIGHT, WL_POINTER_BUTTON_STATE_RELEASED, ev->time); break; } diff --git a/examples/pointer.c b/examples/pointer.c index bb249b42..81529e88 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -144,7 +144,7 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { struct wlr_pointer_button_event *event = data; float (*color)[4]; - if (event->state == WLR_BUTTON_RELEASED) { + if (event->state == WL_POINTER_BUTTON_STATE_RELEASED) { color = &sample->default_color; memcpy(&sample->clear_color, color, sizeof(*color)); } else { diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h index 240b69d6..931bc046 100644 --- a/include/wlr/types/wlr_pointer.h +++ b/include/wlr/types/wlr_pointer.h @@ -63,7 +63,7 @@ struct wlr_pointer_button_event { struct wlr_pointer *pointer; uint32_t time_msec; uint32_t button; - enum wlr_button_state state; + enum wl_pointer_button_state state; }; enum wlr_axis_orientation { diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index b6d80f15..0c1f0689 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -98,7 +98,7 @@ struct wlr_pointer_grab_interface { void (*motion)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec, double sx, double sy); uint32_t (*button)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec, - uint32_t button, enum wlr_button_state state); + uint32_t button, enum wl_pointer_button_state state); void (*axis)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec, enum wlr_axis_orientation orientation, double value, int32_t value_discrete, enum wl_pointer_axis_source source, @@ -399,7 +399,7 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time_msec, * instead. */ uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, - uint32_t time_msec, uint32_t button, enum wlr_button_state state); + uint32_t time_msec, uint32_t button, enum wl_pointer_button_state state); /** * Send an axis event to the surface with pointer focus. This function does not @@ -453,7 +453,7 @@ void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, * pointer. */ uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, - uint32_t time_msec, uint32_t button, enum wlr_button_state state); + uint32_t time_msec, uint32_t button, enum wl_pointer_button_state state); /** * Notify the seat of an axis event. Defers to any grab of the pointer. diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c index ec8f3c03..bfdee90f 100644 --- a/tinywl/tinywl.c +++ b/tinywl/tinywl.c @@ -525,7 +525,7 @@ static void server_cursor_button(struct wl_listener *listener, void *data) { struct wlr_surface *surface = NULL; struct tinywl_toplevel *toplevel = desktop_toplevel_at(server, server->cursor->x, server->cursor->y, &surface, &sx, &sy); - if (event->state == WLR_BUTTON_RELEASED) { + if (event->state == WL_POINTER_BUTTON_STATE_RELEASED) { /* If you released any buttons, we exit interactive move/resize mode. */ reset_cursor_mode(server); } else { diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c index c872ddf3..72acb4b7 100644 --- a/types/seat/wlr_seat_pointer.c +++ b/types/seat/wlr_seat_pointer.c @@ -23,7 +23,7 @@ static void default_pointer_motion(struct wlr_seat_pointer_grab *grab, } static uint32_t default_pointer_button(struct wlr_seat_pointer_grab *grab, - uint32_t time, uint32_t button, enum wlr_button_state state) { + uint32_t time, uint32_t button, enum wl_pointer_button_state state) { return wlr_seat_pointer_send_button(grab->seat, time, button, state); } @@ -260,7 +260,7 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time, } uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time, - uint32_t button, enum wlr_button_state state) { + uint32_t button, enum wl_pointer_button_state state) { struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client; if (client == NULL) { return 0; @@ -453,12 +453,12 @@ void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, uint32_t time, } uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, - uint32_t time, uint32_t button, enum wlr_button_state state) { + uint32_t time, uint32_t button, enum wl_pointer_button_state state) { clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event); struct wlr_seat_pointer_state* pointer_state = &wlr_seat->pointer_state; - if (state == WLR_BUTTON_PRESSED) { + if (state == WL_POINTER_BUTTON_STATE_PRESSED) { if (pointer_state->button_count == 0) { pointer_state->grab_button = button; pointer_state->grab_time = time; @@ -475,7 +475,7 @@ uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, uint32_t serial = grab->interface->button(grab, time, button, state); if (serial && pointer_state->button_count == 1 && - state == WLR_BUTTON_PRESSED) { + state == WL_POINTER_BUTTON_STATE_PRESSED) { pointer_state->grab_serial = serial; } diff --git a/types/wlr_virtual_pointer_v1.c b/types/wlr_virtual_pointer_v1.c index 6fcd0e94..2ae39a0a 100644 --- a/types/wlr_virtual_pointer_v1.c +++ b/types/wlr_virtual_pointer_v1.c @@ -71,7 +71,7 @@ static void virtual_pointer_button(struct wl_client *client, .pointer = &pointer->pointer, .time_msec = time, .button = button, - .state = state ? WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED + .state = state ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED, }; wl_signal_emit_mutable(&pointer->pointer.events.button, &event); }