From a969adf804af130b44c0d8d12def5fb915b1c868 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Wed, 31 May 2017 14:44:42 +0200
Subject: [PATCH] suspension: fake a SIGWINCH when coming back out of the
 background

When receiving a SIGCONT, don't call regenerate_screen() directly
but act as if a SIGWINCH occurred.  Also insert a dummy key, and
thus let the relevant input routine redraw the relevant subwindows.

Use KEY_F0 as the dummy key, as both Ncurses and Slang know it, and
it should normally do nothing at all.

This fixes https://savannah.gnu.org/bugs/?51124.
---
 src/nano.c  | 7 ++++---
 src/winio.c | 3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/nano.c b/src/nano.c
index 4fe35081..7398b372 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1267,9 +1267,10 @@ RETSIGTYPE do_continue(int signal)
 #endif
 
 #ifndef NANO_TINY
-    /* Perhaps the user resized the window while we slept.  So act as if,
-     * and restore the terminal to its previous state in the process. */
-    regenerate_screen();
+    /* Perhaps the user resized the window while we slept.  So set that
+     * flag, and tickle the input routine so that it will see the flag. */
+    the_window_resized = TRUE;
+    ungetch(KEY_F0);
 #else
     /* Restore the state of the terminal and redraw the whole screen. */
     terminal_init();
diff --git a/src/winio.c b/src/winio.c
index 63b520fa..b27af3e3 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -701,8 +701,9 @@ int parse_kbinput(WINDOW *win)
 #ifdef KEY_RESIZE
 	/* Slang and SunOS 5.7-5.9 don't support KEY_RESIZE. */
 	case KEY_RESIZE:
-	    return ERR;
 #endif
+	case KEY_F0:
+	    return ERR;
     }
 
     return retval;
-- 
GitLab