diff options
author | Anton Kling <anton@kling.gg> | 2023-10-23 20:49:45 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-10-23 20:49:45 +0200 |
commit | d0e898ea995c681c92c2f6ccb7be782e05b17fe7 (patch) | |
tree | ddc07d377b272da9a3e325d36467cb456d2d0f3f /userland | |
parent | 3f44d16f5297a0f7d63f98e48eba46c1e2538a3e (diff) |
ante: Make use of the LibGUI event loop.
Diffstat (limited to 'userland')
-rw-r--r-- | userland/ante/ante.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/userland/ante/ante.c b/userland/ante/ante.c index 760db28..003b03c 100644 --- a/userland/ante/ante.c +++ b/userland/ante/ante.c @@ -260,25 +260,18 @@ int open_file(const char *file) { return 1; } -void run() { - struct pollfd fds[1]; - fds[0].fd = global_w->ws_socket; - fds[0].events = POLLIN; - fds[0].revents = 0; - for (;; fds[0].revents = 0) { - poll(fds, 1, 0); - if (fds[0].revents & POLLIN) { - WS_EVENT e; - int rc; - if (0 >= (rc = read(global_w->ws_socket, &e, sizeof(e)))) - continue; - if (e.ev.release) - continue; - if (0 == e.ev.c) - continue; - key_event(e.ev.c); - } - } +void event_handler(WS_EVENT e) { + if (WINDOWSERVER_EVENT_WINDOW_EXIT == e.type) + exit(0); + + if (WINDOWSERVER_EVENT_KEYPRESS != e.type) + return; + + if (e.ev.release) + return; + if (0 == e.ev.c) + return; + key_event(e.ev.c); } int main(int argc, char **argv) { @@ -293,6 +286,6 @@ int main(int argc, char **argv) { assert(open_file(argv[1])); draw_file(); - run(); + GUI_EventLoop(global_w, event_handler); return 0; } |