From 50f5123190be36051b3378f09f4a6ad689ea6c2b Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Wed, 12 Jun 2019 19:57:30 -0300 Subject: [PATCH] macOS: Fix the coordinate space of SDL_GetDisplayUsableBounds (thanks Tim!) Fixes bug #4518. --- src/video/cocoa/SDL_cocoamodes.m | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index b7c765a7a..95e88da23 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -300,13 +300,9 @@ Cocoa_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) return -1; } - const CGRect cgrect = CGDisplayBounds(cgdisplay); const NSRect frame = [screen visibleFrame]; - - // !!! FIXME: I assume -[NSScreen visibleFrame] is relative to the origin of the screen in question and not the whole desktop. - // !!! FIXME: The math vs CGDisplayBounds might be incorrect if that's not the case, though. Check this. - rect->x = (int)(cgrect.origin.x + frame.origin.x); - rect->y = (int)(cgrect.origin.y + frame.origin.y); + rect->x = (int)frame.origin.x; + rect->y = (int)(CGDisplayPixelsHigh(kCGDirectMainDisplay) - frame.origin.y - frame.size.height); rect->w = (int)frame.size.width; rect->h = (int)frame.size.height;