mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-29 16:05:59 +01:00
relative_pointer: implement protocol events
Implement zwp_relative_pointer_v1.relative_motion event, along with some glue code in wlr_seat_pointer and rootston.
This commit is contained in:
parent
ba5b1676df
commit
d020344675
5 changed files with 52 additions and 0 deletions
|
@ -66,4 +66,8 @@ struct wlr_relative_pointer_v1 {
|
||||||
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);
|
||||||
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);
|
||||||
|
|
||||||
|
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
|
#endif
|
||||||
|
|
|
@ -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,
|
void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
double sx, double sy);
|
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
|
* Send a button event to the surface with pointer focus. Coordinates for the
|
||||||
* button event are surface-local. Returns the serial. Compositors should use
|
* button event are surface-local. Returns the serial. Compositors should use
|
||||||
|
|
|
@ -310,6 +310,9 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor,
|
||||||
double dx = event->delta_x;
|
double dx = event->delta_x;
|
||||||
double dy = event->delta_y;
|
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) {
|
if (cursor->active_constraint) {
|
||||||
struct roots_view *view = cursor->pointer_view->view;
|
struct roots_view *view = cursor->pointer_view->view;
|
||||||
assert(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,
|
wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device, event->x,
|
||||||
event->y, &lx, &ly);
|
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) {
|
if (cursor->pointer_view) {
|
||||||
struct roots_view *view = cursor->pointer_view->view;
|
struct roots_view *view = cursor->pointer_view->view;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
#include <wlr/types/wlr_input_device.h>
|
#include <wlr/types/wlr_input_device.h>
|
||||||
|
#include <wlr/types/wlr_relative_pointer_v1.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "types/wlr_seat.h"
|
#include "types/wlr_seat.h"
|
||||||
#include "util/signal.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);
|
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 wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat,
|
||||||
uint32_t time, uint32_t button, uint32_t state) {
|
uint32_t time, uint32_t button, uint32_t state) {
|
||||||
clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event);
|
clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event);
|
||||||
|
|
|
@ -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");
|
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));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue