Store more information about axis events from Wayland

This commit is contained in:
Kovid Goyal 2026-01-01 13:25:30 +05:30
parent cef2bac116
commit 0f1362524b
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 26 additions and 4 deletions

26
glfw/wl_init.c vendored
View file

@ -193,7 +193,10 @@ static void
pointer_handle_axis(void *data UNUSED, struct wl_pointer *pointer UNUSED, uint32_t time, uint32_t axis, wl_fixed_t value) {
_GLFWwindow* window = _glfw.wl.pointerFocus;
if (!window) return;
if (!info.timestamp_ns) info.timestamp_ns = ms_to_monotonic_t(time);
switch (axis) {
case WL_POINTER_AXIS_VERTICAL_SCROLL: if (!info.y_start_time) info.y_start_time = ms_to_monotonic_t(time); break;
case WL_POINTER_AXIS_HORIZONTAL_SCROLL: if (!info.x_start_time) info.x_start_time = ms_to_monotonic_t(time); break;
}
pointer_handle_axis_common(AXIS_EVENT_CONTINUOUS, axis, value);
}
@ -230,10 +233,27 @@ pointer_handle_frame(void *data UNUSED, struct wl_pointer *pointer UNUSED) {
}
static void
pointer_handle_axis_source(void* data UNUSED, struct wl_pointer* pointer UNUSED, uint32_t source UNUSED) { }
pointer_handle_axis_source(void* data UNUSED, struct wl_pointer* pointer UNUSED, uint32_t source) {
_GLFWwindow* window = _glfw.wl.pointerFocus;
if (!window) return;
info.source_type = source;
}
static void
pointer_handle_axis_stop(void *data UNUSED, struct wl_pointer *wl_pointer UNUSED, uint32_t time UNUSED, uint32_t axis UNUSED) { }
pointer_handle_axis_stop(void *data UNUSED, struct wl_pointer *wl_pointer UNUSED, uint32_t time UNUSED, uint32_t axis) {
_GLFWwindow* window = _glfw.wl.pointerFocus;
if (!window) return;
switch (axis) {
case WL_POINTER_AXIS_VERTICAL_SCROLL:
info.y_stop_received = true;
info.y_stop_time = ms_to_monotonic_t(time);
break;
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
info.x_stop_received = true;
info.x_stop_time = ms_to_monotonic_t(time);
break;
}
}
static void

4
glfw/wl_platform.h vendored
View file

@ -207,7 +207,9 @@ typedef struct _GLFWwindowWayland
} discrete, continuous;
/* Event timestamp in nanoseconds */
monotonic_t timestamp_ns;
bool x_stop_received, y_stop_received;
uint32_t source_type;
monotonic_t x_start_time, x_stop_time, y_stop_time, y_start_time;
} pointer_curr_axis_info;
_GLFWcursor* currentCursor;