summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/ui/x11/ui.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/main/ui/x11/ui.c b/src/main/ui/x11/ui.c
index 369eb7d..49ac978 100644
--- a/src/main/ui/x11/ui.c
+++ b/src/main/ui/x11/ui.c
@@ -22,11 +22,14 @@
#include <GL/gl.h>
#include <GL/glx.h>
#include <X11/Xlib.h>
+#include <unistd.h>
+#include <time.h>
#include "../../util.h"
static Display *display;
static Window window;
static GLXContext gl_context;
+static int close_window = 0;
void cleanup(void);
@@ -117,17 +120,23 @@ ui_on_resize(XEvent event)
glViewport(0, 0, event.xconfigure.width, event.xconfigure.height);
}
+static void
+ui_on_keypress(XEvent event)
+{
+ if (event.type != KeyPress) return;
+ close_window = 1;
+}
+
void
ui_loop(void (*draw_frame)())
{
XEvent event;
- while (1) {
+ while (!close_window) {
XNextEvent(display, &event);
ui_on_expose(event, draw_frame);
ui_on_resize(event);
- if (event.type == KeyPress) {
- break;
- }
+ ui_on_keypress(event);
+
}
cleanup();