mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
Removed relative pointers from wlr_seat
This commit is contained in:
parent
f4cf3c0886
commit
09bdbf24f4
6 changed files with 40 additions and 33 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue