]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
improve SIGWINCH handling in form
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 20 Mar 2008 18:47:32 +0000 (19:47 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 21 Mar 2008 11:58:40 +0000 (12:58 +0100)
form.c
newt.c

diff --git a/form.c b/form.c
index ae1c6a06aee2a585887a7627bbf3b71264df021a..765e8e35ed832962080fc1cf4b50ddac7d34b20e 100644 (file)
--- a/form.c
+++ b/form.c
@@ -422,6 +422,8 @@ struct componentOps formOps = {
     newtDefaultMappedHandler,
 } ;
 
+int needResize = 0;
+
 static inline int componentFits(newtComponent co, int compNum) {
     struct form * form = co->data;
     struct element * el = form->elements + compNum;
@@ -992,6 +994,11 @@ void newtFormRun(newtComponent co, struct newtExitStruct * es) {
            timeout.tv_sec = timeout.tv_usec = 0;
        }
 
+       if (needResize) {
+               needResize = 0;
+               newtResizeScreen(1);
+       }
+
        i = select(max + 1, &readSet, &writeSet, &exceptSet, 
                        form->timer ? &timeout : NULL);
        if (i < 0) continue;    /* ?? What should we do here? */
@@ -1031,11 +1038,6 @@ void newtFormRun(newtComponent co, struct newtExitStruct * es) {
 
                key = newtGetKey();
 
-               if (key == NEWT_KEY_RESIZE) {
-                   newtResizeScreen(1);
-                   continue;
-               }
-
                for (i = 0; i < form->numHotKeys; i++) {
                    if (form->hotKeys[i] == key) {
                        es->reason = NEWT_EXIT_HOTKEY;
diff --git a/newt.c b/newt.c
index 37050a08b873c1f9952c44af1ce8a746e71ac35a..51b5a2dfe488416fe79c69fee6fe46fbe50f5441 100644 (file)
--- a/newt.c
+++ b/newt.c
@@ -37,9 +37,9 @@ static char * helplineStack[20];
 static char ** currentHelpline = NULL;
 
 static int cursorRow, cursorCol;
-static int needResize = 0;
 static int cursorOn = 1;
 static int trashScreen = 0;
+extern int needResize;
 
 static const char * defaultHelpLine =
 "  <Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen"
@@ -264,8 +264,9 @@ void newtCls(void) {
  * @param redraw - boolean - should we redraw the screen?
  */
 void newtResizeScreen(int redraw) {
+    /* we can't redraw from scratch, just redisplay SLang screen */
     SLtt_get_screen_size();
-    SLsmg_reinit_smg();
+    /* SLsmg_reinit_smg(); */
     if (redraw) {
         SLsmg_touch_lines (0, SLtt_Screen_Rows - 1);
         newtRefresh();
@@ -309,10 +310,6 @@ int newtInit(void) {
     newtCursorOff();
     initKeymap();
 
-    /*memset(&sa, 0, sizeof(sa));
-    sa.sa_handler = handleSigwinch;
-    sigaction(SIGWINCH, &sa, NULL);*/
-
     SLsignal_intr(SIGWINCH, handleSigwinch);
     SLang_getkey_intr_hook = getkeyInterruptHook;