From 024e5da6fb34910f73259c3b23545c8126c560ba Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 23 Dec 2024 17:07:00 -0800
Subject: [PATCH] Mouse events only get a mouse ID in relative mode
---
src/events/SDL_mouse.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index d13e788f803a9..7466fc461d3f8 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -105,7 +105,7 @@ static void SDLCALL SDL_MouseRelativeSpeedScaleChanged(void *userdata, const cha
static void SDLCALL SDL_MouseRelativeModeCenterChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
-
+
mouse->relative_mode_center = SDL_GetStringBoolean(hint, true);
}
@@ -196,7 +196,7 @@ static void SDLCALL SDL_MouseRelativeCursorVisibleChanged(void *userdata, const
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
mouse->relative_mode_cursor_visible = SDL_GetStringBoolean(hint, false);
-
+
SDL_SetCursor(NULL); // Update cursor visibility
}
@@ -436,7 +436,7 @@ void SDL_SetDefaultCursor(SDL_Cursor *cursor)
}
}
-SDL_SystemCursor SDL_GetDefaultSystemCursor(void)
+SDL_SystemCursor SDL_GetDefaultSystemCursor(void)
{
SDL_SystemCursor id = SDL_SYSTEM_CURSOR_DEFAULT;
const char *value = SDL_GetHint(SDL_HINT_MOUSE_DEFAULT_SYSTEM_CURSOR);
@@ -954,6 +954,11 @@ void SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseI
return;
}
+ if (!mouse->relative_mode || mouse->warp_emulation_active) {
+ // We're not in relative mode, so all mouse events are global mouse events
+ mouseID = SDL_GLOBAL_MOUSE_ID;
+ }
+
// Post the event, if desired
if (SDL_EventEnabled(SDL_EVENT_MOUSE_WHEEL)) {
SDL_Event event;
@@ -1022,7 +1027,7 @@ void SDL_QuitMouse(void)
SDL_RemoveHintCallback(SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE,
SDL_MouseRelativeSystemScaleChanged, mouse);
- SDL_RemoveHintCallback(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER,
+ SDL_RemoveHintCallback(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER,
SDL_MouseRelativeModeCenterChanged, mouse);
SDL_RemoveHintCallback(SDL_HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE,