From b47f577a9db3d06433a42be0b4e254a833842499 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 11 May 2020 14:36:23 -0700 Subject: [PATCH] Fixed bug 5098 - macOS CreateWindowFrom doesn't work with high-dpi displays michaeljosephmaltese Display ends up taking only 1/4 of the screen area. It needs to call "setWantsBestResolutionOpenGLSurface:highdpi", like when creating a window the normal way. --- src/video/cocoa/SDL_cocoawindow.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 43c6dfadf..2bf1ef547 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -1588,6 +1588,21 @@ Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) window->title = SDL_strdup([title UTF8String]); } + /* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ + #ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #endif + /* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when + * the NSHighResolutionCapable boolean is set in Info.plist. */ + if ([nsview respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) { + BOOL highdpi = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0; + [nsview setWantsBestResolutionOpenGLSurface:highdpi]; + } + #ifdef __clang__ + #pragma clang diagnostic pop + #endif + return SetupWindowData(_this, window, nswindow, nsview, SDL_FALSE); }}