summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vui.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/vui.c b/vui.c
index c5b09bf..ae244e0 100644
--- a/vui.c
+++ b/vui.c
@@ -1,3 +1,5 @@
+#define _POSIX_C_SOURCE 20250918
+
#include <sys/ioctl.h>
#include <stdlib.h>
@@ -208,7 +210,8 @@ void vui_curs_pos(int x, int y) {
/* TODO: use something better than signal() */
/* does sigaction allow for a context pointer? */
-static void on_resized(int _) {
+static void on_resized(int signo) {
+ (void)signo;
adjust_win_size();
if (win.redraw_fn) {
win.redraw_fn(win.redraw_ctx);
@@ -243,7 +246,7 @@ void vui_init(void) {
win.redraw_all = 1;
adjust_win_size();
- signal(SIGWINCH, on_resized);
+ sigaction(SIGWINCH, &(struct sigaction) { .sa_handler = on_resized }, NULL);
}
@@ -676,7 +679,13 @@ int vui_printf(int x, int y, const char *fmt, ...) {
}
int vui_wait_for_input(int ms) {
- return poll(&(struct pollfd) { .fd = STDIN_FILENO, .events = POLLIN }, 1, ms);
+ sigset_t set;
+ sigemptyset(&set);
+ sigaddset(&set, SIGWINCH);
+ sigprocmask(SIG_BLOCK, &set, NULL);
+ int r = poll(&(struct pollfd) { .fd = STDIN_FILENO, .events = POLLIN }, 1, ms);
+ sigprocmask(SIG_UNBLOCK, &set, NULL);
+ return r;
}
int vui_has_input(void) {