Get driver-specific information about a window.
int SDL_GetWindowWMInfo(SDL_Window *window, SDL_SysWMinfo *info, Uint32 version);
window | the window about which information is being requested |
info | an SDL_SysWMinfo structure filled in with window information |
version | the version of info being requested, should be SDL_SYSWM_CURRENT_VERSION |
Returns 0 on success or a negative error code on failure; call SDL_GetError() for more information.
You must include SDL_syswm.h for the declaration of SDL_SysWMinfo.
This function is available since SDL 3.0.0.
#include "SDL.h"
#include "SDL_syswm.h"
int main(int argc, char *argv[]) {
SDL_Window* window;
SDL_SysWMinfo info;
0);
SDL_Init(
"", 0, 0, 0, 0, SDL_WINDOW_HIDDEN);
window = SDL_CreateWindow(
/* initialize info structure with SDL version info */
SDL_VERSION(&info.version);
if(SDL_GetWindowWMInfo(window,&info) == 0) { /* the call returns 0 on success */
/* success */
const char *subsystem = "an unknown system!";
switch(info.subsystem) {
case SDL_SYSWM_UNKNOWN: break;
case SDL_SYSWM_WINDOWS: subsystem = "Microsoft Windows(TM)"; break;
case SDL_SYSWM_X11: subsystem = "X Window System"; break;
#if SDL_VERSION_ATLEAST(2, 0, 3)
case SDL_SYSWM_WINRT: subsystem = "WinRT"; break;
#endif
case SDL_SYSWM_DIRECTFB: subsystem = "DirectFB"; break;
case SDL_SYSWM_COCOA: subsystem = "Apple OS X"; break;
case SDL_SYSWM_UIKIT: subsystem = "UIKit"; break;
#if SDL_VERSION_ATLEAST(2, 0, 2)
case SDL_SYSWM_WAYLAND: subsystem = "Wayland"; break;
case SDL_SYSWM_MIR: subsystem = "Mir"; break;
#endif
#if SDL_VERSION_ATLEAST(2, 0, 4)
case SDL_SYSWM_ANDROID: subsystem = "Android"; break;
#endif
#if SDL_VERSION_ATLEAST(2, 0, 5)
case SDL_SYSWM_VIVANTE: subsystem = "Vivante"; break;
#endif
}
"This program is running SDL version %d.%d.%d on %s",
SDL_Log(int)info.version.major,
(int)info.version.minor,
(int)info.version.patch,
(
subsystem);else {
} /* call failed */
"Couldn't get window information: %s", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_ERROR,
}
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
CategoryAPI, CategoryVideo, CategorySWM