types/wlr_touch: uniformize events name

This commit is contained in:
Simon Zeni 2022-03-09 16:01:14 -05:00 committed by Kirill Primak
parent e732c5c895
commit aaf787ee56
7 changed files with 48 additions and 45 deletions

View file

@ -32,8 +32,8 @@ void handle_touch_down(struct libinput_event *event,
struct wlr_touch *touch) { struct wlr_touch *touch) {
struct libinput_event_touch *tevent = struct libinput_event_touch *tevent =
libinput_event_get_touch_event(event); libinput_event_get_touch_event(event);
struct wlr_event_touch_down wlr_event = { 0 }; struct wlr_touch_down_event wlr_event = { 0 };
wlr_event.device = &touch->base; wlr_event.touch = touch;
wlr_event.time_msec = wlr_event.time_msec =
usec_to_msec(libinput_event_touch_get_time_usec(tevent)); usec_to_msec(libinput_event_touch_get_time_usec(tevent));
wlr_event.touch_id = libinput_event_touch_get_seat_slot(tevent); wlr_event.touch_id = libinput_event_touch_get_seat_slot(tevent);
@ -46,8 +46,8 @@ void handle_touch_up(struct libinput_event *event,
struct wlr_touch *touch) { struct wlr_touch *touch) {
struct libinput_event_touch *tevent = struct libinput_event_touch *tevent =
libinput_event_get_touch_event(event); libinput_event_get_touch_event(event);
struct wlr_event_touch_up wlr_event = { 0 }; struct wlr_touch_up_event wlr_event = { 0 };
wlr_event.device = &touch->base; wlr_event.touch = touch;
wlr_event.time_msec = wlr_event.time_msec =
usec_to_msec(libinput_event_touch_get_time_usec(tevent)); usec_to_msec(libinput_event_touch_get_time_usec(tevent));
wlr_event.touch_id = libinput_event_touch_get_seat_slot(tevent); wlr_event.touch_id = libinput_event_touch_get_seat_slot(tevent);
@ -58,8 +58,8 @@ void handle_touch_motion(struct libinput_event *event,
struct wlr_touch *touch) { struct wlr_touch *touch) {
struct libinput_event_touch *tevent = struct libinput_event_touch *tevent =
libinput_event_get_touch_event(event); libinput_event_get_touch_event(event);
struct wlr_event_touch_motion wlr_event = { 0 }; struct wlr_touch_motion_event wlr_event = { 0 };
wlr_event.device = &touch->base; wlr_event.touch = touch;
wlr_event.time_msec = wlr_event.time_msec =
usec_to_msec(libinput_event_touch_get_time_usec(tevent)); usec_to_msec(libinput_event_touch_get_time_usec(tevent));
wlr_event.touch_id = libinput_event_touch_get_seat_slot(tevent); wlr_event.touch_id = libinput_event_touch_get_seat_slot(tevent);
@ -72,8 +72,8 @@ void handle_touch_cancel(struct libinput_event *event,
struct wlr_touch *touch) { struct wlr_touch *touch) {
struct libinput_event_touch *tevent = struct libinput_event_touch *tevent =
libinput_event_get_touch_event(event); libinput_event_get_touch_event(event);
struct wlr_event_touch_cancel wlr_event = { 0 }; struct wlr_touch_cancel_event wlr_event = { 0 };
wlr_event.device = &touch->base; wlr_event.touch = touch;
wlr_event.time_msec = wlr_event.time_msec =
usec_to_msec(libinput_event_touch_get_time_usec(tevent)); usec_to_msec(libinput_event_touch_get_time_usec(tevent));
wlr_event.touch_id = libinput_event_touch_get_seat_slot(tevent); wlr_event.touch_id = libinput_event_touch_get_seat_slot(tevent);

View file

@ -140,40 +140,43 @@ static void touch_handle_down(void *data, struct wl_touch *wl_touch,
uint32_t serial, uint32_t time, struct wl_surface *surface, uint32_t serial, uint32_t time, struct wl_surface *surface,
int32_t id, wl_fixed_t x, wl_fixed_t y) { int32_t id, wl_fixed_t x, wl_fixed_t y) {
struct wlr_wl_seat *seat = data; struct wlr_wl_seat *seat = data;
struct wlr_touch *touch = &seat->wlr_touch;
struct wlr_event_touch_down event = { struct wlr_touch_down_event event = {
.device = &seat->wlr_touch.base, .touch = touch,
.time_msec = time, .time_msec = time,
.touch_id = id, .touch_id = id,
}; };
touch_coordinates_to_absolute(seat, x, y, &event.x, &event.y); touch_coordinates_to_absolute(seat, x, y, &event.x, &event.y);
wlr_signal_emit_safe(&seat->wlr_touch.events.down, &event); wlr_signal_emit_safe(&touch->events.down, &event);
} }
static void touch_handle_up(void *data, struct wl_touch *wl_touch, static void touch_handle_up(void *data, struct wl_touch *wl_touch,
uint32_t serial, uint32_t time, int32_t id) { uint32_t serial, uint32_t time, int32_t id) {
struct wlr_wl_seat *seat = data; struct wlr_wl_seat *seat = data;
struct wlr_touch *touch = &seat->wlr_touch;
struct wlr_event_touch_up event = { struct wlr_touch_up_event event = {
.device = &seat->wlr_touch.base, .touch = touch,
.time_msec = time, .time_msec = time,
.touch_id = id, .touch_id = id,
}; };
wlr_signal_emit_safe(&seat->wlr_touch.events.up, &event); wlr_signal_emit_safe(&touch->events.up, &event);
} }
static void touch_handle_motion(void *data, struct wl_touch *wl_touch, static void touch_handle_motion(void *data, struct wl_touch *wl_touch,
uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y) { uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y) {
struct wlr_wl_seat *seat = data; struct wlr_wl_seat *seat = data;
struct wlr_input_device *device = &seat->wlr_touch.base; struct wlr_touch *touch = &seat->wlr_touch;
struct wlr_event_touch_motion event = { struct wlr_touch_motion_event event = {
.device = device, .touch = touch,
.time_msec = time, .time_msec = time,
.touch_id = id, .touch_id = id,
}; };
touch_coordinates_to_absolute(seat, x, y, &event.x, &event.y); touch_coordinates_to_absolute(seat, x, y, &event.x, &event.y);
wlr_signal_emit_safe(&seat->wlr_touch.events.motion, &event); wlr_signal_emit_safe(&touch->events.motion, &event);
} }
static void touch_handle_frame(void *data, struct wl_touch *wl_touch) { static void touch_handle_frame(void *data, struct wl_touch *wl_touch) {

View file

@ -70,8 +70,8 @@ static void send_pointer_position_event(struct wlr_x11_output *output,
static void send_touch_down_event(struct wlr_x11_output *output, static void send_touch_down_event(struct wlr_x11_output *output,
int16_t x, int16_t y, int32_t touch_id, xcb_timestamp_t time) { int16_t x, int16_t y, int32_t touch_id, xcb_timestamp_t time) {
struct wlr_event_touch_down ev = { struct wlr_touch_down_event ev = {
.device = &output->touch.base, .touch = &output->touch,
.time_msec = time, .time_msec = time,
.x = (double)x / output->wlr_output.width, .x = (double)x / output->wlr_output.width,
.y = (double)y / output->wlr_output.height, .y = (double)y / output->wlr_output.height,
@ -83,8 +83,8 @@ static void send_touch_down_event(struct wlr_x11_output *output,
static void send_touch_motion_event(struct wlr_x11_output *output, static void send_touch_motion_event(struct wlr_x11_output *output,
int16_t x, int16_t y, int32_t touch_id, xcb_timestamp_t time) { int16_t x, int16_t y, int32_t touch_id, xcb_timestamp_t time) {
struct wlr_event_touch_motion ev = { struct wlr_touch_motion_event ev = {
.device = &output->touch.base, .touch = &output->touch,
.time_msec = time, .time_msec = time,
.x = (double)x / output->wlr_output.width, .x = (double)x / output->wlr_output.width,
.y = (double)y / output->wlr_output.height, .y = (double)y / output->wlr_output.height,
@ -96,8 +96,8 @@ static void send_touch_motion_event(struct wlr_x11_output *output,
static void send_touch_up_event(struct wlr_x11_output *output, static void send_touch_up_event(struct wlr_x11_output *output,
int32_t touch_id, xcb_timestamp_t time) { int32_t touch_id, xcb_timestamp_t time) {
struct wlr_event_touch_up ev = { struct wlr_touch_up_event ev = {
.device = &output->touch.base, .touch = &output->touch,
.time_msec = time, .time_msec = time,
.touch_id = touch_id, .touch_id = touch_id,
}; };

View file

@ -168,7 +168,7 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
static void handle_touch_up(struct wl_listener *listener, void *data) { static void handle_touch_up(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, touch_up); struct sample_state *sample = wl_container_of(listener, sample, touch_up);
struct wlr_event_touch_up *event = data; struct wlr_touch_up_event *event = data;
struct touch_point *point, *tmp; struct touch_point *point, *tmp;
wl_list_for_each_safe(point, tmp, &sample->touch_points, link) { wl_list_for_each_safe(point, tmp, &sample->touch_points, link) {
@ -178,25 +178,25 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
} }
} }
warp_to_touch(sample, event->device); warp_to_touch(sample, &event->touch->base);
} }
static void handle_touch_down(struct wl_listener *listener, void *data) { static void handle_touch_down(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, touch_down); struct sample_state *sample = wl_container_of(listener, sample, touch_down);
struct wlr_event_touch_down *event = data; struct wlr_touch_down_event *event = data;
struct touch_point *point = calloc(1, sizeof(struct touch_point)); struct touch_point *point = calloc(1, sizeof(struct touch_point));
point->touch_id = event->touch_id; point->touch_id = event->touch_id;
point->x = event->x; point->x = event->x;
point->y = event->y; point->y = event->y;
wl_list_insert(&sample->touch_points, &point->link); wl_list_insert(&sample->touch_points, &point->link);
warp_to_touch(sample, event->device); warp_to_touch(sample, &event->touch->base);
} }
static void handle_touch_motion(struct wl_listener *listener, void *data) { static void handle_touch_motion(struct wl_listener *listener, void *data) {
struct sample_state *sample = struct sample_state *sample =
wl_container_of(listener, sample, touch_motion); wl_container_of(listener, sample, touch_motion);
struct wlr_event_touch_motion *event = data; struct wlr_touch_motion_event *event = data;
struct touch_point *point; struct touch_point *point;
wl_list_for_each(point, &sample->touch_points, link) { wl_list_for_each(point, &sample->touch_points, link) {
@ -207,7 +207,7 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
} }
} }
warp_to_touch(sample, event->device); warp_to_touch(sample, &event->touch->base);
} }
static void handle_touch_cancel(struct wl_listener *listener, void *data) { static void handle_touch_cancel(struct wl_listener *listener, void *data) {

View file

@ -93,7 +93,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
} }
static void touch_down_notify(struct wl_listener *listener, void *data) { static void touch_down_notify(struct wl_listener *listener, void *data) {
struct wlr_event_touch_motion *event = data; struct wlr_touch_motion_event *event = data;
struct touch_state *tstate = wl_container_of(listener, tstate, down); struct touch_state *tstate = wl_container_of(listener, tstate, down);
struct sample_state *sample = tstate->sample; struct sample_state *sample = tstate->sample;
struct touch_point *point = calloc(1, sizeof(struct touch_point)); struct touch_point *point = calloc(1, sizeof(struct touch_point));
@ -104,7 +104,7 @@ static void touch_down_notify(struct wl_listener *listener, void *data) {
} }
static void touch_up_notify(struct wl_listener *listener, void *data ) { static void touch_up_notify(struct wl_listener *listener, void *data ) {
struct wlr_event_touch_up *event = data; struct wlr_touch_up_event *event = data;
struct touch_state *tstate = wl_container_of(listener, tstate, up); struct touch_state *tstate = wl_container_of(listener, tstate, up);
struct sample_state *sample = tstate->sample; struct sample_state *sample = tstate->sample;
struct touch_point *point, *tmp; struct touch_point *point, *tmp;
@ -117,7 +117,7 @@ static void touch_up_notify(struct wl_listener *listener, void *data ) {
} }
static void touch_motion_notify(struct wl_listener *listener, void *data) { static void touch_motion_notify(struct wl_listener *listener, void *data) {
struct wlr_event_touch_motion *event = data; struct wlr_touch_motion_event *event = data;
struct touch_state *tstate = wl_container_of(listener, tstate, motion); struct touch_state *tstate = wl_container_of(listener, tstate, motion);
struct sample_state *sample = tstate->sample; struct sample_state *sample = tstate->sample;
struct touch_point *point; struct touch_point *point;

View file

@ -34,30 +34,30 @@ struct wlr_touch {
void *data; void *data;
}; };
struct wlr_event_touch_down { struct wlr_touch_down_event {
struct wlr_input_device *device; struct wlr_touch *touch;
uint32_t time_msec; uint32_t time_msec;
int32_t touch_id; int32_t touch_id;
// From 0..1 // From 0..1
double x, y; double x, y;
}; };
struct wlr_event_touch_up { struct wlr_touch_up_event {
struct wlr_input_device *device; struct wlr_touch *touch;
uint32_t time_msec; uint32_t time_msec;
int32_t touch_id; int32_t touch_id;
}; };
struct wlr_event_touch_motion { struct wlr_touch_motion_event {
struct wlr_input_device *device; struct wlr_touch *touch;
uint32_t time_msec; uint32_t time_msec;
int32_t touch_id; int32_t touch_id;
// From 0..1 // From 0..1
double x, y; double x, y;
}; };
struct wlr_event_touch_cancel { struct wlr_touch_cancel_event {
struct wlr_input_device *device; struct wlr_touch *touch;
uint32_t time_msec; uint32_t time_msec;
int32_t touch_id; int32_t touch_id;
}; };

View file

@ -510,14 +510,14 @@ static void handle_pointer_hold_end(struct wl_listener *listener, void *data) {
} }
static void handle_touch_up(struct wl_listener *listener, void *data) { static void handle_touch_up(struct wl_listener *listener, void *data) {
struct wlr_event_touch_up *event = data; struct wlr_touch_up_event *event = data;
struct wlr_cursor_device *device; struct wlr_cursor_device *device;
device = wl_container_of(listener, device, touch_up); device = wl_container_of(listener, device, touch_up);
wlr_signal_emit_safe(&device->cursor->events.touch_up, event); wlr_signal_emit_safe(&device->cursor->events.touch_up, event);
} }
static void handle_touch_down(struct wl_listener *listener, void *data) { static void handle_touch_down(struct wl_listener *listener, void *data) {
struct wlr_event_touch_down *event = data; struct wlr_touch_down_event *event = data;
struct wlr_cursor_device *device; struct wlr_cursor_device *device;
device = wl_container_of(listener, device, touch_down); device = wl_container_of(listener, device, touch_down);
@ -530,7 +530,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
} }
static void handle_touch_motion(struct wl_listener *listener, void *data) { static void handle_touch_motion(struct wl_listener *listener, void *data) {
struct wlr_event_touch_motion *event = data; struct wlr_touch_motion_event *event = data;
struct wlr_cursor_device *device; struct wlr_cursor_device *device;
device = wl_container_of(listener, device, touch_motion); device = wl_container_of(listener, device, touch_motion);
@ -543,7 +543,7 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
} }
static void handle_touch_cancel(struct wl_listener *listener, void *data) { static void handle_touch_cancel(struct wl_listener *listener, void *data) {
struct wlr_event_touch_cancel *event = data; struct wlr_touch_cancel_event *event = data;
struct wlr_cursor_device *device; struct wlr_cursor_device *device;
device = wl_container_of(listener, device, touch_cancel); device = wl_container_of(listener, device, touch_cancel);
wlr_signal_emit_safe(&device->cursor->events.touch_cancel, event); wlr_signal_emit_safe(&device->cursor->events.touch_cancel, event);