testnativex11.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  3. This software is provided 'as-is', without any express or implied
  4. warranty. In no event will the authors be held liable for any damages
  5. arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it
  8. freely.
  9. */
  10. #include "testnative.h"
  11. #ifdef TEST_NATIVE_X11
  12. static void *CreateWindowX11(int w, int h);
  13. static void DestroyWindowX11(void *window);
  14. NativeWindowFactory X11WindowFactory = {
  15. "x11",
  16. CreateWindowX11,
  17. DestroyWindowX11
  18. };
  19. static Display *dpy;
  20. static void *
  21. CreateWindowX11(int w, int h)
  22. {
  23. Window window = 0;
  24. dpy = XOpenDisplay(NULL);
  25. if (dpy) {
  26. window =
  27. XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, w, h, 0, 0,
  28. 0);
  29. XMapRaised(dpy, window);
  30. XSync(dpy, False);
  31. }
  32. return (void *) window;
  33. }
  34. static void
  35. DestroyWindowX11(void *window)
  36. {
  37. if (dpy) {
  38. XDestroyWindow(dpy, (Window) window);
  39. XCloseDisplay(dpy);
  40. }
  41. }
  42. #endif