Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backends: SDL3: Fix macOS mouse position incorrect for fullscreen apps #7919

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions backends/imgui_impl_sdl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,21 @@ static void ImGui_ImplSDL3_UpdateMouseData()
float mouse_x_global, mouse_y_global;
int window_x, window_y;
SDL_GetGlobalMouseState(&mouse_x_global, &mouse_y_global);
#if defined(SDL_PLATFORM_MACOS)
// On macOS SDL3 no longer renders fullscreen windows into the notch area
// on devices with such hardware, but will still report the global mouse state relative
// to the entire display.
// This results in incorrect mouse location data, as the mouse should be reported
// relative to the drawable client area.
// To resolve this issue, SDL_GetMouseState() can be used.
uint32_t window_flags = SDL_GetWindowFlags(bd->Window);
if (window_flags & SDL_WINDOW_FULLSCREEN)
{
SDL_GetMouseState(&mouse_x_global, &mouse_y_global);
}
#endif


SDL_GetWindowPosition(focused_window, &window_x, &window_y);
io.AddMousePosEvent(mouse_x_global - window_x, mouse_y_global - window_y);
}
Expand Down