Added documentation for getting the NSWindow from an SDL window

This commit is contained in:
Sam Lantinga 2023-12-28 16:09:59 -08:00
parent 3976bbef2a
commit 327d31a5d9
1 changed files with 20 additions and 7 deletions

View File

@ -1210,12 +1210,20 @@ The information previously available in SDL_GetWindowWMInfo() is now available a
if (hwnd) { if (hwnd) {
... ...
} }
#elif defined(__LINUX__) #elif defined(__MACOSX__)
Window xwin = 0; NSWindow *nswindow = NULL;
if (SDL_GetWindowWMInfo(window, &info) && info.subsystem == SDL_SYSWM_X11) { if (SDL_GetWindowWMInfo(window, &info) && info.subsystem == SDL_SYSWM_COCOA) {
xwin = info.info.x11.window; nswindow = (__bridge NSWindow *)info.info.cocoa.window;
} }
if (xwin) { if (nswindow) {
...
}
#elif defined(__LINUX__)
Window xwindow = 0;
if (SDL_GetWindowWMInfo(window, &info) && info.subsystem == SDL_SYSWM_X11) {
xwindow = info.info.x11.window;
}
if (xwindow) {
... ...
} }
#endif #endif
@ -1227,9 +1235,14 @@ becomes:
if (hwnd) { if (hwnd) {
... ...
} }
#elif defined(__MACOS__)
NSWindow *nswindow = (__bridge NSWindow *)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.cocoa.window", NULL);
if (nswindow) {
...
}
#elif defined(__LINUX__) #elif defined(__LINUX__)
Window xwin = (Window)SDL_GetNumberProperty(SDL_GetWindowProperties(window), "SDL.window.x11.window", 0); Window xwindow = (Window)SDL_GetNumberProperty(SDL_GetWindowProperties(window), "SDL.window.x11.window", 0);
if (xwin) { if (xwindow) {
... ...
} }
#endif #endif