summaryrefslogtreecommitdiff
path: root/zig-x11/main.zig
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2024-09-15 07:54:55 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2024-09-15 07:54:55 +0200
commitc81c7b573aa98953ed77fdf8b318e67d3cbe267a (patch)
tree245549840b9412078da32f7e946902dbe9f95c44 /zig-x11/main.zig
parent12d299f552a5aa8b6ea711dbe67805c4a5aab10d (diff)
downloadprobe-c81c7b573aa98953ed77fdf8b318e67d3cbe267a.tar.gz
Added Zig and X11 example for creating simple Window
Diffstat (limited to 'zig-x11/main.zig')
-rw-r--r--zig-x11/main.zig32
1 files changed, 32 insertions, 0 deletions
diff --git a/zig-x11/main.zig b/zig-x11/main.zig
new file mode 100644
index 0000000..daa4cd5
--- /dev/null
+++ b/zig-x11/main.zig
@@ -0,0 +1,32 @@
+const std = @import("std");
+const xlib = @cImport({
+ @cInclude("X11/Xlib.h");
+});
+
+pub fn main() !void {
+ const display = xlib.XOpenDisplay(null);
+ if (display == null) {
+ return error.DisplayOpenFailed;
+ }
+
+ const rootWindow = xlib.XDefaultRootWindow(display);
+
+ const mainWindow = xlib.XCreateSimpleWindow(
+ display,
+ rootWindow,
+ 0,
+ 0,
+ 800,
+ 600,
+ 0,
+ 0,
+ 0xFF0000,
+ );
+
+ _ = xlib.XMapWindow(display, mainWindow);
+ _ = xlib.XFlush(display);
+
+ while (true) {
+ std.time.sleep(1 * std.time.ns_per_s);
+ }
+}