Krolyxon
Commit 15603c2

Branches

Refs →

nsxiv15603c2

Added event loop

Author
Bert
Date
2011-01-17 18:32 +0100
Parent
6e0db8c
Commit
15603c25cf00a11dbdf238203858d9eab313120c

+8 −0

2 files changed

  1. M app.c +1 −0
  2. M events.c +7 −0
M app.c View
@@ -37,6 +37,7 @@ void app_init(app_t *app) {
3737 }
3838
3939 void app_run(app_t *app) {
40+ event_loop(app);
4041 }
4142
4243 void app_quit(app_t *app) {
M events.c View
@@ -22,6 +22,7 @@
2222 #include <X11/keysym.h>
2323
2424 #include "events.h"
25+#include "window.h"
2526
2627 extern Display *dpy;
2728
@@ -55,4 +56,10 @@ static void (*handler[LASTEvent])(app_t*, XEvent*) = {
5556 };
5657
5758 void event_loop(app_t *app) {
59+ XEvent ev;
60+
61+ while (!XNextEvent(dpy, &ev)) {
62+ if (handler[ev.type])
63+ handler[ev.type](app, &ev);
64+ }
5865 }