Wayland: Fix uninitialized variable warning

Related to #1143.
Fixes #1197.
master
Camilla Löwy ago%!(EXTRA string=8 years)
parent e98102162f
commit 53b193a161
  1. 27
      src/wl_init.c

@ -138,8 +138,11 @@ static void pointerHandleAxis(void* data,
wl_fixed_t value) wl_fixed_t value)
{ {
_GLFWwindow* window = _glfw.wl.pointerFocus; _GLFWwindow* window = _glfw.wl.pointerFocus;
double scrollFactor; double x = 0.0, y = 0.0;
double x, y; // Wayland scroll events are in pointer motion coordinate space (think two
// finger scroll). The factor 10 is commonly used to convert to "scroll
// step means 1.0.
const double scrollFactor = 1.0 / 10.0;
if (!window) if (!window)
return; return;
@ -147,22 +150,10 @@ static void pointerHandleAxis(void* data,
assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL || assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ||
axis == WL_POINTER_AXIS_VERTICAL_SCROLL); axis == WL_POINTER_AXIS_VERTICAL_SCROLL);
/* Wayland scroll events are in pointer motion coordinate space (think if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
* two finger scroll). The factor 10 is commonly used to convert to x = wl_fixed_to_double(value) * scrollFactor;
* "scroll step means 1.0. */ else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
scrollFactor = 1.0/10.0; y = wl_fixed_to_double(value) * scrollFactor;
switch (axis)
{
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
x = wl_fixed_to_double(value) * scrollFactor;
y = 0.0;
break;
case WL_POINTER_AXIS_VERTICAL_SCROLL:
x = 0.0;
y = wl_fixed_to_double(value) * scrollFactor;
break;
}
_glfwInputScroll(window, x, y); _glfwInputScroll(window, x, y);
} }

Loading…
Cancel
Save