simplify wayland loop
This commit is contained in:
parent
22642b7d74
commit
0a1958dcd9
1 changed files with 9 additions and 22 deletions
31
dam.c
31
dam.c
|
@ -1,4 +1,5 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
|
@ -724,6 +725,7 @@ setup(void)
|
||||||
|
|
||||||
sigemptyset(&mask);
|
sigemptyset(&mask);
|
||||||
sigaddset(&mask, SIGUSR1);
|
sigaddset(&mask, SIGUSR1);
|
||||||
|
sigaddset(&mask, SIGUSR2);
|
||||||
sigaddset(&mask, SIGTERM);
|
sigaddset(&mask, SIGTERM);
|
||||||
sigaddset(&mask, SIGINT);
|
sigaddset(&mask, SIGINT);
|
||||||
|
|
||||||
|
@ -750,21 +752,16 @@ run(void)
|
||||||
};
|
};
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (wl_display_prepare_read(display) < 0)
|
wl_display_flush(display);
|
||||||
if (wl_display_dispatch_pending(display) < 0)
|
|
||||||
die("wl_display_dispatch_pending:");
|
|
||||||
|
|
||||||
if (wl_display_flush(display) < 0)
|
while (poll(pfds, 3, -1) < 0)
|
||||||
die("wl_display_flush:");
|
|
||||||
|
|
||||||
while (poll(pfds, 3, -1) < 0) {
|
|
||||||
if (errno == EAGAIN)
|
|
||||||
continue;
|
|
||||||
wl_display_cancel_read(display);
|
|
||||||
die("poll:");
|
die("poll:");
|
||||||
}
|
|
||||||
|
|
||||||
if (pfds[1].revents & POLLHUP) {
|
if (pfds[0].revents & POLLIN)
|
||||||
|
if (wl_display_dispatch(display) < 0)
|
||||||
|
die("display dispatch failed");
|
||||||
|
|
||||||
|
if (pfds[1].revents & POLLHUP) { /* stdin closed */
|
||||||
pfds[1].fd = -1;
|
pfds[1].fd = -1;
|
||||||
stext[0] = '\0';
|
stext[0] = '\0';
|
||||||
bars_draw();
|
bars_draw();
|
||||||
|
@ -783,16 +780,6 @@ run(void)
|
||||||
si.ssi_signo == SIGINT)
|
si.ssi_signo == SIGINT)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue