From 3a3d1b661714a7d37b8a4450fe0c3dec50027622 Mon Sep 17 00:00:00 2001 From: random human Date: Fri, 28 Sep 2018 04:43:52 +0530 Subject: relative_pointer: create skeleton and build Add protocol, header and type files to build. Create skeleton structs, creator and destroyer, and define implementations. --- include/wlr/types/wlr_relative_pointer_v1.h | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 include/wlr/types/wlr_relative_pointer_v1.h (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h new file mode 100644 index 00000000..815dcaca --- /dev/null +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -0,0 +1,45 @@ +/* + * This an unstable interface of wlroots. No guarantees are made regarding the + * future consistency of this API. + */ +#ifndef WLR_USE_UNSTABLE +#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" +#endif + +#ifndef WLR_TYPES_WLR_RELATIVE_POINTER_V1_H +#define WLR_TYPES_WLR_RELATIVE_POINTER_V1_H + +#include + + +/* This protocol specifies a set of interfaces used for making clients able to + * receive relative pointer events not obstructed by barriers (such as the + * monitor edge or other pointer barriers). + */ + +struct wlr_relative_pointer_manager_v1 { + struct wl_list resources; + struct wl_global *global; + + struct { + struct wl_signal destroy; + struct wl_signal get_relative_pointer; + } requests; + + void *data; +}; + +struct wlr_relative_pointer_v1 { + struct wl_resource *resource; + + struct { + struct wl_signal destroy; + } destroy; + + void *data; +}; + +struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl_display *display); +void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *relative_pointer_manager); + +#endif -- cgit v1.2.3 From ba5b1676dfb0041c88e4966a6c32dee5a5a6513a Mon Sep 17 00:00:00 2001 From: random human Date: Mon, 1 Oct 2018 03:54:21 +0530 Subject: relative_pointer: implement protocol requests Flesh out the details of the structs, signals, callback functions, and so on. weston-resizer silently works at this point (no events sent). --- include/wlr/types/wlr_relative_pointer_v1.h | 30 ++++++++- include/wlr/types/wlr_seat.h | 1 + types/seat/wlr_seat.c | 4 ++ types/wlr_relative_pointer_v1.c | 99 +++++++++++++++++++++++------ 4 files changed, 113 insertions(+), 21 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index 815dcaca..94ae053b 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -17,24 +17,48 @@ * monitor edge or other pointer barriers). */ + +/* A global interface used for getting the relative pointer object for a given + * pointer. + * + * Signals: + * - destroy -> struct wlr_relative_pointer_manager_v1 *manager + * :: the manager was destroyed + * - new_relative_pointer -> struct wlr_relative_pointer_v1 *relative_pointer + * :: a new relative_pointer was created + */ + struct wlr_relative_pointer_manager_v1 { struct wl_list resources; struct wl_global *global; struct { struct wl_signal destroy; - struct wl_signal get_relative_pointer; - } requests; + struct wl_signal new_relative_pointer; + } events; void *data; }; + +/* A wp_relative_pointer object is an extension to the wl_pointer interface + * used for emitting relative pointer events. It shares the same focus as + * wl_pointer objects of the same seat and will only emit events when it has + * focus. + * + * Signals: + * - destroy -> struct wlr_relative_pointer_v1 *relative_pointer + * :: the relative_pointer was destroyed + */ + struct wlr_relative_pointer_v1 { + struct wl_client *client; struct wl_resource *resource; + struct wl_pointer *pointer; struct { struct wl_signal destroy; - } destroy; + } events; void *data; }; diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 942a3420..9fc1ba95 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -27,6 +27,7 @@ struct wlr_seat_client { // lists of wl_resource struct wl_list resources; struct wl_list pointers; + struct wl_list relative_pointers; struct wl_list keyboards; struct wl_list touches; struct wl_list data_devices; diff --git a/types/seat/wlr_seat.c b/types/seat/wlr_seat.c index 8b1d67fd..698a906a 100644 --- a/types/seat/wlr_seat.c +++ b/types/seat/wlr_seat.c @@ -79,6 +79,9 @@ static void seat_client_handle_resource_destroy( wl_resource_for_each_safe(resource, tmp, &client->pointers) { wl_resource_destroy(resource); } + wl_resource_for_each_safe(resource, tmp, &client->relative_pointers) { + wl_resource_destroy(resource); + } wl_resource_for_each_safe(resource, tmp, &client->keyboards) { wl_resource_destroy(resource); } @@ -131,6 +134,7 @@ static void seat_handle_bind(struct wl_client *client, void *_wlr_seat, seat_client->seat = wlr_seat; wl_list_init(&seat_client->resources); wl_list_init(&seat_client->pointers); + wl_list_init(&seat_client->relative_pointers); wl_list_init(&seat_client->keyboards); wl_list_init(&seat_client->touches); wl_list_init(&seat_client->data_devices); diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index 54bd41a7..b32bbc79 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -1,7 +1,10 @@ #include +#include +#include #include #include #include +#include #include "wayland-util.h" #include "wayland-server.h" #include "relative-pointer-unstable-v1-protocol.h" @@ -13,53 +16,109 @@ static const struct zwp_relative_pointer_v1_interface relative_pointer_v1_impl; /* Callback functions */ +static void relative_pointer_manager_v1_handle_resource_destroy(struct wl_resource *resource) +{ + wl_list_remove(wl_resource_get_link(resource)); +} + + +static void relative_pointer_v1_handle_resource_destroy(struct wl_resource *resource) +{ + wl_list_remove(wl_resource_get_link(resource)); + + struct wlr_relative_pointer_v1 *relative_pointer = wl_resource_get_user_data(resource); + free(relative_pointer); +} + + static void relative_pointer_manager_v1_handle_destroy(struct wl_client *client, struct wl_resource *resource) { - wlr_log(WLR_DEBUG, "relative_pointer_manager_v1_handle_destroy called"); + wl_resource_destroy(resource); + + wlr_log(WLR_DEBUG, "relative_pointer_v1 manager unbound from client 0x%" PRIXPTR, + (uintptr_t) client); } static void relative_pointer_manager_v1_handle_get_relative_pointer(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *pointer) { - wlr_log(WLR_DEBUG, "relative_pointer_manager_v1_handle_get_relative_pointer called"); + struct wlr_seat_client *seat_client = + wlr_seat_client_from_pointer_resource(pointer); + assert(seat_client->client == client); + + struct wlr_relative_pointer_v1 *relative_pointer = + calloc(1, sizeof(struct wlr_relative_pointer_v1)); + if (relative_pointer == NULL) { + wl_client_post_no_memory(client); + return; + } + + struct wl_resource *relative_pointer_resource = wl_resource_create(client, + &zwp_relative_pointer_v1_interface, wl_resource_get_version(resource), id); + if (relative_pointer_resource == NULL) { + free(relative_pointer); + wl_client_post_no_memory(client); + return; + } + + relative_pointer->client = client; + relative_pointer->resource = relative_pointer_resource; + relative_pointer->pointer = (struct wl_pointer *) pointer; + + wl_signal_init(&relative_pointer->events.destroy); + + wl_list_insert(&seat_client->relative_pointers, + wl_resource_get_link(relative_pointer_resource)); + + wl_resource_set_implementation(relative_pointer_resource, &relative_pointer_v1_impl, + relative_pointer, relative_pointer_v1_handle_resource_destroy); + + struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = + wl_resource_get_user_data(resource); + wlr_signal_emit_safe(&relative_pointer_manager->events.new_relative_pointer, + relative_pointer); + + wlr_log(WLR_DEBUG, + "relative_pointer_v1 0x%" PRIXPTR " created for client 0x%" PRIXPTR, + (uintptr_t) relative_pointer, (uintptr_t) client); } static void relative_pointer_v1_handle_destroy(struct wl_client *client, struct wl_resource *resource) { - wlr_log(WLR_DEBUG, "relative_pointer_v1_handle_destroy called"); -} + struct wlr_relative_pointer_v1 *relative_pointer = + wl_resource_get_user_data(resource); + wlr_log(WLR_DEBUG, + "relative_pointer_v1 0x%" PRIXPTR " released by client 0x%" PRIXPTR, + (uintptr_t) relative_pointer, (uintptr_t) client); - -static void relative_pointer_manager_v1_handle_resource_destroy(struct wl_resource *resource) -{ - wl_list_remove(wl_resource_get_link(resource)); - wlr_log(WLR_DEBUG, "relative_pointer_manager_v1_handle_resource_destroy called"); + wl_resource_destroy(resource); } -static void relative_pointer_manager_bind(struct wl_client *wl_client, void *data, +static void relative_pointer_manager_v1_bind(struct wl_client *wl_client, void *data, uint32_t version, uint32_t id) { struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = data; - struct wl_resource *wl_resource = wl_resource_create(wl_client, + struct wl_resource *manager_resource = wl_resource_create(wl_client, &zwp_relative_pointer_manager_v1_interface, version, id); - if (wl_resource == NULL) { + if (manager_resource == NULL) { wl_client_post_no_memory(wl_client); return; } - wl_list_insert(&relative_pointer_manager->resources, wl_resource_get_link(wl_resource)); + wl_list_insert(&relative_pointer_manager->resources, wl_resource_get_link(manager_resource)); - wl_resource_set_implementation(wl_resource, &relative_pointer_manager_v1_impl, + wl_resource_set_implementation(manager_resource, &relative_pointer_manager_v1_impl, relative_pointer_manager, relative_pointer_manager_v1_handle_resource_destroy); - wlr_log(WLR_DEBUG, "relative_pointer_manager bound"); + wlr_log(WLR_DEBUG, "relative_pointer_v1 manager bound to client 0x%" PRIXPTR, + (uintptr_t) wl_client); } @@ -91,12 +150,12 @@ struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl wl_list_init(&relative_pointer_manager->resources); - wl_signal_init(&relative_pointer_manager->requests.destroy); - wl_signal_init(&relative_pointer_manager->requests.get_relative_pointer); + wl_signal_init(&relative_pointer_manager->events.destroy); + wl_signal_init(&relative_pointer_manager->events.new_relative_pointer); relative_pointer_manager->global = wl_global_create(display, &zwp_relative_pointer_manager_v1_interface, 1, - relative_pointer_manager, relative_pointer_manager_bind); + relative_pointer_manager, relative_pointer_manager_v1_bind); if (relative_pointer_manager->global == NULL) { free(relative_pointer_manager); @@ -115,6 +174,8 @@ void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *rel return; } + wlr_signal_emit_safe(&relative_pointer_manager->events.destroy, relative_pointer_manager); + struct wl_resource *resource; struct wl_resource *tmp_resource; wl_resource_for_each_safe(resource, tmp_resource, &relative_pointer_manager->resources) { @@ -123,4 +184,6 @@ void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *rel wl_global_destroy(relative_pointer_manager->global); free(relative_pointer_manager); + + wlr_log(WLR_DEBUG, "relative_pointer_v1 manager destroyed"); } -- cgit v1.2.3 From d0203446751f2b8b4e80ecf54b6ff831096c3302 Mon Sep 17 00:00:00 2001 From: random human Date: Mon, 1 Oct 2018 06:21:32 +0530 Subject: relative_pointer: implement protocol events Implement zwp_relative_pointer_v1.relative_motion event, along with some glue code in wlr_seat_pointer and rootston. --- include/wlr/types/wlr_relative_pointer_v1.h | 4 ++++ include/wlr/types/wlr_seat.h | 12 ++++++++++++ rootston/cursor.c | 8 ++++++++ types/seat/wlr_seat_pointer.c | 15 +++++++++++++++ types/wlr_relative_pointer_v1.c | 13 +++++++++++++ 5 files changed, 52 insertions(+) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index 94ae053b..c74766b9 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -66,4 +66,8 @@ struct wlr_relative_pointer_v1 { struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl_display *display); void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *relative_pointer_manager); +void wlr_relative_pointer_v1_send_relative_motion(struct wl_resource *resource, + uint64_t time, double dx, double dy, double dx_unaccel, double + dy_unaccel); + #endif diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 9fc1ba95..54e04e24 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -314,6 +314,18 @@ void wlr_seat_pointer_clear_focus(struct wlr_seat *wlr_seat); void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time, double sx, double sy); +/** Send relative motion events to the surface with pointer focus. Coordinates + * for the motion event are relative to current pointer location, both + * accelerated and unaccelerated. Compositors should use + * `wlr_seat_pointer_notify_relative_motion()` to send relative motion events + * to respect relative pointer requests by clients. + * + * Note that the timestamp is 64 bit, split into high 32 bits and low 32 bits. + */ +void wlr_seat_pointer_notify_relative_motion(struct wlr_seat *wlr_seat, + uint64_t time, double dx, double dy, double dx_unaccel, + double dy_unaccel); + /** * Send a button event to the surface with pointer focus. Coordinates for the * button event are surface-local. Returns the serial. Compositors should use diff --git a/rootston/cursor.c b/rootston/cursor.c index b9ded30e..b03b934e 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -310,6 +310,9 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor, double dx = event->delta_x; double dy = event->delta_y; + wlr_seat_pointer_notify_relative_motion(cursor->seat->seat, (uint64_t) + event->time_msec, dx, dy, dx, dy); + if (cursor->active_constraint) { struct roots_view *view = cursor->pointer_view->view; assert(view); @@ -349,6 +352,11 @@ void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor, wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device, event->x, event->y, &lx, &ly); + double dx = lx - cursor->cursor->x; + double dy = ly - cursor->cursor->y; + wlr_seat_pointer_notify_relative_motion(cursor->seat->seat, (uint64_t) + event->time_msec, dx, dy, dx, dy); + if (cursor->pointer_view) { struct roots_view *view = cursor->pointer_view->view; diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c index 594a5b81..12c4fab5 100644 --- a/types/seat/wlr_seat_pointer.c +++ b/types/seat/wlr_seat_pointer.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "types/wlr_seat.h" #include "util/signal.h" @@ -304,6 +305,20 @@ void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, uint32_t time, grab->interface->motion(grab, time, sx, sy); } +void wlr_seat_pointer_notify_relative_motion(struct wlr_seat *wlr_seat, + uint64_t time, double dx, double dy, double dx_unaccel, double dy_unaccel) { + struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client; + if (client == NULL) { + return; + } + + struct wl_resource *resource; + wl_resource_for_each(resource, &client->relative_pointers) { + wlr_relative_pointer_v1_send_relative_motion(resource, time, dx, dy, + dx_unaccel, dy_unaccel); + } +} + uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, uint32_t time, uint32_t button, uint32_t state) { clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event); diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index b32bbc79..c8ec8190 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -187,3 +187,16 @@ void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *rel wlr_log(WLR_DEBUG, "relative_pointer_v1 manager destroyed"); } + + +void wlr_relative_pointer_v1_send_relative_motion(struct wl_resource *resource, + uint64_t time, double dx, double dy, double dx_unaccel, double + dy_unaccel) +{ + assert(wl_resource_instance_of(resource, &zwp_relative_pointer_v1_interface, + &relative_pointer_v1_impl)); + zwp_relative_pointer_v1_send_relative_motion(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)); +} -- cgit v1.2.3 From 6fa1777f94b2743747d00433c98a2251e0ef12ee Mon Sep 17 00:00:00 2001 From: random human Date: Mon, 1 Oct 2018 20:33:21 +0530 Subject: relative_pointer: code formatting fixes --- include/wlr/types/wlr_relative_pointer_v1.h | 12 +++--- include/wlr/types/wlr_seat.h | 7 ++-- rootston/cursor.c | 8 ++-- types/seat/wlr_seat_pointer.c | 3 +- types/wlr_relative_pointer_v1.c | 62 +++++++++++++---------------- 5 files changed, 44 insertions(+), 48 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index c74766b9..b2eb7241 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -12,13 +12,15 @@ #include -/* This protocol specifies a set of interfaces used for making clients able to +/** + * This protocol specifies a set of interfaces used for making clients able to * receive relative pointer events not obstructed by barriers (such as the * monitor edge or other pointer barriers). */ -/* A global interface used for getting the relative pointer object for a given +/** + * A global interface used for getting the relative pointer object for a given * pointer. * * Signals: @@ -41,7 +43,8 @@ struct wlr_relative_pointer_manager_v1 { }; -/* A wp_relative_pointer object is an extension to the wl_pointer interface +/** + * A wp_relative_pointer object is an extension to the wl_pointer interface * used for emitting relative pointer events. It shares the same focus as * wl_pointer objects of the same seat and will only emit events when it has * focus. @@ -67,7 +70,6 @@ struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *relative_pointer_manager); void wlr_relative_pointer_v1_send_relative_motion(struct wl_resource *resource, - uint64_t time, double dx, double dy, double dx_unaccel, double - dy_unaccel); + uint64_t time, double dx, double dy, double dx_unaccel, double dy_unaccel); #endif diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 54e04e24..4c0edcd8 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -314,7 +314,8 @@ void wlr_seat_pointer_clear_focus(struct wlr_seat *wlr_seat); void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time, double sx, double sy); -/** Send relative motion events to the surface with pointer focus. Coordinates +/** + * Send relative motion events to the surface with pointer focus. Coordinates * for the motion event are relative to current pointer location, both * accelerated and unaccelerated. Compositors should use * `wlr_seat_pointer_notify_relative_motion()` to send relative motion events @@ -323,8 +324,8 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time, * Note that the timestamp is 64 bit, split into high 32 bits and low 32 bits. */ void wlr_seat_pointer_notify_relative_motion(struct wlr_seat *wlr_seat, - uint64_t time, double dx, double dy, double dx_unaccel, - double dy_unaccel); + uint64_t time, double dx, double dy, + double dx_unaccel, double dy_unaccel); /** * Send a button event to the surface with pointer focus. Coordinates for the diff --git a/rootston/cursor.c b/rootston/cursor.c index b03b934e..45d7b40e 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -310,8 +310,8 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor, double dx = event->delta_x; double dy = event->delta_y; - wlr_seat_pointer_notify_relative_motion(cursor->seat->seat, (uint64_t) - event->time_msec, dx, dy, dx, dy); + wlr_seat_pointer_notify_relative_motion(cursor->seat->seat, + (uint64_t)event->time_msec, dx, dy, dx, dy); if (cursor->active_constraint) { struct roots_view *view = cursor->pointer_view->view; @@ -354,8 +354,8 @@ void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor, double dx = lx - cursor->cursor->x; double dy = ly - cursor->cursor->y; - wlr_seat_pointer_notify_relative_motion(cursor->seat->seat, (uint64_t) - event->time_msec, dx, dy, dx, dy); + wlr_seat_pointer_notify_relative_motion(cursor->seat->seat, + (uint64_t)event->time_msec, dx, dy, dx, dy); if (cursor->pointer_view) { struct roots_view *view = cursor->pointer_view->view; diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c index 12c4fab5..3c7e98e9 100644 --- a/types/seat/wlr_seat_pointer.c +++ b/types/seat/wlr_seat_pointer.c @@ -306,7 +306,8 @@ void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, uint32_t time, } void wlr_seat_pointer_notify_relative_motion(struct wlr_seat *wlr_seat, - uint64_t time, double dx, double dy, double dx_unaccel, double dy_unaccel) { + uint64_t time, double dx, double dy, + double dx_unaccel, double dy_unaccel) { struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client; if (client == NULL) { return; diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index c8ec8190..93d96fa4 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -13,17 +13,16 @@ static const struct zwp_relative_pointer_manager_v1_interface relative_pointer_m static const struct zwp_relative_pointer_v1_interface relative_pointer_v1_impl; -/* Callback functions +/** + * Callback functions */ -static void relative_pointer_manager_v1_handle_resource_destroy(struct wl_resource *resource) -{ +static void relative_pointer_manager_v1_handle_resource_destroy(struct wl_resource *resource) { wl_list_remove(wl_resource_get_link(resource)); } -static void relative_pointer_v1_handle_resource_destroy(struct wl_resource *resource) -{ +static void relative_pointer_v1_handle_resource_destroy(struct wl_resource *resource) { wl_list_remove(wl_resource_get_link(resource)); struct wlr_relative_pointer_v1 *relative_pointer = wl_resource_get_user_data(resource); @@ -32,18 +31,16 @@ static void relative_pointer_v1_handle_resource_destroy(struct wl_resource *reso static void relative_pointer_manager_v1_handle_destroy(struct wl_client *client, - struct wl_resource *resource) -{ + struct wl_resource *resource) { wl_resource_destroy(resource); - wlr_log(WLR_DEBUG, "relative_pointer_v1 manager unbound from client 0x%" PRIXPTR, - (uintptr_t) client); + wlr_log(WLR_DEBUG, "relative_pointer_v1 manager unbound from client %p", + client); } static void relative_pointer_manager_v1_handle_get_relative_pointer(struct wl_client *client, - struct wl_resource *resource, uint32_t id, struct wl_resource *pointer) -{ + struct wl_resource *resource, uint32_t id, struct wl_resource *pointer) { struct wlr_seat_client *seat_client = wlr_seat_client_from_pointer_resource(pointer); assert(seat_client->client == client); @@ -80,28 +77,24 @@ static void relative_pointer_manager_v1_handle_get_relative_pointer(struct wl_cl wlr_signal_emit_safe(&relative_pointer_manager->events.new_relative_pointer, relative_pointer); - wlr_log(WLR_DEBUG, - "relative_pointer_v1 0x%" PRIXPTR " created for client 0x%" PRIXPTR, - (uintptr_t) relative_pointer, (uintptr_t) client); + wlr_log(WLR_DEBUG, "relative_pointer_v1 %p created for client %p", + relative_pointer, client); } static void relative_pointer_v1_handle_destroy(struct wl_client *client, - struct wl_resource *resource) -{ + struct wl_resource *resource) { struct wlr_relative_pointer_v1 *relative_pointer = wl_resource_get_user_data(resource); - wlr_log(WLR_DEBUG, - "relative_pointer_v1 0x%" PRIXPTR " released by client 0x%" PRIXPTR, - (uintptr_t) relative_pointer, (uintptr_t) client); + wlr_log(WLR_DEBUG, "relative_pointer_v1 %p released by client %p", + relative_pointer, client); wl_resource_destroy(resource); } static void relative_pointer_manager_v1_bind(struct wl_client *wl_client, void *data, - uint32_t version, uint32_t id) -{ + uint32_t version, uint32_t id) { struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = data; struct wl_resource *manager_resource = wl_resource_create(wl_client, @@ -117,12 +110,13 @@ static void relative_pointer_manager_v1_bind(struct wl_client *wl_client, void * wl_resource_set_implementation(manager_resource, &relative_pointer_manager_v1_impl, relative_pointer_manager, relative_pointer_manager_v1_handle_resource_destroy); - wlr_log(WLR_DEBUG, "relative_pointer_v1 manager bound to client 0x%" PRIXPTR, - (uintptr_t) wl_client); + wlr_log(WLR_DEBUG, "relative_pointer_v1 manager bound to client %p", + wl_client); } -/* Implementations +/** + * Implementations */ static const struct zwp_relative_pointer_manager_v1_interface relative_pointer_manager_v1_impl = { @@ -136,11 +130,11 @@ static const struct zwp_relative_pointer_v1_interface relative_pointer_v1_impl = }; -/* Public functions +/** + * Public functions */ -struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl_display *display) -{ +struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl_display *display) { struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = calloc(1, sizeof(struct wlr_relative_pointer_manager_v1)); @@ -168,8 +162,7 @@ struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl } -void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *relative_pointer_manager) -{ +void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *relative_pointer_manager) { if (relative_pointer_manager == NULL) { return; } @@ -190,13 +183,12 @@ void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *rel void wlr_relative_pointer_v1_send_relative_motion(struct wl_resource *resource, - uint64_t time, double dx, double dy, double dx_unaccel, double - dy_unaccel) -{ + uint64_t time, double dx, double dy, + double dx_unaccel, double dy_unaccel) { assert(wl_resource_instance_of(resource, &zwp_relative_pointer_v1_interface, &relative_pointer_v1_impl)); zwp_relative_pointer_v1_send_relative_motion(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)); + (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)); } -- cgit v1.2.3 From fb44ce9fa8aadc1fee59b13f5780b493ed0a425f Mon Sep 17 00:00:00 2001 From: random human Date: Mon, 1 Oct 2018 21:49:26 +0530 Subject: relative_pointer: send frame event to pointer for Xwayland --- include/wlr/types/wlr_relative_pointer_v1.h | 2 +- types/seat/wlr_seat_pointer.c | 11 +++++++++-- types/wlr_relative_pointer_v1.c | 6 ++---- 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index b2eb7241..22441bb6 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -69,7 +69,7 @@ struct wlr_relative_pointer_v1 { struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl_display *display); void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *relative_pointer_manager); -void wlr_relative_pointer_v1_send_relative_motion(struct wl_resource *resource, +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); #endif diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c index 3c7e98e9..2515fddc 100644 --- a/types/seat/wlr_seat_pointer.c +++ b/types/seat/wlr_seat_pointer.c @@ -315,8 +315,15 @@ void wlr_seat_pointer_notify_relative_motion(struct wlr_seat *wlr_seat, struct wl_resource *resource; wl_resource_for_each(resource, &client->relative_pointers) { - wlr_relative_pointer_v1_send_relative_motion(resource, time, dx, dy, - dx_unaccel, dy_unaccel); + struct wlr_relative_pointer_v1 *relative_pointer = + wl_resource_get_user_data(resource); + if (relative_pointer == NULL) { + continue; + } + + wlr_relative_pointer_v1_send_relative_motion(relative_pointer, time, + dx, dy, dx_unaccel, dy_unaccel); + pointer_send_frame((struct wl_resource *) relative_pointer->pointer); } } diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index 93d96fa4..c5c4650f 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -182,12 +182,10 @@ void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *rel } -void wlr_relative_pointer_v1_send_relative_motion(struct wl_resource *resource, +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) { - assert(wl_resource_instance_of(resource, &zwp_relative_pointer_v1_interface, - &relative_pointer_v1_impl)); - zwp_relative_pointer_v1_send_relative_motion(resource, + 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)); -- cgit v1.2.3 From 68137dca3f0b20c5610a30e4c3820984b387dda5 Mon Sep 17 00:00:00 2001 From: random human Date: Thu, 4 Oct 2018 00:43:35 +0530 Subject: relative_pointer: implementation and code fixes In particular, modified public creator and destructor function names, added a display destroy listener, safely extract user data from resources, send correct time (in usecs) in rootston, etc. --- include/wlr/types/wlr_relative_pointer_v1.h | 32 +++++----- include/wlr/types/wlr_seat.h | 2 +- rootston/cursor.c | 4 +- rootston/desktop.c | 2 +- types/seat/wlr_seat.c | 4 +- types/seat/wlr_seat_pointer.c | 6 +- types/wlr_relative_pointer_v1.c | 91 +++++++++++++++++++++-------- 7 files changed, 92 insertions(+), 49 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index 22441bb6..50106b4b 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -22,12 +22,6 @@ /** * A global interface used for getting the relative pointer object for a given * pointer. - * - * Signals: - * - destroy -> struct wlr_relative_pointer_manager_v1 *manager - * :: the manager was destroyed - * - new_relative_pointer -> struct wlr_relative_pointer_v1 *relative_pointer - * :: a new relative_pointer was created */ struct wlr_relative_pointer_manager_v1 { @@ -36,9 +30,15 @@ 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; } events; + struct wl_listener display_destroy_listener; + void *data; }; @@ -48,16 +48,12 @@ struct wlr_relative_pointer_manager_v1 { * used for emitting relative pointer events. It shares the same focus as * wl_pointer objects of the same seat and will only emit events when it has * focus. - * - * Signals: - * - destroy -> struct wlr_relative_pointer_v1 *relative_pointer - * :: the relative_pointer was destroyed */ struct wlr_relative_pointer_v1 { struct wl_client *client; struct wl_resource *resource; - struct wl_pointer *pointer; + struct wl_resource *pointer; struct { struct wl_signal destroy; @@ -66,10 +62,16 @@ struct wlr_relative_pointer_v1 { void *data; }; -struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl_display *display); -void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *relative_pointer_manager); +struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_manager_v1_create( + struct wl_display *display); +void wlr_relative_pointer_manager_v1_destroy( + struct wlr_relative_pointer_manager_v1 *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); -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_relative_pointer_v1 *wlr_relative_pointer_v1_from_resource( + struct wl_resource *resource); #endif diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 4c0edcd8..9865ecdd 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -27,7 +27,7 @@ struct wlr_seat_client { // lists of wl_resource struct wl_list resources; struct wl_list pointers; - struct wl_list relative_pointers; + struct wl_list relative_pointers_v1; struct wl_list keyboards; struct wl_list touches; struct wl_list data_devices; diff --git a/rootston/cursor.c b/rootston/cursor.c index 45d7b40e..4c5fdb36 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -311,7 +311,7 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor, double dy = event->delta_y; wlr_seat_pointer_notify_relative_motion(cursor->seat->seat, - (uint64_t)event->time_msec, dx, dy, dx, dy); + (uint64_t)event->time_msec * 1000, dx, dy, dx, dy); if (cursor->active_constraint) { struct roots_view *view = cursor->pointer_view->view; @@ -355,7 +355,7 @@ void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor, double dx = lx - cursor->cursor->x; double dy = ly - cursor->cursor->y; wlr_seat_pointer_notify_relative_motion(cursor->seat->seat, - (uint64_t)event->time_msec, dx, dy, dx, dy); + (uint64_t)event->time_msec * 1000, dx, dy, dx, dy); if (cursor->pointer_view) { struct roots_view *view = cursor->pointer_view->view; diff --git a/rootston/desktop.c b/rootston/desktop.c index e4affe3b..77a52571 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -1082,7 +1082,7 @@ struct roots_desktop *desktop_create(struct roots_server *server, desktop->foreign_toplevel_manager_v1 = wlr_foreign_toplevel_manager_v1_create(server->wl_display); desktop->relative_pointer_manager = - wlr_relative_pointer_v1_create(server->wl_display); + wlr_relative_pointer_manager_v1_create(server->wl_display); return desktop; } diff --git a/types/seat/wlr_seat.c b/types/seat/wlr_seat.c index 698a906a..688bfc94 100644 --- a/types/seat/wlr_seat.c +++ b/types/seat/wlr_seat.c @@ -79,7 +79,7 @@ static void seat_client_handle_resource_destroy( wl_resource_for_each_safe(resource, tmp, &client->pointers) { wl_resource_destroy(resource); } - wl_resource_for_each_safe(resource, tmp, &client->relative_pointers) { + wl_resource_for_each_safe(resource, tmp, &client->relative_pointers_v1) { wl_resource_destroy(resource); } wl_resource_for_each_safe(resource, tmp, &client->keyboards) { @@ -134,7 +134,7 @@ static void seat_handle_bind(struct wl_client *client, void *_wlr_seat, seat_client->seat = wlr_seat; wl_list_init(&seat_client->resources); wl_list_init(&seat_client->pointers); - wl_list_init(&seat_client->relative_pointers); + wl_list_init(&seat_client->relative_pointers_v1); wl_list_init(&seat_client->keyboards); wl_list_init(&seat_client->touches); wl_list_init(&seat_client->data_devices); diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c index 2515fddc..8e5fa4db 100644 --- a/types/seat/wlr_seat_pointer.c +++ b/types/seat/wlr_seat_pointer.c @@ -314,16 +314,16 @@ void wlr_seat_pointer_notify_relative_motion(struct wlr_seat *wlr_seat, } struct wl_resource *resource; - wl_resource_for_each(resource, &client->relative_pointers) { + wl_resource_for_each(resource, &client->relative_pointers_v1) { struct wlr_relative_pointer_v1 *relative_pointer = - wl_resource_get_user_data(resource); + wlr_relative_pointer_v1_from_resource(resource); if (relative_pointer == NULL) { continue; } wlr_relative_pointer_v1_send_relative_motion(relative_pointer, time, dx, dy, dx_unaccel, dy_unaccel); - pointer_send_frame((struct wl_resource *) relative_pointer->pointer); + pointer_send_frame(relative_pointer->pointer); } } diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index c5c4650f..fb126f1e 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -9,27 +9,64 @@ #include "wayland-server.h" #include "relative-pointer-unstable-v1-protocol.h" +#define RELATIVE_POINTER_MANAGER_VERSION 1 + static const struct zwp_relative_pointer_manager_v1_interface relative_pointer_manager_v1_impl; static const struct zwp_relative_pointer_v1_interface relative_pointer_v1_impl; /** - * Callback functions + * helper functions */ -static void relative_pointer_manager_v1_handle_resource_destroy(struct wl_resource *resource) { - wl_list_remove(wl_resource_get_link(resource)); +struct wlr_relative_pointer_v1 *relative_pointer_from_resource(struct wl_resource *resource) { + assert(wl_resource_instance_of(resource, &zwp_relative_pointer_v1_interface, + &relative_pointer_v1_impl)); + return wl_resource_get_user_data(resource); } +static struct wlr_relative_pointer_manager_v1 *relative_pointer_manager_from_resource(struct wl_resource *resource) { + assert(wl_resource_instance_of(resource, &zwp_relative_pointer_manager_v1_interface, + &relative_pointer_manager_v1_impl)); + return wl_resource_get_user_data(resource); +} + + +/** + * relative_pointer handler functions + */ + static void relative_pointer_v1_handle_resource_destroy(struct wl_resource *resource) { - wl_list_remove(wl_resource_get_link(resource)); + struct wlr_relative_pointer_v1 *relative_pointer = + relative_pointer_from_resource(resource); + wlr_signal_emit_safe(&relative_pointer->events.destroy, relative_pointer); - struct wlr_relative_pointer_v1 *relative_pointer = wl_resource_get_user_data(resource); + wl_list_remove(wl_resource_get_link(resource)); free(relative_pointer); } +static void relative_pointer_v1_handle_destroy(struct wl_client *client, + struct wl_resource *resource) { + struct wlr_relative_pointer_v1 *relative_pointer = + relative_pointer_from_resource(resource); + wlr_log(WLR_DEBUG, "relative_pointer_v1 %p released by client %p", + relative_pointer, client); + + wl_resource_destroy(resource); +} + + +/** + * relative_pointer_manager handler functions + */ + +static void relative_pointer_manager_v1_handle_resource_destroy(struct wl_resource *resource) { + wl_list_remove(wl_resource_get_link(resource)); +} + + static void relative_pointer_manager_v1_handle_destroy(struct wl_client *client, struct wl_resource *resource) { wl_resource_destroy(resource); @@ -62,18 +99,18 @@ static void relative_pointer_manager_v1_handle_get_relative_pointer(struct wl_cl relative_pointer->client = client; relative_pointer->resource = relative_pointer_resource; - relative_pointer->pointer = (struct wl_pointer *) pointer; + relative_pointer->pointer = pointer; wl_signal_init(&relative_pointer->events.destroy); - wl_list_insert(&seat_client->relative_pointers, + wl_list_insert(&seat_client->relative_pointers_v1, wl_resource_get_link(relative_pointer_resource)); wl_resource_set_implementation(relative_pointer_resource, &relative_pointer_v1_impl, relative_pointer, relative_pointer_v1_handle_resource_destroy); struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = - wl_resource_get_user_data(resource); + relative_pointer_manager_from_resource(resource); wlr_signal_emit_safe(&relative_pointer_manager->events.new_relative_pointer, relative_pointer); @@ -82,17 +119,6 @@ static void relative_pointer_manager_v1_handle_get_relative_pointer(struct wl_cl } -static void relative_pointer_v1_handle_destroy(struct wl_client *client, - struct wl_resource *resource) { - struct wlr_relative_pointer_v1 *relative_pointer = - wl_resource_get_user_data(resource); - wlr_log(WLR_DEBUG, "relative_pointer_v1 %p released by client %p", - relative_pointer, client); - - wl_resource_destroy(resource); -} - - static void relative_pointer_manager_v1_bind(struct wl_client *wl_client, void *data, uint32_t version, uint32_t id) { struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = data; @@ -114,6 +140,12 @@ static void relative_pointer_manager_v1_bind(struct wl_client *wl_client, void * wl_client); } +static void handle_display_destroy(struct wl_listener *listener, void *data) { + struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = + wl_container_of(listener, relative_pointer_manager, display_destroy_listener); + wlr_relative_pointer_manager_v1_destroy(relative_pointer_manager); +} + /** * Implementations @@ -134,7 +166,7 @@ static const struct zwp_relative_pointer_v1_interface relative_pointer_v1_impl = * Public functions */ -struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl_display *display) { +struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_manager_v1_create(struct wl_display *display) { struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = calloc(1, sizeof(struct wlr_relative_pointer_manager_v1)); @@ -144,11 +176,8 @@ struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl wl_list_init(&relative_pointer_manager->resources); - wl_signal_init(&relative_pointer_manager->events.destroy); - wl_signal_init(&relative_pointer_manager->events.new_relative_pointer); - relative_pointer_manager->global = wl_global_create(display, - &zwp_relative_pointer_manager_v1_interface, 1, + &zwp_relative_pointer_manager_v1_interface, RELATIVE_POINTER_MANAGER_VERSION, relative_pointer_manager, relative_pointer_manager_v1_bind); if (relative_pointer_manager->global == NULL) { @@ -156,18 +185,25 @@ struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_v1_create(struct wl return NULL; } + wl_signal_init(&relative_pointer_manager->events.destroy); + wl_signal_init(&relative_pointer_manager->events.new_relative_pointer); + + relative_pointer_manager->display_destroy_listener.notify = handle_display_destroy; + wl_display_add_destroy_listener(display, &relative_pointer_manager->display_destroy_listener); + wlr_log(WLR_DEBUG, "relative_pointer_v1 manager created"); return relative_pointer_manager; } -void wlr_relative_pointer_v1_destroy(struct wlr_relative_pointer_manager_v1 *relative_pointer_manager) { +void wlr_relative_pointer_manager_v1_destroy(struct wlr_relative_pointer_manager_v1 *relative_pointer_manager) { if (relative_pointer_manager == NULL) { return; } wlr_signal_emit_safe(&relative_pointer_manager->events.destroy, relative_pointer_manager); + wl_list_remove(&relative_pointer_manager->display_destroy_listener.link); struct wl_resource *resource; struct wl_resource *tmp_resource; @@ -190,3 +226,8 @@ void wlr_relative_pointer_v1_send_relative_motion(struct wlr_relative_pointer_v1 wl_fixed_from_double(dx), wl_fixed_from_double(dy), wl_fixed_from_double(dx_unaccel), wl_fixed_from_double(dy_unaccel)); } + + +struct wlr_relative_pointer_v1 *wlr_relative_pointer_v1_from_resource(struct wl_resource *resource) { + return relative_pointer_from_resource(resource); +} -- cgit v1.2.3 From a2964a640bbcbe4e8e9c0f9ad0b7913227e9a3a0 Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Sun, 9 Dec 2018 19:59:00 -0600 Subject: Add wlr_relative_pointer_v1.h to meson.build --- include/wlr/types/meson.build | 1 + 1 file changed, 1 insertion(+) (limited to 'include/wlr') diff --git a/include/wlr/types/meson.build b/include/wlr/types/meson.build index 752c0dea..dfb55ec9 100644 --- a/include/wlr/types/meson.build +++ b/include/wlr/types/meson.build @@ -27,6 +27,7 @@ install_headers( 'wlr_presentation_time.h', 'wlr_primary_selection.h', 'wlr_region.h', + 'wlr_relative_pointer_v1.h', 'wlr_screencopy_v1.h', 'wlr_screenshooter.h', 'wlr_seat.h', -- cgit v1.2.3 From f4cf3c08865e39e88061c96e823b2893a68a433f Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Thu, 13 Dec 2018 02:19:55 -0600 Subject: Remove wl_client from wlr_relative_pointer_v1 --- include/wlr/types/wlr_relative_pointer_v1.h | 1 - types/wlr_relative_pointer_v1.c | 1 - 2 files changed, 2 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index 50106b4b..24b20003 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -51,7 +51,6 @@ struct wlr_relative_pointer_manager_v1 { */ struct wlr_relative_pointer_v1 { - struct wl_client *client; struct wl_resource *resource; struct wl_resource *pointer; diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index fb126f1e..ed01b433 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -97,7 +97,6 @@ static void relative_pointer_manager_v1_handle_get_relative_pointer(struct wl_cl return; } - relative_pointer->client = client; relative_pointer->resource = relative_pointer_resource; relative_pointer->pointer = pointer; -- cgit v1.2.3 From 09bdbf24f4fc44cfbb9bd6079a1d7cd08edaefdb Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Thu, 13 Dec 2018 23:41:21 -0600 Subject: Removed relative pointers from wlr_seat --- include/wlr/types/wlr_relative_pointer_v1.h | 5 ++++- include/wlr/types/wlr_seat.h | 1 - rootston/cursor.c | 32 +++++++++++++++++++++++++++-- types/seat/wlr_seat.c | 4 ---- types/seat/wlr_seat_pointer.c | 22 -------------------- types/wlr_relative_pointer_v1.c | 9 +++++--- 6 files changed, 40 insertions(+), 33 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index 24b20003..1fd6e610 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -25,8 +25,9 @@ */ struct wlr_relative_pointer_manager_v1 { - struct wl_list resources; struct wl_global *global; + struct wl_list resources; + struct wl_list relative_pointers; struct { struct wl_signal destroy; @@ -52,7 +53,9 @@ struct wlr_relative_pointer_manager_v1 { struct wlr_relative_pointer_v1 { struct wl_resource *resource; + struct wlr_seat *seat; struct wl_resource *pointer; + struct wl_list link; // wlr_relative_pointer_manager_v1::relative_pointers struct { struct wl_signal destroy; diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 9865ecdd..48c48d73 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -27,7 +27,6 @@ struct wlr_seat_client { // lists of wl_resource struct wl_list resources; struct wl_list pointers; - struct wl_list relative_pointers_v1; struct wl_list keyboards; struct wl_list touches; struct wl_list data_devices; diff --git a/rootston/cursor.c b/rootston/cursor.c index 4c5fdb36..87f35435 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -305,12 +305,39 @@ static void roots_cursor_press_button(struct roots_cursor *cursor, } } +static void notify_relative_motion(struct roots_seat *seat, uint64_t time_msec, + double dx, double dy, double dx_unaccel, double dy_unaccel) { + + struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = + seat->input->server->desktop->relative_pointer_manager; + + struct wlr_seat_client *client = seat->seat->pointer_state.focused_client; + if (client == NULL) { + return; + } + + struct wl_resource *resource; + wl_resource_for_each(resource, &relative_pointer_manager->relative_pointers) { + + struct wlr_relative_pointer_v1 *pointer = + wlr_relative_pointer_v1_from_resource(resource); + if (pointer == NULL) { + continue; + } + + wlr_relative_pointer_v1_send_relative_motion(pointer, time_msec, + dx, dy, dx_unaccel, dy_unaccel); + wl_pointer_send_frame(pointer->pointer); + } + +} + void roots_cursor_handle_motion(struct roots_cursor *cursor, struct wlr_event_pointer_motion *event) { double dx = event->delta_x; double dy = event->delta_y; - wlr_seat_pointer_notify_relative_motion(cursor->seat->seat, + notify_relative_motion(cursor->seat, (uint64_t)event->time_msec * 1000, dx, dy, dx, dy); if (cursor->active_constraint) { @@ -354,7 +381,8 @@ void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor, double dx = lx - cursor->cursor->x; double dy = ly - cursor->cursor->y; - wlr_seat_pointer_notify_relative_motion(cursor->seat->seat, + + notify_relative_motion(cursor->seat, (uint64_t)event->time_msec * 1000, dx, dy, dx, dy); if (cursor->pointer_view) { diff --git a/types/seat/wlr_seat.c b/types/seat/wlr_seat.c index 688bfc94..8b1d67fd 100644 --- a/types/seat/wlr_seat.c +++ b/types/seat/wlr_seat.c @@ -79,9 +79,6 @@ static void seat_client_handle_resource_destroy( wl_resource_for_each_safe(resource, tmp, &client->pointers) { wl_resource_destroy(resource); } - wl_resource_for_each_safe(resource, tmp, &client->relative_pointers_v1) { - wl_resource_destroy(resource); - } wl_resource_for_each_safe(resource, tmp, &client->keyboards) { wl_resource_destroy(resource); } @@ -134,7 +131,6 @@ static void seat_handle_bind(struct wl_client *client, void *_wlr_seat, seat_client->seat = wlr_seat; wl_list_init(&seat_client->resources); wl_list_init(&seat_client->pointers); - wl_list_init(&seat_client->relative_pointers_v1); wl_list_init(&seat_client->keyboards); wl_list_init(&seat_client->touches); wl_list_init(&seat_client->data_devices); diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c index 8e5fa4db..936ac0dc 100644 --- a/types/seat/wlr_seat_pointer.c +++ b/types/seat/wlr_seat_pointer.c @@ -305,28 +305,6 @@ void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, uint32_t time, grab->interface->motion(grab, time, sx, sy); } -void wlr_seat_pointer_notify_relative_motion(struct wlr_seat *wlr_seat, - uint64_t time, double dx, double dy, - double dx_unaccel, double dy_unaccel) { - struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client; - if (client == NULL) { - return; - } - - struct wl_resource *resource; - wl_resource_for_each(resource, &client->relative_pointers_v1) { - struct wlr_relative_pointer_v1 *relative_pointer = - wlr_relative_pointer_v1_from_resource(resource); - if (relative_pointer == NULL) { - continue; - } - - wlr_relative_pointer_v1_send_relative_motion(relative_pointer, time, - dx, dy, dx_unaccel, dy_unaccel); - pointer_send_frame(relative_pointer->pointer); - } -} - uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, uint32_t time, uint32_t button, uint32_t state) { clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event); diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index ed01b433..ef937829 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -98,18 +98,20 @@ 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); - wl_list_insert(&seat_client->relative_pointers_v1, - wl_resource_get_link(relative_pointer_resource)); - wl_resource_set_implementation(relative_pointer_resource, &relative_pointer_v1_impl, relative_pointer, relative_pointer_v1_handle_resource_destroy); struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = relative_pointer_manager_from_resource(resource); + + wl_list_insert(&relative_pointer_manager->relative_pointers, + wl_resource_get_link(relative_pointer_resource)); + wlr_signal_emit_safe(&relative_pointer_manager->events.new_relative_pointer, relative_pointer); @@ -174,6 +176,7 @@ struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_manager_v1_create(s } wl_list_init(&relative_pointer_manager->resources); + wl_list_init(&relative_pointer_manager->relative_pointers); relative_pointer_manager->global = wl_global_create(display, &zwp_relative_pointer_manager_v1_interface, RELATIVE_POINTER_MANAGER_VERSION, -- cgit v1.2.3 From f5ea393bca7a427c0d97217c67b0be563b28dc19 Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Fri, 14 Dec 2018 09:42:24 -0600 Subject: Remove pointer resource from relative pointer --- include/wlr/types/wlr_relative_pointer_v1.h | 1 - rootston/cursor.c | 8 +++++++- types/wlr_relative_pointer_v1.c | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index 1fd6e610..6f2e0878 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -54,7 +54,6 @@ struct wlr_relative_pointer_manager_v1 { struct wlr_relative_pointer_v1 { struct wl_resource *resource; struct wlr_seat *seat; - struct wl_resource *pointer; struct wl_list link; // wlr_relative_pointer_manager_v1::relative_pointers struct { diff --git a/rootston/cursor.c b/rootston/cursor.c index e34fe4b2..ba8d0860 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -327,7 +327,13 @@ static void notify_relative_motion(struct roots_seat *seat, uint64_t time_msec, wlr_relative_pointer_v1_send_relative_motion(pointer, time_msec, dx, dy, dx_unaccel, dy_unaccel); - wl_pointer_send_frame(pointer->pointer); + } + + wl_resource_for_each(resource, &client->pointers) { + if (wlr_seat_client_from_pointer_resource(resource) == NULL) { + continue; + } + wl_pointer_send_frame(resource); } } diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index ef937829..e5568f5f 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -99,7 +99,6 @@ 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); -- cgit v1.2.3 From a803a007fb9c572e0eccc22ab670ac711cb89b13 Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Mon, 17 Dec 2018 14:04:49 -0600 Subject: Address @emersion's comments --- include/wlr/types/wlr_relative_pointer_v1.h | 8 ++-- include/wlr/types/wlr_seat.h | 13 ------- rootston/cursor.c | 20 +++------- types/seat/wlr_seat_pointer.c | 1 - types/wlr_relative_pointer_v1.c | 59 +++++++++++++++++++++-------- 5 files changed, 53 insertions(+), 48 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index 6f2e0878..292be238 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -15,7 +15,7 @@ /** * This protocol specifies a set of interfaces used for making clients able to * receive relative pointer events not obstructed by barriers (such as the - * monitor edge or other pointer barriers). + * monitor edge or pointer constraints). */ @@ -26,7 +26,7 @@ struct wlr_relative_pointer_manager_v1 { struct wl_global *global; - struct wl_list resources; + struct wl_list resources; // wl_resource_get_link() struct wl_list relative_pointers; struct { @@ -60,6 +60,8 @@ struct wlr_relative_pointer_v1 { struct wl_signal destroy; } events; + struct wl_listener seat_destroy; + void *data; }; @@ -69,7 +71,7 @@ void wlr_relative_pointer_manager_v1_destroy( struct wlr_relative_pointer_manager_v1 *relative_pointer_manager); void wlr_relative_pointer_v1_send_relative_motion( - struct wlr_relative_pointer_v1 *relative_pointer, uint64_t time, + struct wlr_relative_pointer_v1 *relative_pointer, uint64_t time_msec, double dx, double dy, double dx_unaccel, double dy_unaccel); struct wlr_relative_pointer_v1 *wlr_relative_pointer_v1_from_resource( diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 48c48d73..942a3420 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -313,19 +313,6 @@ void wlr_seat_pointer_clear_focus(struct wlr_seat *wlr_seat); void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time, double sx, double sy); -/** - * Send relative motion events to the surface with pointer focus. Coordinates - * for the motion event are relative to current pointer location, both - * accelerated and unaccelerated. Compositors should use - * `wlr_seat_pointer_notify_relative_motion()` to send relative motion events - * to respect relative pointer requests by clients. - * - * Note that the timestamp is 64 bit, split into high 32 bits and low 32 bits. - */ -void wlr_seat_pointer_notify_relative_motion(struct wlr_seat *wlr_seat, - uint64_t time, double dx, double dy, - double dx_unaccel, double dy_unaccel); - /** * Send a button event to the surface with pointer focus. Coordinates for the * button event are surface-local. Returns the serial. Compositors should use diff --git a/rootston/cursor.c b/rootston/cursor.c index ba8d0860..16fb9c70 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -307,7 +307,6 @@ static void roots_cursor_press_button(struct roots_cursor *cursor, static void notify_relative_motion(struct roots_seat *seat, uint64_t time_msec, double dx, double dy, double dx_unaccel, double dy_unaccel) { - struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = seat->input->server->desktop->relative_pointer_manager; @@ -316,26 +315,15 @@ static void notify_relative_motion(struct roots_seat *seat, uint64_t time_msec, return; } - struct wl_resource *resource; - wl_resource_for_each(resource, &relative_pointer_manager->relative_pointers) { - - struct wlr_relative_pointer_v1 *pointer = - wlr_relative_pointer_v1_from_resource(resource); - if (pointer == NULL || seat->seat != pointer->seat) { + struct wlr_relative_pointer_v1 *pointer; + wl_list_for_each(pointer, &relative_pointer_manager->relative_pointers, link) { + if (seat->seat != pointer->seat) { continue; } wlr_relative_pointer_v1_send_relative_motion(pointer, time_msec, dx, dy, dx_unaccel, dy_unaccel); } - - wl_resource_for_each(resource, &client->pointers) { - if (wlr_seat_client_from_pointer_resource(resource) == NULL) { - continue; - } - wl_pointer_send_frame(resource); - } - } void roots_cursor_handle_motion(struct roots_cursor *cursor, @@ -343,6 +331,7 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor, double dx = event->delta_x; double dy = event->delta_y; + /* TODO send unaccelerated values */ notify_relative_motion(cursor->seat, (uint64_t)event->time_msec * 1000, dx, dy, dx, dy); @@ -388,6 +377,7 @@ void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor, double dx = lx - cursor->cursor->x; double dy = ly - cursor->cursor->y; + /* TODO send unaccelerated values */ notify_relative_motion(cursor->seat, (uint64_t)event->time_msec * 1000, dx, dy, dx, dy); diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c index 936ac0dc..594a5b81 100644 --- a/types/seat/wlr_seat_pointer.c +++ b/types/seat/wlr_seat_pointer.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include "types/wlr_seat.h" #include "util/signal.h" diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index e5568f5f..6f686431 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -19,7 +19,7 @@ static const struct zwp_relative_pointer_v1_interface relative_pointer_v1_impl; * helper functions */ -struct wlr_relative_pointer_v1 *relative_pointer_from_resource(struct wl_resource *resource) { +struct wlr_relative_pointer_v1 *wlr_relative_pointer_v1_from_resource(struct wl_resource *resource) { assert(wl_resource_instance_of(resource, &zwp_relative_pointer_v1_interface, &relative_pointer_v1_impl)); return wl_resource_get_user_data(resource); @@ -37,26 +37,42 @@ static struct wlr_relative_pointer_manager_v1 *relative_pointer_manager_from_res * relative_pointer handler functions */ -static void relative_pointer_v1_handle_resource_destroy(struct wl_resource *resource) { - struct wlr_relative_pointer_v1 *relative_pointer = - relative_pointer_from_resource(resource); +static void relative_pointer_destroy(struct wlr_relative_pointer_v1 *relative_pointer) { wlr_signal_emit_safe(&relative_pointer->events.destroy, relative_pointer); - wl_list_remove(wl_resource_get_link(resource)); + wl_list_remove(&relative_pointer->link); + wl_list_remove(&relative_pointer->seat_destroy.link); free(relative_pointer); } +static void relative_pointer_v1_handle_resource_destroy(struct wl_resource *resource) { + struct wlr_relative_pointer_v1 *relative_pointer = + wlr_relative_pointer_v1_from_resource(resource); + if (relative_pointer == NULL) { + return; + } + relative_pointer_destroy(relative_pointer); +} + static void relative_pointer_v1_handle_destroy(struct wl_client *client, struct wl_resource *resource) { struct wlr_relative_pointer_v1 *relative_pointer = - relative_pointer_from_resource(resource); + wlr_relative_pointer_v1_from_resource(resource); wlr_log(WLR_DEBUG, "relative_pointer_v1 %p released by client %p", relative_pointer, client); wl_resource_destroy(resource); } +static void relative_pointer_handle_seat_destroy(struct wl_listener *listener, + void *data) { + struct wlr_relative_pointer_v1 *relative_pointer = + wl_container_of(listener, relative_pointer, seat_destroy); + + relative_pointer_destroy(relative_pointer); + wl_resource_set_user_data(relative_pointer->resource, NULL); +} /** * relative_pointer_manager handler functions @@ -75,12 +91,10 @@ static void relative_pointer_manager_v1_handle_destroy(struct wl_client *client, client); } - static void relative_pointer_manager_v1_handle_get_relative_pointer(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *pointer) { struct wlr_seat_client *seat_client = wlr_seat_client_from_pointer_resource(pointer); - assert(seat_client->client == client); struct wlr_relative_pointer_v1 *relative_pointer = calloc(1, sizeof(struct wlr_relative_pointer_v1)); @@ -109,7 +123,11 @@ static void relative_pointer_manager_v1_handle_get_relative_pointer(struct wl_cl relative_pointer_manager_from_resource(resource); wl_list_insert(&relative_pointer_manager->relative_pointers, - wl_resource_get_link(relative_pointer_resource)); + &relative_pointer->link); + + wl_signal_add(&relative_pointer->seat->events.destroy, + &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, relative_pointer); @@ -141,9 +159,9 @@ static void relative_pointer_manager_v1_bind(struct wl_client *wl_client, void * } static void handle_display_destroy(struct wl_listener *listener, void *data) { - struct wlr_relative_pointer_manager_v1 *relative_pointer_manager = - wl_container_of(listener, relative_pointer_manager, display_destroy_listener); - wlr_relative_pointer_manager_v1_destroy(relative_pointer_manager); + struct wlr_relative_pointer_manager_v1 *manager = + wl_container_of(listener, manager, display_destroy_listener); + wlr_relative_pointer_manager_v1_destroy(manager); } @@ -222,13 +240,22 @@ 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 wlr_relative_pointer_v1 *wlr_relative_pointer_v1_from_resource(struct wl_resource *resource) { - return relative_pointer_from_resource(resource); + 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); + } } -- cgit v1.2.3 From e276d310e81c6bebf883ff3eeff5210d306b1c57 Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Mon, 17 Dec 2018 14:24:07 -0600 Subject: Add unaccelerated pointer values to wlr_event_pointer_motion events --- backend/libinput/pointer.c | 2 ++ include/wlr/types/wlr_pointer.h | 1 + rootston/cursor.c | 7 ++++--- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'include/wlr') diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index fb85cddd..b9cf1dfe 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -36,6 +36,8 @@ void handle_pointer_motion(struct libinput_event *event, usec_to_msec(libinput_event_pointer_get_time_usec(pevent)); wlr_event.delta_x = libinput_event_pointer_get_dx(pevent); wlr_event.delta_y = libinput_event_pointer_get_dy(pevent); + wlr_event.unaccel_dx = libinput_event_pointer_get_dx_unaccelerated(pevent); + wlr_event.unaccel_dy = libinput_event_pointer_get_dy_unaccelerated(pevent); wlr_signal_emit_safe(&wlr_dev->pointer->events.motion, &wlr_event); } diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h index 7dc643ae..6da4c02a 100644 --- a/include/wlr/types/wlr_pointer.h +++ b/include/wlr/types/wlr_pointer.h @@ -32,6 +32,7 @@ struct wlr_event_pointer_motion { struct wlr_input_device *device; uint32_t time_msec; double delta_x, delta_y; + double unaccel_dx, unaccel_dy; }; struct wlr_event_pointer_motion_absolute { diff --git a/rootston/cursor.c b/rootston/cursor.c index 16fb9c70..ffb38816 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -331,9 +331,11 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor, double dx = event->delta_x; double dy = event->delta_y; - /* TODO send unaccelerated values */ + double unaccel_dx = event->unaccel_dx; + double unaccel_dy = event->unaccel_dy; + notify_relative_motion(cursor->seat, - (uint64_t)event->time_msec * 1000, dx, dy, dx, dy); + (uint64_t)event->time_msec * 1000, dx, dy, unaccel_dx, unaccel_dy); if (cursor->active_constraint) { struct roots_view *view = cursor->pointer_view->view; @@ -377,7 +379,6 @@ void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor, double dx = lx - cursor->cursor->x; double dy = ly - cursor->cursor->y; - /* TODO send unaccelerated values */ notify_relative_motion(cursor->seat, (uint64_t)event->time_msec * 1000, dx, dy, dx, dy); -- cgit v1.2.3 From 12d9edc0c92c321a43331f23854e3de2e84a6aa0 Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Mon, 17 Dec 2018 16:58:31 -0600 Subject: 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(-) (limited to 'include/wlr') 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); } -- cgit v1.2.3 From 5999d0322b63c4dd9f2cd902c2b798fc4df77116 Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Wed, 19 Dec 2018 11:32:36 -0600 Subject: Add a listener for when the pointer gets destroyed --- include/wlr/types/wlr_relative_pointer_v1.h | 1 + types/wlr_relative_pointer_v1.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index 1bc85b05..cc4b2746 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -58,6 +58,7 @@ struct wlr_relative_pointer_v1 { } events; struct wl_listener seat_destroy; + struct wl_listener pointer_destroy; void *data; }; diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index 9d12bd93..4d3620bd 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -75,6 +75,14 @@ static void relative_pointer_handle_seat_destroy(struct wl_listener *listener, relative_pointer_destroy(relative_pointer); } +static void relative_pointer_handle_pointer_destroy(struct wl_listener *listener, + void *data) { + struct wlr_relative_pointer_v1 *relative_pointer = + wl_container_of(listener, relative_pointer, pointer_destroy); + + relative_pointer_destroy(relative_pointer); +} + /** * relative_pointer_manager handler functions */ @@ -129,10 +137,12 @@ 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; + wl_resource_add_destroy_listener(relative_pointer->pointer, + &relative_pointer->pointer_destroy); + relative_pointer->pointer_destroy.notify = relative_pointer_handle_pointer_destroy; + wlr_signal_emit_safe(&relative_pointer_manager->events.new_relative_pointer, relative_pointer); -- cgit v1.2.3 From 8b97c20d01a869497d5e0545319597b3b57e79c2 Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Wed, 2 Jan 2019 11:46:13 -0600 Subject: Finish addressing @emersion's comments --- include/wlr/types/wlr_relative_pointer_v1.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_relative_pointer_v1.h b/include/wlr/types/wlr_relative_pointer_v1.h index cc4b2746..f9f91219 100644 --- a/include/wlr/types/wlr_relative_pointer_v1.h +++ b/include/wlr/types/wlr_relative_pointer_v1.h @@ -27,7 +27,7 @@ struct wlr_relative_pointer_manager_v1 { struct wl_global *global; struct wl_list resources; // wl_resource_get_link() - struct wl_list relative_pointers; + struct wl_list relative_pointers; // wlr_relative_pointer_v1::link struct { struct wl_signal destroy; @@ -68,6 +68,9 @@ struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_manager_v1_create( void wlr_relative_pointer_manager_v1_destroy( struct wlr_relative_pointer_manager_v1 *relative_pointer_manager); +/** + * Send a relative motion event to the seat with the same wl_pointer as relative_pointer + */ void wlr_relative_pointer_v1_send_relative_motion( struct wlr_relative_pointer_v1 *relative_pointer, uint64_t time_msec, double dx, double dy, double dx_unaccel, double dy_unaccel); -- cgit v1.2.3