From 084547f8a9176f558eb75a956bc248800274d4c4 Mon Sep 17 00:00:00 2001 From: Alessandro Iezzi Date: Fri, 16 May 2025 09:31:05 +0200 Subject: Add event function ui_on_expose --- src/main/ui/x11/ui.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/main/ui/x11/ui.c') diff --git a/src/main/ui/x11/ui.c b/src/main/ui/x11/ui.c index 591c90e..8e5ce45 100644 --- a/src/main/ui/x11/ui.c +++ b/src/main/ui/x11/ui.c @@ -99,16 +99,21 @@ ui_init() glXMakeCurrent(display, window, gl_context); } +static void +ui_on_expose(XEvent event, void (*draw_frame)()) +{ + if (event.type != Expose) return; + draw_frame(); + glXSwapBuffers(display, window); +} + void ui_loop(void (*draw_frame)()) { XEvent event; while (1) { XNextEvent(display, &event); - if (event.type == Expose) { - draw_frame(); - glXSwapBuffers(display, window); - } + ui_on_expose(event, draw_frame); if (event.type == KeyPress) { break; } -- cgit v1.2.3