Skip to content

Commit 0f13625

Browse files
committed
Store more information about axis events from Wayland
1 parent cef2bac commit 0f13625

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

glfw/wl_init.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ static void
193193
pointer_handle_axis(void *data UNUSED, struct wl_pointer *pointer UNUSED, uint32_t time, uint32_t axis, wl_fixed_t value) {
194194
_GLFWwindow* window = _glfw.wl.pointerFocus;
195195
if (!window) return;
196-
if (!info.timestamp_ns) info.timestamp_ns = ms_to_monotonic_t(time);
196+
switch (axis) {
197+
case WL_POINTER_AXIS_VERTICAL_SCROLL: if (!info.y_start_time) info.y_start_time = ms_to_monotonic_t(time); break;
198+
case WL_POINTER_AXIS_HORIZONTAL_SCROLL: if (!info.x_start_time) info.x_start_time = ms_to_monotonic_t(time); break;
199+
}
197200
pointer_handle_axis_common(AXIS_EVENT_CONTINUOUS, axis, value);
198201
}
199202

@@ -230,10 +233,27 @@ pointer_handle_frame(void *data UNUSED, struct wl_pointer *pointer UNUSED) {
230233
}
231234

232235
static void
233-
pointer_handle_axis_source(void* data UNUSED, struct wl_pointer* pointer UNUSED, uint32_t source UNUSED) { }
236+
pointer_handle_axis_source(void* data UNUSED, struct wl_pointer* pointer UNUSED, uint32_t source) {
237+
_GLFWwindow* window = _glfw.wl.pointerFocus;
238+
if (!window) return;
239+
info.source_type = source;
240+
}
234241

235242
static void
236-
pointer_handle_axis_stop(void *data UNUSED, struct wl_pointer *wl_pointer UNUSED, uint32_t time UNUSED, uint32_t axis UNUSED) { }
243+
pointer_handle_axis_stop(void *data UNUSED, struct wl_pointer *wl_pointer UNUSED, uint32_t time UNUSED, uint32_t axis) {
244+
_GLFWwindow* window = _glfw.wl.pointerFocus;
245+
if (!window) return;
246+
switch (axis) {
247+
case WL_POINTER_AXIS_VERTICAL_SCROLL:
248+
info.y_stop_received = true;
249+
info.y_stop_time = ms_to_monotonic_t(time);
250+
break;
251+
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
252+
info.x_stop_received = true;
253+
info.x_stop_time = ms_to_monotonic_t(time);
254+
break;
255+
}
256+
}
237257

238258

239259
static void

glfw/wl_platform.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ typedef struct _GLFWwindowWayland
207207
} discrete, continuous;
208208

209209
/* Event timestamp in nanoseconds */
210-
monotonic_t timestamp_ns;
210+
bool x_stop_received, y_stop_received;
211+
uint32_t source_type;
212+
monotonic_t x_start_time, x_stop_time, y_stop_time, y_start_time;
211213
} pointer_curr_axis_info;
212214

213215
_GLFWcursor* currentCursor;

0 commit comments

Comments
 (0)