Dont use global variables for the axis discrete counts
This commit is contained in:
parent
e06b774174
commit
4b4f904aac
24
glfw/wl_init.c
vendored
24
glfw/wl_init.c
vendored
@ -317,11 +317,6 @@ static void pointerHandleButton(void* data UNUSED,
|
|||||||
#undef x
|
#undef x
|
||||||
#undef y
|
#undef y
|
||||||
|
|
||||||
// counters for ignoring axis events following axis_discrete events in the
|
|
||||||
// same frame along the same axis
|
|
||||||
static unsigned int discreteXCount = 0;
|
|
||||||
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,
|
||||||
uint32_t time UNUSED,
|
uint32_t time UNUSED,
|
||||||
@ -337,15 +332,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 (discreteXCount) {
|
if (window->wl.axis_discrete_count.x) {
|
||||||
--discreteXCount;
|
window->wl.axis_discrete_count.x--;
|
||||||
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 (discreteYCount) {
|
if (window->wl.axis_discrete_count.y) {
|
||||||
--discreteYCount;
|
window->wl.axis_discrete_count.y--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
y = -wl_fixed_to_double(value);
|
y = -wl_fixed_to_double(value);
|
||||||
@ -357,8 +352,11 @@ 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)
|
||||||
{
|
{
|
||||||
discreteXCount = 0;
|
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
||||||
discreteYCount = 0;
|
if (window) {
|
||||||
|
window->wl.axis_discrete_count.x = 0;
|
||||||
|
window->wl.axis_discrete_count.y = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pointerHandleAxisSource(void* data UNUSED,
|
static void pointerHandleAxisSource(void* data UNUSED,
|
||||||
@ -390,11 +388,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;
|
||||||
++discreteXCount;
|
window->wl.axis_discrete_count.x++;
|
||||||
}
|
}
|
||||||
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) {
|
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) {
|
||||||
y = -discrete;
|
y = -discrete;
|
||||||
++discreteYCount;
|
window->wl.axis_discrete_count.y++;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputScroll(window, x, y, 0, _glfw.wl.xkb.states.modifiers);
|
_glfwInputScroll(window, x, y, 0, _glfw.wl.xkb.states.modifiers);
|
||||||
|
|||||||
5
glfw/wl_platform.h
vendored
5
glfw/wl_platform.h
vendored
@ -212,6 +212,11 @@ typedef struct _GLFWwindowWayland
|
|||||||
|
|
||||||
uint32_t toplevel_states;
|
uint32_t toplevel_states;
|
||||||
bool maximize_on_first_show;
|
bool maximize_on_first_show;
|
||||||
|
// counters for ignoring axis events following axis_discrete events in the
|
||||||
|
// same frame along the same axis
|
||||||
|
struct {
|
||||||
|
unsigned int x, y;
|
||||||
|
} axis_discrete_count;
|
||||||
|
|
||||||
} _GLFWwindowWayland;
|
} _GLFWwindowWayland;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user