Browse Source

Added event loop

master
Bert 14 years ago
parent
commit
15603c25cf
2 changed files with 8 additions and 0 deletions
  1. +1
    -0
      app.c
  2. +7
    -0
      events.c

+ 1
- 0
app.c View File

@@ -37,6 +37,7 @@ void app_init(app_t *app) {
} }


void app_run(app_t *app) { void app_run(app_t *app) {
event_loop(app);
} }


void app_quit(app_t *app) { void app_quit(app_t *app) {


+ 7
- 0
events.c View File

@@ -22,6 +22,7 @@
#include <X11/keysym.h> #include <X11/keysym.h>


#include "events.h" #include "events.h"
#include "window.h"


extern Display *dpy; extern Display *dpy;


@@ -55,4 +56,10 @@ static void (*handler[LASTEvent])(app_t*, XEvent*) = {
}; };


void event_loop(app_t *app) { void event_loop(app_t *app) {
XEvent ev;

while (!XNextEvent(dpy, &ev)) {
if (handler[ev.type])
handler[ev.type](app, &ev);
}
} }

Loading…
Cancel
Save