SDL/src/video/cocoa
Sam Lantinga d4c0f498db Fixed bug 4255 - SDL_GetGlobalMouseState() returns incorrect Y on secondary display
Julian Raschke

I use an open Mac laptop with an additional external monitor. The coordinate spaces from SDL_GetGlobalMouseState() and SDL_GetWindowPosition() match on the primary display, but not on the secondary display.

Cocoa window coordinates are vertically flipped in relation to the primary display:

https://github.com/spurious/SDL-mirror/blob/release-2.0.8/src/video/cocoa/SDL_cocoawindow.m#L219-L222

However, Cocoa_GetGlobalMouseState inverts the cursor Y coordinate per-display:

https://github.com/spurious/SDL-mirror/blob/release-2.0.8/src/video/cocoa/SDL_cocoamouse.m#L320-L323

Suggested fix: Replace the for-loop with this simpler calculation:

    *x = (int) cocoaLocation.x;
    *y = (int) (CGDisplayPixelsHigh(kCGDirectMainDisplay) - cocoaLocation.y);
2019-01-04 22:09:38 -08:00
..
SDL_cocoaclipboard.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoaclipboard.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoaevents.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoaevents.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoakeyboard.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoakeyboard.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoamessagebox.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoamessagebox.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoametalview.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoametalview.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoamodes.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoamodes.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoamouse.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoamouse.m Fixed bug 4255 - SDL_GetGlobalMouseState() returns incorrect Y on secondary display 2019-01-04 22:09:38 -08:00
SDL_cocoamousetap.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoamousetap.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoaopengl.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoaopengl.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoaopengles.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoaopengles.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoashape.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoashape.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoavideo.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoavideo.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoavulkan.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoavulkan.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoawindow.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_cocoawindow.m Updated copyright for 2019 2019-01-04 22:01:14 -08:00