summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Iezzi <aiezzi@alessandroiezzi.it>2025-05-16 09:05:42 +0200
committerAlessandro Iezzi <aiezzi@alessandroiezzi.it>2025-05-16 09:05:42 +0200
commit93632dc4258f511137c0b652c462af536056b1ea (patch)
tree51241900deff43a0e06729a7fcdd4fec5588aa54
parentefdb37413e5acf24bf21150479176ad060a8a216 (diff)
downloadtris-93632dc4258f511137c0b652c462af536056b1ea.tar.gz
tris-93632dc4258f511137c0b652c462af536056b1ea.zip
Add a function to get the window attributes
In that function must be defined what events to catch on the UI loop.
-rw-r--r--src/main/ui/x11/ui.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main/ui/x11/ui.c b/src/main/ui/x11/ui.c
index e577bcf..2c605bd 100644
--- a/src/main/ui/x11/ui.c
+++ b/src/main/ui/x11/ui.c
@@ -55,6 +55,17 @@ gl_choose_visual(int screen)
return vi;
}
+static XSetWindowAttributes
+ui_get_attributes(Window root, XVisualInfo *vi)
+{
+ Colormap colormap = XCreateColormap(display, root, vi->visual, AllocNone);
+ XSetWindowAttributes swa;
+ swa.colormap = colormap;
+ swa.event_mask = ExposureMask | KeyPressMask;
+
+ return swa;
+}
+
void
ui_init()
{
@@ -64,11 +75,7 @@ ui_init()
Window root = RootWindow(display, screen);
XVisualInfo *vi = gl_choose_visual(screen);
-
- Colormap colormap = XCreateColormap(display, root, vi->visual, AllocNone);
- XSetWindowAttributes swa;
- swa.colormap = colormap;
- swa.event_mask = ExposureMask | KeyPressMask;
+ XSetWindowAttributes swa = ui_get_attributes(root, vi);
window = XCreateWindow(display, root, 0, 0, 640, 480, 0, vi->depth, InputOutput, vi->visual, CWColormap | CWEventMask, &swa);
XMapWindow(display, window);