mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-03 10:27:40 +00:00
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:
parent
8641f6e99d
commit
361417c0a4
4 changed files with 30 additions and 33 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue