pointer: use enum wl_pointer_button_state

master
Simon Ser 9 months ago committed by Simon Zeni
parent 9f4cf242d9
commit 812451cd8f

@ -69,13 +69,13 @@ void handle_pointer_button(struct libinput_event *event,
uint32_t seat_count = libinput_event_pointer_get_seat_button_count(pevent); uint32_t seat_count = libinput_event_pointer_get_seat_button_count(pevent);
switch (libinput_event_pointer_get_button_state(pevent)) { switch (libinput_event_pointer_get_button_state(pevent)) {
case LIBINPUT_BUTTON_STATE_PRESSED: case LIBINPUT_BUTTON_STATE_PRESSED:
wlr_event.state = WLR_BUTTON_PRESSED; wlr_event.state = WL_POINTER_BUTTON_STATE_PRESSED;
if (seat_count != 1) { if (seat_count != 1) {
return; return;
} }
break; break;
case LIBINPUT_BUTTON_STATE_RELEASED: case LIBINPUT_BUTTON_STATE_RELEASED:
wlr_event.state = WLR_BUTTON_RELEASED; wlr_event.state = WL_POINTER_BUTTON_STATE_RELEASED;
if (seat_count != 0) { if (seat_count != 0) {
return; return;
} }

@ -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, 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 = { struct wlr_pointer_button_event ev = {
.pointer = &output->pointer, .pointer = &output->pointer,
.time_msec = time, .time_msec = time,
@ -155,15 +155,15 @@ void handle_x11_xinput_event(struct wlr_x11_backend *x11,
switch (ev->detail) { switch (ev->detail) {
case XCB_BUTTON_INDEX_1: 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); ev->time);
break; break;
case XCB_BUTTON_INDEX_2: 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); ev->time);
break; break;
case XCB_BUTTON_INDEX_3: 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); ev->time);
break; break;
case XCB_BUTTON_INDEX_4: case XCB_BUTTON_INDEX_4:
@ -188,15 +188,15 @@ void handle_x11_xinput_event(struct wlr_x11_backend *x11,
switch (ev->detail) { switch (ev->detail) {
case XCB_BUTTON_INDEX_1: 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); ev->time);
break; break;
case XCB_BUTTON_INDEX_2: 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); ev->time);
break; break;
case XCB_BUTTON_INDEX_3: 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); ev->time);
break; break;
} }

@ -144,7 +144,7 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
struct wlr_pointer_button_event *event = data; struct wlr_pointer_button_event *event = data;
float (*color)[4]; float (*color)[4];
if (event->state == WLR_BUTTON_RELEASED) { if (event->state == WL_POINTER_BUTTON_STATE_RELEASED) {
color = &sample->default_color; color = &sample->default_color;
memcpy(&sample->clear_color, color, sizeof(*color)); memcpy(&sample->clear_color, color, sizeof(*color));
} else { } else {

@ -63,7 +63,7 @@ struct wlr_pointer_button_event {
struct wlr_pointer *pointer; struct wlr_pointer *pointer;
uint32_t time_msec; uint32_t time_msec;
uint32_t button; uint32_t button;
enum wlr_button_state state; enum wl_pointer_button_state state;
}; };
enum wlr_axis_orientation { enum wlr_axis_orientation {

@ -98,7 +98,7 @@ struct wlr_pointer_grab_interface {
void (*motion)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec, void (*motion)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec,
double sx, double sy); double sx, double sy);
uint32_t (*button)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec, 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, void (*axis)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec,
enum wlr_axis_orientation orientation, double value, enum wlr_axis_orientation orientation, double value,
int32_t value_discrete, enum wl_pointer_axis_source source, 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. * instead.
*/ */
uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, 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 * 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. * pointer.
*/ */
uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, 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. * Notify the seat of an axis event. Defers to any grab of the pointer.

@ -525,7 +525,7 @@ static void server_cursor_button(struct wl_listener *listener, void *data) {
struct wlr_surface *surface = NULL; struct wlr_surface *surface = NULL;
struct tinywl_toplevel *toplevel = desktop_toplevel_at(server, struct tinywl_toplevel *toplevel = desktop_toplevel_at(server,
server->cursor->x, server->cursor->y, &surface, &sx, &sy); 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. */ /* If you released any buttons, we exit interactive move/resize mode. */
reset_cursor_mode(server); reset_cursor_mode(server);
} else { } else {

@ -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, 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); 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 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; struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client;
if (client == NULL) { if (client == NULL) {
return 0; 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 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); clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event);
struct wlr_seat_pointer_state* pointer_state = &wlr_seat->pointer_state; 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) { if (pointer_state->button_count == 0) {
pointer_state->grab_button = button; pointer_state->grab_button = button;
pointer_state->grab_time = time; 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); uint32_t serial = grab->interface->button(grab, time, button, state);
if (serial && pointer_state->button_count == 1 && if (serial && pointer_state->button_count == 1 &&
state == WLR_BUTTON_PRESSED) { state == WL_POINTER_BUTTON_STATE_PRESSED) {
pointer_state->grab_serial = serial; pointer_state->grab_serial = serial;
} }

@ -71,7 +71,7 @@ static void virtual_pointer_button(struct wl_client *client,
.pointer = &pointer->pointer, .pointer = &pointer->pointer,
.time_msec = time, .time_msec = time,
.button = button, .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); wl_signal_emit_mutable(&pointer->pointer.events.button, &event);
} }

Loading…
Cancel
Save