]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: Handle absolute motion for relative_pointer
authorJoshua Ashton <joshua@froggi.es>
Sun, 17 Oct 2021 21:57:10 +0000 (21:57 +0000)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 17 Oct 2021 22:21:27 +0000 (23:21 +0100)
Signed-off-by: Joshua Ashton <joshua@froggi.es>
src/cursor.c

index 5fc711d8b3f3c0a11911d6ae3c6dedd724fce5da..ec748dba942efe21185a989fee3cda34459e19af 100644 (file)
@@ -367,7 +367,30 @@ cursor_motion_absolute(struct wl_listener *listener, void *data)
        struct seat *seat = wl_container_of(
                listener, seat, cursor_motion_absolute);
        struct wlr_event_pointer_motion_absolute *event = data;
-       wlr_cursor_warp_absolute(seat->cursor, event->device, event->x, event->y);
+
+       double lx, ly;
+       wlr_cursor_absolute_to_layout_coords(seat->cursor, event->device,
+                       event->x, event->y, &lx, &ly);
+
+       double dx = lx - seat->cursor->x;
+       double dy = ly - seat->cursor->y;
+
+       wlr_relative_pointer_manager_v1_send_relative_motion(
+               seat->server->relative_pointer_manager,
+               seat->seat, (uint64_t)event->time_msec * 1000,
+               dx, dy, dx, dy);
+
+       if (!seat->current_constraint) {
+               /*
+                * The cursor doesn't move unless we tell it to. The cursor
+                * automatically handles constraining the motion to the output layout,
+                * as well as any special configuration applied for the specific input
+                * device which generated the event. You can pass NULL for the device
+                * if you want to move the cursor around without any input.
+                */
+               wlr_cursor_move(seat->cursor, event->device, dx, dy);
+       }
+
        process_cursor_motion(seat->server, event->time_msec);
 }