From 1d9fed18c2bf021492cb4b9bf8b7bd2d0cd8c8ef Mon Sep 17 00:00:00 2001 From: Ryan Landay Date: Fri, 14 Aug 2026 21:05:05 -0400 Subject: [PATCH] cocoa: Fix macOS 26 popup window regression in 3.4.14 The macOS 26 mouse workaround recomputes motion positions as the global mouse position minus SDL_GetWindowPosition(), but window positions are parent-relative for popup windows, so popups received coordinates offset by their parent's global origin. Unreachable before 3.4.14, when the workaround was widened beyond fullscreen spaces. Convert the position to global first with SDL_RelativeToGlobalForWindow(), a no-op for non-popup windows. Diagnosed by @pipiwoaini in #15967. --- src/video/cocoa/SDL_cocoawindow.m | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index c50f6645b0c91..18d4f40ac51e2 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -1927,11 +1927,18 @@ - (void)mouseMoved:(NSEvent *)theEvent if (@available(macOS 26.0, *)) { // do for all windows for now, not just fullscreen spaces. And hopefully remove this code entirely soon. //if ([_data.listener isInFullscreenSpace]) { - int posx = 0, posy = 0; - SDL_GetWindowPosition(window, &posx, &posy); - SDL_GetGlobalMouseState(&x, &y); - x -= posx; - y -= posy; + int windowRelativePosX = 0, windowRelativePosY = 0; + // If window is a popup, these coordinates are relative to the parent window. + SDL_GetWindowPosition(window, &windowRelativePosX, &windowRelativePosY); + + int windowGlobalPosX = 0, windowGlobalPosY = 0; + // For the popup case + SDL_RelativeToGlobalForWindow(window, windowRelativePosX, windowRelativePosY, &windowGlobalPosX, &windowGlobalPosY); + + float globalMouseX = 0.0f, globalMouseY = 0.0f; + SDL_GetGlobalMouseState(&globalMouseX, &globalMouseY); + x = globalMouseX - windowGlobalPosX; + y = globalMouseY - windowGlobalPosY; //} }