From 12d9edc0c92c321a43331f23854e3de2e84a6aa0 Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Mon, 17 Dec 2018 16:58:31 -0600 Subject: [PATCH] Address more of @emersion's comments --- include/wlr/types/wlr_relative_pointer_v1.h | 7 ++----- types/wlr_relative_pointer_v1.c | 20 ++++++-------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index 292be238..1bc85b05 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -31,11 +31,7 @@ struct wlr_relative_pointer_manager_v1 { struct { struct wl_signal destroy; - /** - * returns struct wlr_relative_pointer_v1 *relative_pointer - * called when a new relative_pointer is successfully created - */ - struct wl_signal new_relative_pointer; + struct wl_signal new_relative_pointer; //wlr_relative_pointer_v1 } events; struct wl_listener display_destroy_listener; @@ -53,6 +49,7 @@ struct wlr_relative_pointer_manager_v1 { struct wlr_relative_pointer_v1 { struct wl_resource *resource; + struct wl_resource *pointer; struct wlr_seat *seat; struct wl_list link; // wlr_relative_pointer_manager_v1::relative_pointers diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index 6f686431..9d12bd93 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -42,6 +42,8 @@ static void relative_pointer_destroy(struct wlr_relative_pointer_v1 *relative_po wl_list_remove(&relative_pointer->link); wl_list_remove(&relative_pointer->seat_destroy.link); + + wl_resource_set_user_data(relative_pointer->resource, NULL); free(relative_pointer); } @@ -71,7 +73,6 @@ static void relative_pointer_handle_seat_destroy(struct wl_listener *listener, wl_container_of(listener, relative_pointer, seat_destroy); relative_pointer_destroy(relative_pointer); - wl_resource_set_user_data(relative_pointer->resource, NULL); } /** @@ -113,6 +114,7 @@ static void relative_pointer_manager_v1_handle_get_relative_pointer(struct wl_cl relative_pointer->resource = relative_pointer_resource; relative_pointer->seat = seat_client->seat; + relative_pointer->pointer = pointer; wl_signal_init(&relative_pointer->events.destroy); @@ -127,6 +129,8 @@ static void relative_pointer_manager_v1_handle_get_relative_pointer(struct wl_cl wl_signal_add(&relative_pointer->seat->events.destroy, &relative_pointer->seat_destroy); + wl_resource_add_destroy_listener(relative_pointer->pointer, + &relative_pointer->seat_destroy); relative_pointer->seat_destroy.notify = relative_pointer_handle_seat_destroy; wlr_signal_emit_safe(&relative_pointer_manager->events.new_relative_pointer, @@ -240,22 +244,10 @@ void wlr_relative_pointer_manager_v1_destroy(struct wlr_relative_pointer_manager void wlr_relative_pointer_v1_send_relative_motion(struct wlr_relative_pointer_v1 *relative_pointer, uint64_t time, double dx, double dy, double dx_unaccel, double dy_unaccel) { - struct wlr_seat_client *client = - relative_pointer->seat->pointer_state.focused_client; - - if (client == NULL) { - return; - } zwp_relative_pointer_v1_send_relative_motion(relative_pointer->resource, (uint32_t)(time >> 32), (uint32_t)time, wl_fixed_from_double(dx), wl_fixed_from_double(dy), wl_fixed_from_double(dx_unaccel), wl_fixed_from_double(dy_unaccel)); - struct wl_resource *resource; - wl_resource_for_each(resource, &client->pointers) { - if (wlr_seat_client_from_pointer_resource(resource) == NULL) { - continue; - } - wl_pointer_send_frame(resource); - } + wl_pointer_send_frame(relative_pointer->pointer); }