[Scummvm-git-logs] scummvm master -> 172021cccfbc00c4d691a0c1068f12a8442becfe

criezy noreply at scummvm.org
Wed May 13 18:21:35 UTC 2026


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
c0f0fd5198 BACKENDS: SDL: Use wheel event mouse location if available
d703f6fc5c BACKENDS: SDL: Use accumulated wheel scroll amount in SDL3 is available
172021cccf BACKENDS: SDL: Do not ignore wheel scroll amount


Commit: c0f0fd51986d20f05c8a3ae5f1202f3bf148b8c2
    https://github.com/scummvm/scummvm/commit/c0f0fd51986d20f05c8a3ae5f1202f3bf148b8c2
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2026-05-13T19:21:29+01:00

Commit Message:
BACKENDS: SDL: Use wheel event mouse location if available

Changed paths:
    backends/events/sdl/sdl2-events.cpp
    backends/events/sdl/sdl3-events.cpp


diff --git a/backends/events/sdl/sdl2-events.cpp b/backends/events/sdl/sdl2-events.cpp
index af2a0acb60d..d4cfcf3336e 100644
--- a/backends/events/sdl/sdl2-events.cpp
+++ b/backends/events/sdl/sdl2-events.cpp
@@ -717,11 +717,16 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
 	case SDL_MOUSEWHEEL: {
 		Sint32 yDir = ev.wheel.y;
 		// We want the mouse coordinates supplied with a mouse wheel event.
-		// However, SDL2 does not supply these, thus we use whatever we got
-		// last time.
+		// However, SDL2 only supplies these since v2.26.0. For older versions
+		// we use whatever we got last time.
+#if SDL_VERSION_ATLEAST(2, 26, 0)
+		if (!processMouseEvent(event, ev.wheel.mouseX, ev.wheel.mouseY)) {
+#else
 		if (!processMouseEvent(event, _mouseX, _mouseY)) {
+#endif
 			return false;
 		}
+
 		if (yDir < 0) {
 			event.type = Common::EVENT_WHEELDOWN;
 			return true;
diff --git a/backends/events/sdl/sdl3-events.cpp b/backends/events/sdl/sdl3-events.cpp
index 3cf4c346936..2ff280411d6 100644
--- a/backends/events/sdl/sdl3-events.cpp
+++ b/backends/events/sdl/sdl3-events.cpp
@@ -696,10 +696,7 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
 
 	case SDL_EVENT_MOUSE_WHEEL: {
 		Sint32 yDir = ev.wheel.y;
-		// We want the mouse coordinates supplied with a mouse wheel event.
-		// However, SDL2 does not supply these, thus we use whatever we got
-		// last time.
-		if (!processMouseEvent(event, _mouseX, _mouseY)) {
+		if (!processMouseEvent(event, ev.wheel.mouse_x, ev.wheel.mouse_y)) {
 			return false;
 		}
 		if (yDir < 0) {


Commit: d703f6fc5c6638bee14422c393c27bed9610ca3c
    https://github.com/scummvm/scummvm/commit/d703f6fc5c6638bee14422c393c27bed9610ca3c
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2026-05-13T19:21:29+01:00

Commit Message:
BACKENDS: SDL: Use accumulated wheel scroll amount in SDL3 is available

This is what we used with SDL2. In SDL3 it was initially removed,
with the y being now the precise amount instead of the accumulated
amount to whole scroll ticks. It was added back in SDL 3.2.12 as
integer_y.

Changed paths:
    backends/events/sdl/sdl3-events.cpp


diff --git a/backends/events/sdl/sdl3-events.cpp b/backends/events/sdl/sdl3-events.cpp
index 2ff280411d6..663899e27d5 100644
--- a/backends/events/sdl/sdl3-events.cpp
+++ b/backends/events/sdl/sdl3-events.cpp
@@ -695,7 +695,13 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
 		return handleMouseButtonUp(ev, event);
 
 	case SDL_EVENT_MOUSE_WHEEL: {
+#if SDL_VERSION_ATLEAST(3, 2, 12)
+		Sint32 yDir = ev.wheel.integer_y;
+#else
+		// We only have the precise y available. Ir would be better to accumulate it
+		// until we get at least -1 or +1 so that we can handle slow scrolling with abs values < 1.
 		Sint32 yDir = ev.wheel.y;
+#endif
 		if (!processMouseEvent(event, ev.wheel.mouse_x, ev.wheel.mouse_y)) {
 			return false;
 		}


Commit: 172021cccfbc00c4d691a0c1068f12a8442becfe
    https://github.com/scummvm/scummvm/commit/172021cccfbc00c4d691a0c1068f12a8442becfe
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2026-05-13T19:21:29+01:00

Commit Message:
BACKENDS: SDL: Do not ignore wheel scroll amount

This provides a better scroll behaviour when scrolling fast. Before
this change fast scrolling was not faster and ended up scalling less
than if we scrolled more slowly.

Changed paths:
    backends/events/sdl/sdl-events.h
    backends/events/sdl/sdl2-events.cpp
    backends/events/sdl/sdl3-events.cpp


diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h
index 695ec1a909f..d139f6fe1cd 100644
--- a/backends/events/sdl/sdl-events.h
+++ b/backends/events/sdl/sdl-events.h
@@ -227,6 +227,18 @@ protected:
 	 */
 	Common::Event _fakeKeyUp;
 
+	/**
+	 * Whether and how many times _fakeMouseScroll contains an event we need to send .
+	 */
+	int _queuedFakeMouseScroll;
+
+	/**
+	 * A fake mouse scroll event sent when the graphics manager is told to warp
+	 * the mouse but the system mouse is unable to be warped (e.g. because the
+	 * window is not focused).
+	 */
+	Common::Event _fakeMouseScroll;
+
 	enum {
 		MAX_NUM_FINGERS = 3, // number of fingers to track per panel
 		MAX_TAP_TIME = 250, // taps longer than this will not result in mouse click events
diff --git a/backends/events/sdl/sdl2-events.cpp b/backends/events/sdl/sdl2-events.cpp
index d4cfcf3336e..338c1419f77 100644
--- a/backends/events/sdl/sdl2-events.cpp
+++ b/backends/events/sdl/sdl2-events.cpp
@@ -75,7 +75,7 @@ void SdlEventSource::loadGameControllerMappingFile() {
 SdlEventSource::SdlEventSource()
 	: EventSource(), _scrollLock(false), _joystick(nullptr), _lastScreenID(0), _graphicsManager(nullptr), _queuedFakeMouseMove(false),
 	  _lastHatPosition(SDL_HAT_CENTERED), _mouseX(0), _mouseY(0), _engineRunning(false)
-	  , _queuedFakeKeyUp(false), _fakeKeyUp(), _controller(nullptr)
+	  , _queuedFakeKeyUp(false), _fakeKeyUp(), _queuedFakeMouseScroll(0), _fakeMouseScroll(), _controller(nullptr)
 	  {
 	int joystick_num = ConfMan.getInt("joystick_num");
 	if (joystick_num >= 0) {
@@ -640,6 +640,13 @@ bool SdlEventSource::pollEvent(Common::Event &event) {
 		return true;
 	}
 
+	// In we still need to send scroll events for an event with a scroll amount > 1
+	if (_queuedFakeMouseScroll) {
+		event = _fakeMouseScroll;
+		--_queuedFakeMouseScroll;
+		return true;
+	}
+
 	// If the screen changed, send an Common::EVENT_SCREEN_CHANGED
 	int screenID = g_system->getScreenChangeID();
 	if (screenID != _lastScreenID) {
@@ -729,9 +736,13 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
 
 		if (yDir < 0) {
 			event.type = Common::EVENT_WHEELDOWN;
+			_fakeMouseScroll = event;
+			_queuedFakeMouseScroll = -yDir - 1;
 			return true;
 		} else if (yDir > 0) {
 			event.type = Common::EVENT_WHEELUP;
+			_fakeMouseScroll = event;
+			_queuedFakeMouseScroll = yDir - 1;
 			return true;
 		} else {
 			return false;
diff --git a/backends/events/sdl/sdl3-events.cpp b/backends/events/sdl/sdl3-events.cpp
index 663899e27d5..43daa780348 100644
--- a/backends/events/sdl/sdl3-events.cpp
+++ b/backends/events/sdl/sdl3-events.cpp
@@ -75,7 +75,7 @@ void SdlEventSource::loadGameControllerMappingFile() {
 SdlEventSource::SdlEventSource()
 	: EventSource(), _scrollLock(false), _joystick(nullptr), _lastScreenID(0), _graphicsManager(nullptr), _queuedFakeMouseMove(false),
 	  _lastHatPosition(SDL_HAT_CENTERED), _mouseX(0), _mouseY(0), _engineRunning(false)
-	  , _queuedFakeKeyUp(false), _fakeKeyUp(), _controller(nullptr) {
+	  , _queuedFakeKeyUp(false), _fakeKeyUp(), _queuedFakeMouseScroll(0), _fakeMouseScroll(), _controller(nullptr) {
 	int joystick_num = ConfMan.getInt("joystick_num");
 	if (joystick_num >= 0) {
 		// Initialize SDL joystick subsystem
@@ -624,6 +624,13 @@ bool SdlEventSource::pollEvent(Common::Event &event) {
 		return true;
 	}
 
+	// In we still need to send scroll events for an event with a scroll amount > 1
+	if (_queuedFakeMouseScroll) {
+		event = _fakeMouseScroll;
+		--_queuedFakeMouseScroll;
+		return true;
+	}
+
 	// If the screen changed, send an Common::EVENT_SCREEN_CHANGED
 	int screenID = g_system->getScreenChangeID();
 	if (screenID != _lastScreenID) {
@@ -707,9 +714,13 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
 		}
 		if (yDir < 0) {
 			event.type = Common::EVENT_WHEELDOWN;
+			_fakeMouseScroll = event;
+			_queuedFakeMouseScroll = -yDir - 1;
 			return true;
 		} else if (yDir > 0) {
 			event.type = Common::EVENT_WHEELUP;
+			_fakeMouseScroll = event;
+			_queuedFakeMouseScroll = yDir - 1;
 			return true;
 		} else {
 			return false;




More information about the Scummvm-git-logs mailing list