🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

  1. /*
  2. Copyright (C) 1997-2023 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