diff options
Diffstat (limited to 'd-x11/main.d')
| -rw-r--r-- | d-x11/main.d | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/d-x11/main.d b/d-x11/main.d new file mode 100644 index 0000000..5f21f25 --- /dev/null +++ b/d-x11/main.d @@ -0,0 +1,40 @@ +import core.sys.posix.unistd; +import core.stdc.stdlib; + +extern(C) { + struct Display; + struct Screen; + alias Window = ulong; + + Display* XOpenDisplay(const char*); + Window XDefaultRootWindow(Display*); + Window XCreateSimpleWindow(Display*, Window, int, int, uint, uint, uint, ulong, ulong); + int XMapWindow(Display*, Window); + int XFlush(Display*); + int XCloseDisplay(Display*); +} + +void main() { + Display* mainDisplay = XOpenDisplay(null); + if (mainDisplay is null) { + exit(1); + } + + Window rootWindow = XDefaultRootWindow(mainDisplay); + + Window mainWindow = XCreateSimpleWindow( + mainDisplay, rootWindow, + 0, 0, // x, y position + 800, 600, // width, height + 0, // border width + 0, // border color (ignored) + 0xFF0000 // background color (red) + ); + + XMapWindow(mainDisplay, mainWindow); + XFlush(mainDisplay); + + while(true) { + sleep(1); + } +} |
