SDL-1.2: Fix bug #839 - OpenGL severe display problem on macOS 11 Big Sur

From 89fc1b1c8a65d2f642bb05be9cdac2636c82ff5f Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 11 Mar 2021 23:05:40 +0300
Subject: [PATCH] Fix bug #839 - OpenGL severe display problem on macOS 11 Big
 Sur

Issue, as reported by Dominik Reichardt: "SDL 1.2x apps compiled against
SDK 10.15 or SDK 11.x have severe display problems when started on macOS
11. All is fine on macOS < 11.x, or when compiled against SDK 10.14. The
window is as big as it should be, but the actual video display is in the
lower left corner as if it only renders to the lower left quarter of the
screen. Observed with DOSBox, but reproduced with SDL's testgl program."

Fix extracted from two DOSBox-X commits authored by Jonathan Campbell:
https://github.com/joncampbell123/dosbox-x/commit/c924e716b331c926e86f59c1c3532fb6e95654b2
https://github.com/joncampbell123/dosbox-x/commit/0c87b066011dd88b5d09482a148fbf4fbea1283f

Closes: https://github.com/libsdl-org/SDL-1.2/issues/839
---
 src/video/quartz/SDL_QuartzVideo.m | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/video/quartz/SDL_QuartzVideo.m b/src/video/quartz/SDL_QuartzVideo.m
index 6e71fbeb..1228bfba 100644
--- a/src/video/quartz/SDL_QuartzVideo.m
+++ b/src/video/quartz/SDL_QuartzVideo.m
@@ -1078,6 +1078,18 @@ other blitting while waiting on the VBL (and hence results in higher framerates)
 
         window_view = [ [ NSView alloc ] initWithFrame:contentRect ];
         [ window_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ];
+
+        NSRect contentRectOrig = NSMakeRect (0, 0, width, height);
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101500
+        /* OpenGL in Catalina apparently wants to match pixels on Retina displays. Without this the OpenGL
+           display will only use 1/4th the display in the lower left corner. This seems to be an API issue
+           with XCode as binaries previously compiled on Mojave don't have this issue on Catalina. */
+        contentRectOrig = [ window_view convertRectFromBacking:contentRectOrig ];
+#endif
+
+        [ window_view setBoundsSize: contentRectOrig.size ];
+
         [ [ qz_window contentView ] addSubview:window_view ];
         [ gl_context setView: window_view ];
         [ window_view release ];