From c22bc0b38669c4d85bb5c8e48441110d23642f5b Mon Sep 17 00:00:00 2001 From: random human Date: Fri, 14 Jun 2019 19:02:13 +0000 Subject: [PATCH] seat: expose more from_resource() functions --- include/wlr/types/wlr_seat.h | 11 +++++++++++ types/seat/wlr_seat_keyboard.c | 16 ++++++++-------- types/seat/wlr_seat_touch.c | 10 +++++----- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index bfd3625dc..23147c96f 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -627,10 +627,21 @@ bool wlr_seat_validate_touch_grab_serial(struct wlr_seat *seat, struct wlr_seat_client *wlr_seat_client_from_resource( struct wl_resource *resource); +/** + * Get a seat client from a keyboard resource. Returns NULL if inert. + */ +struct wlr_seat_client *wlr_seat_client_from_keyboard_resource( + struct wl_resource *resource); + /** * Get a seat client from a pointer resource. Returns NULL if inert. */ struct wlr_seat_client *wlr_seat_client_from_pointer_resource( struct wl_resource *resource); +/** + * Get a seat client from a touch resource. Returns NULL if inert. + */ +struct wlr_seat_client *wlr_seat_client_from_touch_resource( + struct wl_resource *resource); #endif diff --git a/types/seat/wlr_seat_keyboard.c b/types/seat/wlr_seat_keyboard.c index c92103eb6..29a6310d7 100644 --- a/types/seat/wlr_seat_keyboard.c +++ b/types/seat/wlr_seat_keyboard.c @@ -52,7 +52,7 @@ static const struct wl_keyboard_interface keyboard_impl = { .release = keyboard_release, }; -static struct wlr_seat_client *seat_client_from_keyboard_resource( +struct wlr_seat_client *wlr_seat_client_from_keyboard_resource( struct wl_resource *resource) { assert(wl_resource_instance_of(resource, &wl_keyboard_interface, &keyboard_impl)); @@ -75,7 +75,7 @@ void wlr_seat_keyboard_send_key(struct wlr_seat *wlr_seat, uint32_t time, uint32_t serial = wl_display_next_serial(wlr_seat->display); struct wl_resource *resource; wl_resource_for_each(resource, &client->keyboards) { - if (seat_client_from_keyboard_resource(resource) == NULL) { + if (wlr_seat_client_from_keyboard_resource(resource) == NULL) { continue; } @@ -204,7 +204,7 @@ void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat, uint32_t serial = wl_display_next_serial(seat->display); struct wl_resource *resource; wl_resource_for_each(resource, &client->keyboards) { - if (seat_client_from_keyboard_resource(resource) == NULL) { + if (wlr_seat_client_from_keyboard_resource(resource) == NULL) { continue; } @@ -243,7 +243,7 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat, uint32_t serial = wl_display_next_serial(seat->display); struct wl_resource *resource; wl_resource_for_each(resource, &focused_client->keyboards) { - if (seat_client_from_keyboard_resource(resource) == NULL) { + if (wlr_seat_client_from_keyboard_resource(resource) == NULL) { continue; } wl_keyboard_send_leave(resource, serial, focused_surface->resource); @@ -266,7 +266,7 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat, uint32_t serial = wl_display_next_serial(seat->display); struct wl_resource *resource; wl_resource_for_each(resource, &client->keyboards) { - if (seat_client_from_keyboard_resource(resource) == NULL) { + if (wlr_seat_client_from_keyboard_resource(resource) == NULL) { continue; } wl_keyboard_send_enter(resource, serial, surface->resource, &keys); @@ -344,7 +344,7 @@ static void seat_client_send_keymap(struct wlr_seat_client *client, // keyboard struct wl_resource *resource; wl_resource_for_each(resource, &client->keyboards) { - if (seat_client_from_keyboard_resource(resource) == NULL) { + if (wlr_seat_client_from_keyboard_resource(resource) == NULL) { continue; } @@ -381,7 +381,7 @@ static void seat_client_send_repeat_info(struct wlr_seat_client *client, struct wl_resource *resource; wl_resource_for_each(resource, &client->keyboards) { - if (seat_client_from_keyboard_resource(resource) == NULL) { + if (wlr_seat_client_from_keyboard_resource(resource) == NULL) { continue; } @@ -415,7 +415,7 @@ void seat_client_create_keyboard(struct wlr_seat_client *seat_client, void seat_client_destroy_keyboard(struct wl_resource *resource) { struct wlr_seat_client *seat_client = - seat_client_from_keyboard_resource(resource); + wlr_seat_client_from_keyboard_resource(resource); if (seat_client == NULL) { return; } diff --git a/types/seat/wlr_seat_touch.c b/types/seat/wlr_seat_touch.c index 75b304a54..631ae06c7 100644 --- a/types/seat/wlr_seat_touch.c +++ b/types/seat/wlr_seat_touch.c @@ -60,7 +60,7 @@ static void touch_handle_resource_destroy(struct wl_resource *resource) { seat_client_destroy_touch(resource); } -static struct wlr_seat_client *seat_client_from_touch_resource( +struct wlr_seat_client *wlr_seat_client_from_touch_resource( struct wl_resource *resource) { assert(wl_resource_instance_of(resource, &wl_touch_interface, &touch_impl)); @@ -281,7 +281,7 @@ uint32_t wlr_seat_touch_send_down(struct wlr_seat *seat, uint32_t serial = wl_display_next_serial(seat->display); struct wl_resource *resource; wl_resource_for_each(resource, &point->client->touches) { - if (seat_client_from_touch_resource(resource) == NULL) { + if (wlr_seat_client_from_touch_resource(resource) == NULL) { continue; } wl_touch_send_down(resource, serial, time, surface->resource, @@ -302,7 +302,7 @@ void wlr_seat_touch_send_up(struct wlr_seat *seat, uint32_t time, int32_t touch_ uint32_t serial = wl_display_next_serial(seat->display); struct wl_resource *resource; wl_resource_for_each(resource, &point->client->touches) { - if (seat_client_from_touch_resource(resource) == NULL) { + if (wlr_seat_client_from_touch_resource(resource) == NULL) { continue; } wl_touch_send_up(resource, serial, time, touch_id); @@ -320,7 +320,7 @@ void wlr_seat_touch_send_motion(struct wlr_seat *seat, uint32_t time, int32_t to struct wl_resource *resource; wl_resource_for_each(resource, &point->client->touches) { - if (seat_client_from_touch_resource(resource) == NULL) { + if (wlr_seat_client_from_touch_resource(resource) == NULL) { continue; } wl_touch_send_motion(resource, time, touch_id, wl_fixed_from_double(sx), @@ -353,7 +353,7 @@ void seat_client_create_touch(struct wlr_seat_client *seat_client, void seat_client_destroy_touch(struct wl_resource *resource) { struct wlr_seat_client *seat_client = - seat_client_from_touch_resource(resource); + wlr_seat_client_from_touch_resource(resource); if (seat_client == NULL) { return; }