summaryrefslogtreecommitdiff
path: root/src/contrib/SDL-3.2.20/test/testnativex11.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/contrib/SDL-3.2.20/test/testnativex11.c')
-rw-r--r--src/contrib/SDL-3.2.20/test/testnativex11.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/test/testnativex11.c b/src/contrib/SDL-3.2.20/test/testnativex11.c
new file mode 100644
index 0000000..5934e4e
--- /dev/null
+++ b/src/contrib/SDL-3.2.20/test/testnativex11.c
@@ -0,0 +1,55 @@
1/*
2 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely.
11*/
12
13#include "testnative.h"
14
15#ifdef TEST_NATIVE_X11
16
17#include <X11/Xlib.h>
18
19static void *CreateWindowX11(int w, int h);
20static void DestroyWindowX11(void *window);
21
22NativeWindowFactory X11WindowFactory = {
23 "x11",
24 CreateWindowX11,
25 DestroyWindowX11
26};
27
28static Display *dpy;
29
30static void *
31CreateWindowX11(int w, int h)
32{
33 Window window = 0;
34
35 dpy = XOpenDisplay(NULL);
36 if (dpy) {
37 window =
38 XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, w, h, 0, 0,
39 0);
40 XMapRaised(dpy, window);
41 XSync(dpy, False);
42 }
43 return (void *)window;
44}
45
46static void
47DestroyWindowX11(void *window)
48{
49 if (dpy) {
50 XDestroyWindow(dpy, (Window)window);
51 XCloseDisplay(dpy);
52 }
53}
54
55#endif