|
diff --git a/README.md b/README.md
|
| ... |
| 40 |
| [zig-struct-bin](./zig-struct-bin) | zig-0.13.0 | Save a struct into binary file and then reading it back. | |
40 |
| [zig-struct-bin](./zig-struct-bin) | zig-0.13.0 | Save a struct into binary file and then reading it back. | |
| 41 |
| [zig-elf](./zig-elf) | zig-0.14.0 | Read execution header of Elf64 format in Zig. | |
41 |
| [zig-elf](./zig-elf) | zig-0.14.0 | Read execution header of Elf64 format in Zig. | |
| 42 |
| [c-bluetooth](./c-bluetooth) | clang-17 | Scans for all Bluetooth devices. | |
42 |
| [c-bluetooth](./c-bluetooth) | clang-17 | Scans for all Bluetooth devices. | |
|
|
43 |
| [d-x11](./d-x11) | dmd-2.110 | Uses X11 to create a basic window without any bindings needed. | |
| 43 |
|
44 |
|
| 44 |
## License |
45 |
## License |
| 45 |
|
46 |
|
| ... |
|
diff --git a/d-x11/main.d b/d-x11/main.d
|
|
|
1 |
import core.sys.posix.unistd; |
|
|
2 |
import core.stdc.stdlib; |
|
|
3 |
|
|
|
4 |
extern(C) { |
|
|
5 |
struct Display; |
|
|
6 |
struct Screen; |
|
|
7 |
alias Window = ulong; |
|
|
8 |
|
|
|
9 |
Display* XOpenDisplay(const char*); |
|
|
10 |
Window XDefaultRootWindow(Display*); |
|
|
11 |
Window XCreateSimpleWindow(Display*, Window, int, int, uint, uint, uint, ulong, ulong); |
|
|
12 |
int XMapWindow(Display*, Window); |
|
|
13 |
int XFlush(Display*); |
|
|
14 |
int XCloseDisplay(Display*); |
|
|
15 |
} |
|
|
16 |
|
|
|
17 |
void main() { |
|
|
18 |
Display* mainDisplay = XOpenDisplay(null); |
|
|
19 |
if (mainDisplay is null) { |
|
|
20 |
exit(1); |
|
|
21 |
} |
|
|
22 |
|
|
|
23 |
Window rootWindow = XDefaultRootWindow(mainDisplay); |
|
|
24 |
|
|
|
25 |
Window mainWindow = XCreateSimpleWindow( |
|
|
26 |
mainDisplay, rootWindow, |
|
|
27 |
0, 0, // x, y position |
|
|
28 |
800, 600, // width, height |
|
|
29 |
0, // border width |
|
|
30 |
0, // border color (ignored) |
|
|
31 |
0xFF0000 // background color (red) |
|
|
32 |
); |
|
|
33 |
|
|
|
34 |
XMapWindow(mainDisplay, mainWindow); |
|
|
35 |
XFlush(mainDisplay); |
|
|
36 |
|
|
|
37 |
while(true) { |
|
|
38 |
sleep(1); |
|
|
39 |
} |
|
|
40 |
} |