cocoa: allow calling CreateWindowFrom on an NSView

This lets applications embed SDL with other widgets surrounding it.
Already possible on Windows and X11.

Fixes Bugzilla #5060.
This commit is contained in:
Michael Maltese 2020-03-25 16:40:43 -07:00
parent 8641f6e99d
commit 361417c0a4
4 changed files with 30 additions and 33 deletions

View file

@ -97,17 +97,6 @@
SDL_WindowData *windowdata = (SDL_WindowData *)newWindow->driverdata;
NSView *contentview = windowdata->sdlContentView;
/* This should never be nil since sdlContentView is only nil if the
window was created via SDL_CreateWindowFrom, and SDL doesn't allow
OpenGL contexts to be created in that case. However, it doesn't hurt
to check. */
if (contentview == nil) {
/* Prefer to access the cached content view above instead of this,
since as of Xcode 11 + SDK 10.15, [window contentView] causes
Apple's Main Thread Checker to output a warning. */
contentview = [windowdata->nswindow contentView];
}
/* Now sign up for scheduled updates for the new window. */
NSMutableArray *contexts = windowdata->nscontexts;
@synchronized (contexts) {
@ -382,7 +371,7 @@ void
Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
{
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
NSView *contentView = [windata->nswindow contentView];
NSView *contentView = windata->sdlContentView;
NSRect viewport = [contentView bounds];
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {