commit 831deb20da5b8f6fe4b34506a3172962b126708a from: Omar Polo date: Wed May 12 11:18:47 2021 UTC debounce resize event commit - 8b6e12673d7d1a4e5951542e0e74a255698f2d86 commit + 831deb20da5b8f6fe4b34506a3172962b126708a blob - e1a20a045d7fad85a9f35f4835ff71ae484779d6 blob + 3e80f5519bc96364bcc6552f5c5560e52fcf2668 --- ui.c +++ ui.c @@ -128,6 +128,7 @@ static int readkey(void); static void dispatch_stdio(int, short, void*); static void handle_clear_minibuf(int, short, void*); static void handle_resize(int, short, void*); +static void handle_resize_timeout(int, short, void*); static int wrap_page(struct window*, int); static void print_vline(WINDOW*, struct vline*); static void redraw_tabline(void); @@ -155,6 +156,9 @@ static void usage(void); static struct { short meta; int key; uint32_t cp; } thiskey; +static struct event resizeev; +static struct timeval resize_timer = { 0, 250000 }; + static WINDOW *tabline, *body, *modeline, *minibuf; static int body_lines, body_cols; @@ -1309,6 +1313,16 @@ handle_clear_minibuf(int fd, short ev, void *d) static void handle_resize(int sig, short ev, void *d) +{ + if (event_pending(&resizeev, EV_TIMEOUT, NULL)) { + event_del(&resizeev); + } + evtimer_set(&resizeev, handle_resize_timeout, NULL); + evtimer_add(&resizeev, &resize_timer); +} + +static void +handle_resize_timeout(int s, short ev, void *d) { struct tab *tab;