Address more of @emersion's comments

This commit is contained in:
Alex Maese 2018-12-17 16:58:31 -06:00
parent e276d310e8
commit 12d9edc0c9
2 changed files with 8 additions and 19 deletions

View File

@ -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

View File

@ -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);
}