From: Jens Peters Date: Wed, 3 Jul 2024 19:14:43 +0000 (+0200) Subject: input: add relative cursor move emulation X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=ba9de228e06e81b457dfdd52860173317c8f5773;p=proto%2Flabwc.git input: add relative cursor move emulation --- diff --git a/include/input/cursor.h b/include/input/cursor.h index e9ad4fa2..8087c49a 100644 --- a/include/input/cursor.h +++ b/include/input/cursor.h @@ -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); diff --git a/src/input/cursor.c b/src/input/cursor.c index 6bda5a30..0a705068 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -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)