Fixed bug 5098 - macOS CreateWindowFrom doesn't work with high-dpi displays
authorSam Lantinga <slouken@libsdl.org>
Mon, 11 May 2020 14:36:23 -0700
changeset 13804ccd76043c80e
parent 13803 a73b49512ba2
child 13805 4709c1dfeabb
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
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Mon May 11 14:31:04 2020 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Mon May 11 14:36:23 2020 -0700
     1.3 @@ -1588,6 +1588,21 @@
     1.4          window->title = SDL_strdup([title UTF8String]);
     1.5      }
     1.6  
     1.7 +    /* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */
     1.8 +    #ifdef __clang__
     1.9 +    #pragma clang diagnostic push
    1.10 +    #pragma clang diagnostic ignored "-Wdeprecated-declarations"
    1.11 +    #endif
    1.12 +    /* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when
    1.13 +     * the NSHighResolutionCapable boolean is set in Info.plist. */
    1.14 +    if ([nsview respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
    1.15 +        BOOL highdpi = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
    1.16 +        [nsview setWantsBestResolutionOpenGLSurface:highdpi];
    1.17 +    }
    1.18 +    #ifdef __clang__
    1.19 +    #pragma clang diagnostic pop
    1.20 +    #endif
    1.21 +
    1.22      return SetupWindowData(_this, window, nswindow, nsview, SDL_FALSE);
    1.23  }}
    1.24