aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_relative_pointer_v1.h4
-rw-r--r--include/wlr/types/wlr_seat.h12
-rw-r--r--rootston/cursor.c8
-rw-r--r--types/seat/wlr_seat_pointer.c15
-rw-r--r--types/wlr_relative_pointer_v1.c13
5 files changed, 52 insertions, 0 deletions
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 <time.h>
#include <wayland-server.h>
#include <wlr/types/wlr_input_device.h>
+#include <wlr/types/wlr_relative_pointer_v1.h>
#include <wlr/util/log.h>
#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));
+}