This commit is contained in:
ocornut
2025-09-24 15:00:24 +02:00
parent f61a7ef222
commit 719ea9c228
3 changed files with 3 additions and 0 deletions

View File

@@ -676,6 +676,7 @@ static void ImGui_ImplSDL2_UpdateMouseData()
SDL_WarpMouseInWindow(bd->Window, (int)io.MousePos.x, (int)io.MousePos.y); SDL_WarpMouseInWindow(bd->Window, (int)io.MousePos.x, (int)io.MousePos.y);
// (Optional) Fallback to provide unclamped mouse position when focused but not hovered (SDL_MOUSEMOTION already provides this when hovered or captured) // (Optional) Fallback to provide unclamped mouse position when focused but not hovered (SDL_MOUSEMOTION already provides this when hovered or captured)
// Note that SDL_GetGlobalMouseState() is in theory slow on X11, but this only runs on rather specific cases. If a problem we may provide a way to opt-out this feature.
SDL_Window* hovered_window = SDL_GetMouseFocus(); SDL_Window* hovered_window = SDL_GetMouseFocus();
const bool is_relative_mouse_mode = SDL_GetRelativeMouseMode() != 0; const bool is_relative_mouse_mode = SDL_GetRelativeMouseMode() != 0;
if (hovered_window == NULL && bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0 && !is_relative_mouse_mode) if (hovered_window == NULL && bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0 && !is_relative_mouse_mode)

View File

@@ -638,6 +638,7 @@ static void ImGui_ImplSDL3_UpdateMouseData()
SDL_WarpMouseInWindow(bd->Window, io.MousePos.x, io.MousePos.y); SDL_WarpMouseInWindow(bd->Window, io.MousePos.x, io.MousePos.y);
// (Optional) Fallback to provide unclamped mouse position when focused but not hovered (SDL_EVENT_MOUSE_MOTION already provides this when hovered or captured) // (Optional) Fallback to provide unclamped mouse position when focused but not hovered (SDL_EVENT_MOUSE_MOTION already provides this when hovered or captured)
// Note that SDL_GetGlobalMouseState() is in theory slow on X11, but this only runs on rather specific cases. If a problem we may provide a way to opt-out this feature.
SDL_Window* hovered_window = SDL_GetMouseFocus(); SDL_Window* hovered_window = SDL_GetMouseFocus();
const bool is_relative_mouse_mode = SDL_GetWindowRelativeMouseMode(bd->Window); const bool is_relative_mouse_mode = SDL_GetWindowRelativeMouseMode(bd->Window);
if (hovered_window == NULL && bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0 && !is_relative_mouse_mode) if (hovered_window == NULL && bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0 && !is_relative_mouse_mode)

View File

@@ -60,6 +60,7 @@ Other Changes:
- Backends: SDL2,SDL3: avoid using the SDL_GetGlobalMouseState() path when one of our - Backends: SDL2,SDL3: avoid using the SDL_GetGlobalMouseState() path when one of our
window is hovered, as the event data is reliable and enough in this case. window is hovered, as the event data is reliable and enough in this case.
- Fix mouse coordinates issue in fullscreen apps with macOS notch. (#7919, #7786) - Fix mouse coordinates issue in fullscreen apps with macOS notch. (#7919, #7786)
- Essentially a working for SDL3 bug which will be fixed in SDL 3.3.0.
- Better perf on X11 as querying global position requires a round trip to X11 server. - Better perf on X11 as querying global position requires a round trip to X11 server.
- Backends: Win32: minor optimization not submitting gamepad io again if - Backends: Win32: minor optimization not submitting gamepad io again if
XInput's dwPacketNumber has not changed. (#8556) [@MidTerm-CN] XInput's dwPacketNumber has not changed. (#8556) [@MidTerm-CN]