commit 35d8564f9c4105df3e6f8f16ee323a55b3e027e6
parent 5d32737e4f0e89ae68d3d4d85743f70c177ce5b5
Author: wh1tepearl <whp@disroot.org>
Date: Fri, 4 Sep 2026 20:45:45 +0100
pointer: add swc_cursor_set_position function
Add swc_cursor_set_position function so a compositor will be able to set pointer position.
Diffstat:
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/libswc/swc.c b/libswc/swc.c
@@ -153,6 +153,20 @@ swc_cursor_position(int32_t *x, int32_t *y)
}
EXPORT bool
+swc_cursor_set_position(int32_t x, int32_t y)
+{
+ if (!swc.seat || !swc.seat->pointer) {
+ return false;
+ }
+
+ pointer_handle_absolute_motion(swc.seat->pointer, get_time(),
+ wl_fixed_from_int(x), wl_fixed_from_int(y));
+ pointer_handle_frame(swc.seat->pointer);
+
+ return true;
+}
+
+EXPORT bool
swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop,
const struct swc_manager *manager)
{
diff --git a/libswc/swc.h b/libswc/swc.h
@@ -49,6 +49,16 @@ bool
swc_cursor_position(int32_t *x, int32_t *y);
/**
+ * Set the cursor position.
+ *
+ * The coordinates are in compositor-global space, exposed as raw int32_t
+ * to avoid needing wayland headers. This has the same effect as the
+ * cursor being moved there by an input device.
+ */
+bool
+swc_cursor_set_position(int32_t x, int32_t y);
+
+/**
* Send a pointer button event to the currently focused client.
*
* This is intended for window managers which intercept button events (for