Skip to content

Commit c39d772

Browse files
committed
Added a workaround for fullscreen mouse position on macOS 26
1 parent 65e462a commit c39d772

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/video/cocoa/SDL_cocoawindow.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,19 @@ - (void)mouseMoved:(NSEvent *)theEvent
18621862
x = point.x;
18631863
y = (window->h - point.y);
18641864

1865+
// On macOS 26 if you move away from a space and then back, mouse motion events will have incorrect
1866+
// values at the top of the screen. The global mouse position query is still correct, so we'll fall
1867+
// back to that until this is fixed by Apple. Mouse button events are interestingly not affected.
1868+
if (@available(macOS 26.0, *)) {
1869+
if ([_data.listener isInFullscreenSpace]) {
1870+
int posx = 0, posy = 0;
1871+
SDL_GetWindowPosition(window, &posx, &posy);
1872+
SDL_GetGlobalMouseState(&x, &y);
1873+
x -= posx;
1874+
y -= posy;
1875+
}
1876+
}
1877+
18651878
if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_13_2) {
18661879
// Mouse grab is taken care of by the confinement rect
18671880
} else {

0 commit comments

Comments
 (0)