From a878f5f1833aaafa12b0abe5e2deeb0871d150fa Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 18 May 2016 11:14:17 +0200 Subject: [PATCH] screen: catch a window resize also when the keyboard is in nodelay mode This fixes https://savannah.gnu.org/bugs/?47954. --- src/winio.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/winio.c b/src/winio.c index 4673d0a0..ba6eb63d 100644 --- a/src/winio.c +++ b/src/winio.c @@ -42,7 +42,18 @@ static bool seen_wide = FALSE; /* Whether we've seen a multicolumn character in the current line. */ #ifndef NANO_TINY -static sig_atomic_t sigwinch_counter_save = 0; +static sig_atomic_t last_sigwinch_counter = 0; + +/* Did we receive a SIGWINCH since we were last called? */ +bool the_window_resized(void) +{ + if (sigwinch_counter == last_sigwinch_counter) + return FALSE; + + last_sigwinch_counter = sigwinch_counter; + regenerate_screen(); + return TRUE; +} #endif /* Control character compatibility: @@ -123,6 +134,11 @@ void get_key_buffer(WINDOW *win) /* Read in the first character using whatever mode we're in. */ input = wgetch(win); +#ifndef NANO_TINY + if (the_window_resized()) + input = KEY_WINCH; +#endif + if (input == ERR && nodelay_mode) return; @@ -135,10 +151,7 @@ void get_key_buffer(WINDOW *win) handle_hupterm(0); #ifndef NANO_TINY - /* Did we get a SIGWINCH since we were last here? */ - if (sigwinch_counter != sigwinch_counter_save) { - sigwinch_counter_save = sigwinch_counter; - regenerate_screen(); + if (the_window_resized()) { input = KEY_WINCH; break; }