]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: add relative cursor move emulation
authorJens Peters <jp7677@gmail.com>
Wed, 3 Jul 2024 19:14:43 +0000 (21:14 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 19 Jul 2024 21:45:41 +0000 (22:45 +0100)
include/input/cursor.h
src/input/cursor.c

index e9ad4fa26889cc048786f8010dab4c84ef04d1f6..8087c49a0d55db3f3b54f8d173a49768b396dafd 100644 (file)
@@ -146,6 +146,9 @@ bool cursor_finish_button_release(struct seat *seat);
 
 void cursor_init(struct seat *seat);
 void cursor_reload(struct seat *seat);
+void cursor_emulate_move(struct seat *seat,
+               struct wlr_input_device *device,
+               double dx, double dy, uint32_t time_msec);
 void cursor_emulate_move_absolute(struct seat *seat,
                struct wlr_input_device *device,
                double x, double y, uint32_t time_msec);
index 6bda5a30d8b52df4fc1e52b5968c3c5c92778663..0a705068ffd2049b8c37162ad0a6b97eb2cf42ea 100644 (file)
@@ -1174,18 +1174,9 @@ cursor_button(struct wl_listener *listener, void *data)
 }
 
 void
-cursor_emulate_move_absolute(struct seat *seat, struct wlr_input_device *device,
-               double x, double y, uint32_t time_msec)
+cursor_emulate_move(struct seat *seat, struct wlr_input_device *device,
+               double dx, double dy, uint32_t time_msec)
 {
-       idle_manager_notify_activity(seat->seat);
-
-       double lx, ly;
-       wlr_cursor_absolute_to_layout_coords(seat->cursor,
-               device, x, y, &lx, &ly);
-
-       double dx = lx - seat->cursor->x;
-       double dy = ly - seat->cursor->y;
-
        if (!dx && !dy) {
                wlr_log(WLR_DEBUG, "dropping useless cursor_emulate: %.10f,%.10f", dx, dy);
                return;
@@ -1205,6 +1196,22 @@ cursor_emulate_move_absolute(struct seat *seat, struct wlr_input_device *device,
        wlr_seat_pointer_notify_frame(seat->seat);
 }
 
+void
+cursor_emulate_move_absolute(struct seat *seat, struct wlr_input_device *device,
+               double x, double y, uint32_t time_msec)
+{
+       idle_manager_notify_activity(seat->seat);
+
+       double lx, ly;
+       wlr_cursor_absolute_to_layout_coords(seat->cursor,
+               device, x, y, &lx, &ly);
+
+       double dx = lx - seat->cursor->x;
+       double dy = ly - seat->cursor->y;
+
+       cursor_emulate_move(seat, device, dx, dy, time_msec);
+}
+
 void
 cursor_emulate_button(struct seat *seat, uint32_t button,
                enum wl_pointer_button_state state, uint32_t time_msec)