From af6440da8fe6683cf0b873e0a98c293bf02c3447 Mon Sep 17 00:00:00 2001 From: sewn Date: Fri, 20 Jun 2025 20:26:33 +0300 Subject: [PATCH] simplify event loop --- mew.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/mew.c b/mew.c index 8813090..44aaf89 100644 --- a/mew.c +++ b/mew.c @@ -938,30 +938,17 @@ run(void) running = 1; while (running) { - if (wl_display_prepare_read(display) < 0) - if (wl_display_dispatch_pending(display) < 0) - die("wl_display_dispatch_pending:"); + wl_display_flush(display); - if (wl_display_flush(display) < 0) - die("wl_display_flush:"); - - if (poll(pfds, LENGTH(pfds), -1) < 0) { - wl_display_cancel_read(display); + if (poll(pfds, LENGTH(pfds), -1) < 0) die("poll:"); - } + + if (pfds[0].revents & POLLIN) + if (wl_display_dispatch(display) < 0) + die("display dispatch failed"); if (pfds[1].revents & POLLIN) keyboard_repeat(); - - if (!(pfds[0].revents & POLLIN)) { - wl_display_cancel_read(display); - continue; - } - - if (wl_display_read_events(display) < 0) - die("wl_display_read_events:"); - if (wl_display_dispatch_pending(display) < 0) - die("wl_display_dispatch_pending:"); } }