Wiki Page Content

Differences between revisions 16 and 17
Revision 16 as of 2016-04-15 22:17:05
Size: 2984
Comment: Removed unneccessary \n for SDL_Log() and SDL_LogError() from example.
Revision 17 as of 2016-04-15 22:17:49
Size: 3046
Comment: Added Version section.
Deletions are marked like this. Additions are marked like this.
Line 83: Line 83:
== Version ==
This function is available since SDL 2.0.0.

SDL_GetWindowWMInfo

Use this function to get driver specific information about a window.

Syntax

SDL_bool SDL_GetWindowWMInfo(SDL_Window*    window,
                             SDL_SysWMinfo* info)

Function Parameters

window

the window about which information is being requested

info

an SDL_SysWMinfo structure filled in with window information; see Remarks for details

Return Value

Returns SDL_TRUE if the function is implemented and the version member of the info struct is valid, or SDL_FALSE if the information could not be retrieved; call SDL_GetError() for more information.

Code Examples

#include "SDL.h"
#include "SDL_syswm.h"

int main(int argc, char *argv[]) {
  SDL_Window* window;
  SDL_SysWMinfo info;

  SDL_Init(0);

  window = SDL_CreateWindow("", 0, 0, 0, 0, SDL_WINDOW_HIDDEN);

  SDL_VERSION(&info.version); // initialize info structure with SDL version info

  if(SDL_GetWindowWMInfo(window,&info)) { // the call returns true 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
    }

    SDL_Log("This program is running SDL version %d.%d.%d on %s",
        (int)info.version.major,
        (int)info.version.minor,
        (int)info.version.patch,
        subsystem);
  } else {
    // call failed
    SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Couldn't get window information: %s", SDL_GetError());
  }

  SDL_DestroyWindow(window);
  SDL_Quit();

  return 0;
}

Remarks

You must include SDL_syswm.h for the declaration of SDL_SysWMinfo.

The info structure must be initialized with the SDL version, and is then filled in with information about the given window, as shown in the Code Example.

Version

This function is available since SDL 2.0.0.


CategoryAPI, CategoryVideo, CategorySWM

None: SDL_GetWindowWMInfo (last edited 2016-10-13 20:36:31 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit