[client] wayland: fix discrete mouse scroll speed

This commit is contained in:
Janrupf
2026-01-16 17:14:17 +01:00
committed by Geoffrey McRae
parent 53bfb6547f
commit b181859c1b
2 changed files with 23 additions and 6 deletions

View File

@@ -32,6 +32,9 @@
#include "app.h"
#include "common/debug.h"
const double WL_SCROLL_STEP = 15.0;
const double WL_HALF_SCROLL_STEP = WL_SCROLL_STEP / 2.0;
// Mouse-handling listeners.
static void pointerMotionHandler(void * data, struct wl_pointer * pointer,
@@ -91,12 +94,25 @@ static void pointerAxisHandler(void * data, struct wl_pointer * pointer,
if (axis != WL_POINTER_AXIS_VERTICAL_SCROLL)
return;
int button = value > 0 ?
5 /* SPICE_MOUSE_BUTTON_DOWN */ :
4 /* SPICE_MOUSE_BUTTON_UP */;
app_handleButtonPress(button);
app_handleButtonRelease(button);
app_handleWheelMotion(wl_fixed_to_double(value) / 15.0);
double delta = wl_fixed_to_double(value);
wlWm.scrollState += delta;
while (wlWm.scrollState > WL_HALF_SCROLL_STEP)
{
app_handleButtonPress(5 /* SPICE_MOUSE_BUTTON_DOWN */);
app_handleButtonRelease(5 /* SPICE_MOUSE_BUTTON_DOWN */);
wlWm.scrollState -= WL_SCROLL_STEP;
}
while (wlWm.scrollState < -WL_HALF_SCROLL_STEP)
{
app_handleButtonPress(4 /* SPICE_MOUSE_BUTTON_UP */);
app_handleButtonRelease(4 /* SPICE_MOUSE_BUTTON_UP */);
wlWm.scrollState += WL_SCROLL_STEP;
}
app_handleWheelMotion(delta / WL_SCROLL_STEP);
}
static int mapWaylandToSpiceButton(uint32_t button)

View File

@@ -114,6 +114,7 @@ struct WaylandDSState
bool configured;
bool warpSupport;
double cursorX, cursorY;
double scrollState;
#if defined(ENABLE_EGL) || defined(ENABLE_OPENGL)
struct wl_egl_window * eglWindow;