commit 821508e
uint
·
2026-06-02 16:06:32 +0000 UTC
parent 0ec0c9a
X11: window creation
2 files changed,
+38,
-0
+32,
-0
1@@ -0,0 +1,32 @@
2+#include <stdio.h>
3+#include <stdlib.h>
4+
5+#include <X11/Xlib.h>
6+
7+#include "mauswin.h"
8+
9+MausWindow* maus_init(const char* title, int x, int y, int width, int height)
10+{
11+ if (MAUS_WARN_BACKEND_AUTO_SEL)
12+ maus_log(stderr, "backend auto-selected: X11");
13+
14+ Display* d = XOpenDisplay(NULL);
15+ if (!d)
16+ maus_die("could not open X11 display");
17+
18+ uint32_t* px = malloc(sizeof(uint32_t)*width*height);
19+
20+ MausWindow* win = malloc(sizeof(MausWindow));
21+ win->display = d;
22+ win->root = DefaultRootWindow(d);
23+ win->win = None;
24+ win->title = title;
25+ win->width = width;
26+ win->height = height;
27+ win->x = x;
28+ win->y = x;
29+ win->pixels = px;
30+
31+ return win;
32+}
33+
+6,
-0
1@@ -1,6 +1,8 @@
2 #ifndef MAUSWIN_X11_H
3 #define MAUSWIN_X11_H
4
5+#include <stdint.h>
6+
7 #include <X11/Xlib.h>
8
9 typedef struct {
10@@ -11,6 +13,10 @@ typedef struct {
11 const char* title;
12 int width;
13 int height;
14+ int x;
15+ int y;
16+
17+ uint32_t* pixels;
18 } MausWindow;
19
20 #endif /* MAUSWIN_X11_H */