touch: make cancel functions take a wlr_seat_client

The surface argument is only used to obtain a wlr_seat_client and
semantically makes no sense. The wl_touch.cancel event applies to all
touch points and all surfaces of a client.

I decided to make the functions accept a wlr_seat_client rather than a
wl_client as it is directly available in the wlr_touch_point struct and
simplifies the implementation.
This commit is contained in:
Isaac Freund 2024-03-15 17:36:39 +01:00 committed by Simon Ser
parent 2f3ea4590a
commit 34219b0334
2 changed files with 11 additions and 20 deletions

View file

@ -137,7 +137,7 @@ struct wlr_touch_grab_interface {
void (*cancel)(struct wlr_seat_touch_grab *grab);
// Send wl_touch.cancel
void (*wl_cancel)(struct wlr_seat_touch_grab *grab,
struct wlr_surface *surface);
struct wlr_seat_client *seat_client);
};
/**
@ -632,11 +632,12 @@ void wlr_seat_touch_send_motion(struct wlr_seat *seat, uint32_t time_msec,
/**
* Notify the seat that this is a global gesture and the client should cancel
* processing it. The event will go to the client for the surface given.
* processing it. The event will go to the client given.
* This function does not respect touch grabs: you probably want
* wlr_seat_touch_notify_cancel() instead.
*/
void wlr_seat_touch_send_cancel(struct wlr_seat *seat, struct wlr_surface *surface);
void wlr_seat_touch_send_cancel(struct wlr_seat *seat,
struct wlr_seat_client *seat_client);
void wlr_seat_touch_send_frame(struct wlr_seat *seat);
@ -669,7 +670,7 @@ void wlr_seat_touch_notify_motion(struct wlr_seat *seat, uint32_t time_msec,
* cancel processing it. Defers to any grab of the touch device.
*/
void wlr_seat_touch_notify_cancel(struct wlr_seat *seat,
struct wlr_surface *surface);
struct wlr_seat_client *seat_client);
void wlr_seat_touch_notify_frame(struct wlr_seat *seat);

View file

@ -40,8 +40,8 @@ static void default_touch_cancel(struct wlr_seat_touch_grab *grab) {
}
static void default_touch_wl_cancel(struct wlr_seat_touch_grab *grab,
struct wlr_surface *surface) {
wlr_seat_touch_send_cancel(grab->seat, surface);
struct wlr_seat_client *seat_client) {
wlr_seat_touch_send_cancel(grab->seat, seat_client);
}
const struct wlr_touch_grab_interface default_touch_grab_impl = {
@ -242,17 +242,12 @@ void wlr_seat_touch_notify_frame(struct wlr_seat *seat) {
}
void wlr_seat_touch_notify_cancel(struct wlr_seat *seat,
struct wlr_surface *surface) {
struct wlr_seat_client *seat_client) {
struct wlr_seat_touch_grab *grab = seat->touch_state.grab;
if (grab->interface->wl_cancel) {
grab->interface->wl_cancel(grab, surface);
grab->interface->wl_cancel(grab, seat_client);
}
struct wl_client *client = wl_resource_get_client(surface->resource);
struct wlr_seat_client *seat_client = wlr_seat_client_for_wl_client(seat, client);
if (seat_client == NULL) {
return;
}
struct wlr_touch_point *point, *tmp;
wl_list_for_each_safe(point, tmp, &seat->touch_state.touch_points, link) {
if (point->client == seat_client) {
@ -399,13 +394,8 @@ void wlr_seat_touch_send_frame(struct wlr_seat *seat) {
}
}
void wlr_seat_touch_send_cancel(struct wlr_seat *seat, struct wlr_surface *surface) {
struct wl_client *client = wl_resource_get_client(surface->resource);
struct wlr_seat_client *seat_client = wlr_seat_client_for_wl_client(seat, client);
if (seat_client == NULL) {
return;
}
void wlr_seat_touch_send_cancel(struct wlr_seat *seat,
struct wlr_seat_client *seat_client) {
struct wl_resource *resource;
wl_resource_for_each(resource, &seat_client->touches) {
if (seat_client_from_touch_resource(resource) == NULL) {