Use counters for discrete flags instead

This commit is contained in:
Rui Ming (Max) Xiong 2022-02-12 17:45:28 -05:00
parent 40bf12af7a
commit 79fa9f1c95

22
glfw/wl_init.c vendored
View File

@ -317,10 +317,10 @@ static void pointerHandleButton(void* data UNUSED,
#undef x #undef x
#undef y #undef y
// flags for ignoring axis events following axis_discrete events in the // counters for ignoring axis events following axis_discrete events in the
// same frame along the same axis // same frame along the same axis
static bool ignoreNextX = false; static unsigned int discreteXCount = 0;
static bool ignoreNextY = false; static unsigned int discreteYCount = 0;
static void pointerHandleAxis(void* data UNUSED, static void pointerHandleAxis(void* data UNUSED,
struct wl_pointer* pointer UNUSED, struct wl_pointer* pointer UNUSED,
@ -337,15 +337,15 @@ static void pointerHandleAxis(void* data UNUSED,
axis == WL_POINTER_AXIS_VERTICAL_SCROLL); axis == WL_POINTER_AXIS_VERTICAL_SCROLL);
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) { if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
if (ignoreNextX) { if (discreteXCount) {
ignoreNextX = false; --discreteXCount;
return; return;
} }
x = -wl_fixed_to_double(value); x = -wl_fixed_to_double(value);
} }
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) { else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) {
if (ignoreNextY) { if (discreteYCount) {
ignoreNextY = false; --discreteYCount;
return; return;
} }
y = -wl_fixed_to_double(value); y = -wl_fixed_to_double(value);
@ -357,8 +357,8 @@ static void pointerHandleAxis(void* data UNUSED,
static void pointerHandleFrame(void* data UNUSED, static void pointerHandleFrame(void* data UNUSED,
struct wl_pointer* pointer UNUSED) struct wl_pointer* pointer UNUSED)
{ {
ignoreNextX = false; discreteXCount = 0;
ignoreNextY = false; discreteYCount = 0;
} }
static void pointerHandleAxisSource(void* data UNUSED, static void pointerHandleAxisSource(void* data UNUSED,
@ -390,11 +390,11 @@ static void pointerHandleAxisDiscrete(void *data UNUSED,
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) { if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
x = -discrete; x = -discrete;
ignoreNextX = true; ++discreteXCount;
} }
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) { else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) {
y = -discrete; y = -discrete;
ignoreNextY = true; ++discreteYCount;
} }
_glfwInputScroll(window, x, y, 0, _glfw.wl.xkb.states.modifiers); _glfwInputScroll(window, x, y, 0, _glfw.wl.xkb.states.modifiers);