From 327d31a5d9ea4156a5a5b5afc305a180ca30f1a9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 28 Dec 2023 16:09:59 -0800 Subject: [PATCH] Added documentation for getting the NSWindow from an SDL window --- docs/README-migration.md | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/docs/README-migration.md b/docs/README-migration.md index fb30e16c7c..ccf3734b86 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -1210,12 +1210,20 @@ The information previously available in SDL_GetWindowWMInfo() is now available a if (hwnd) { ... } -#elif defined(__LINUX__) - Window xwin = 0; - if (SDL_GetWindowWMInfo(window, &info) && info.subsystem == SDL_SYSWM_X11) { - xwin = info.info.x11.window; +#elif defined(__MACOSX__) + NSWindow *nswindow = NULL; + if (SDL_GetWindowWMInfo(window, &info) && info.subsystem == SDL_SYSWM_COCOA) { + 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 @@ -1227,9 +1235,14 @@ becomes: if (hwnd) { ... } +#elif defined(__MACOS__) + NSWindow *nswindow = (__bridge NSWindow *)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.cocoa.window", NULL); + if (nswindow) { + ... + } #elif defined(__LINUX__) - Window xwin = (Window)SDL_GetNumberProperty(SDL_GetWindowProperties(window), "SDL.window.x11.window", 0); - if (xwin) { + Window xwindow = (Window)SDL_GetNumberProperty(SDL_GetWindowProperties(window), "SDL.window.x11.window", 0); + if (xwindow) { ... } #endif