about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-02-04 23:35:28 +0000
committerJames Booth <boothj5@gmail.com>2015-02-04 23:35:28 +0000
commit30180ac8bb125e4cae03c415201f796863d4c80b (patch)
treebf9ad3ce7699276918a2fda7436b575a2607b9f6 /src
parentd64c4a69d76aa982f1631449169e35e6eb77bc89 (diff)
downloadprofani-tty-30180ac8bb125e4cae03c415201f796863d4c80b.tar.gz
Move SIGWINCH handling to ui/core.c, ignore signal whilst resizing
Diffstat (limited to 'src')
-rw-r--r--src/profanity.c1
-rw-r--r--src/ui/core.c15
-rw-r--r--src/ui/inputwin.c9
-rw-r--r--src/ui/ui.h1
4 files changed, 17 insertions, 9 deletions
diff --git a/src/profanity.c b/src/profanity.c
index f3c53003..f863a323 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -204,6 +204,7 @@ _init(const int disable_tls, char *log_level)
     signal(SIGPIPE, SIG_IGN);
     signal(SIGINT, SIG_IGN);
     signal(SIGTSTP, SIG_IGN);
+    signal(SIGWINCH, ui_sigwinch_handler);
     _create_directories();
     log_level_t prof_log_level = log_level_from_string(log_level);
     prefs_load();
diff --git a/src/ui/core.c b/src/ui/core.c
index de3bafd2..add80dff 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -79,6 +79,8 @@ static char *win_title;
 
 static int inp_size;
 
+static gboolean perform_resize = FALSE;
+
 #ifdef HAVE_LIBXSS
 static Display *display;
 #endif
@@ -121,6 +123,12 @@ ui_init(void)
 }
 
 void
+ui_sigwinch_handler(int sig)
+{
+    perform_resize = TRUE;
+}
+
+void
 ui_update(void)
 {
     ProfWin *current = wins_get_current();
@@ -137,6 +145,13 @@ ui_update(void)
     status_bar_update_virtual();
     inp_put_back();
     doupdate();
+
+    if (perform_resize) {
+        signal(SIGWINCH, SIG_IGN);
+        ui_resize();
+        perform_resize = FALSE;
+        signal(SIGWINCH, ui_sigwinch_handler);
+    }
 }
 
 void
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index f29b5318..1e78bbcc 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -79,7 +79,6 @@ static gboolean cmd_result = TRUE;
 static void _inp_win_update_virtual(void);
 static int _inp_printable(const wint_t ch);
 static void _inp_win_handle_scroll(void);
-static void _inp_resize_signal_handler(int signal);
 static int _inp_offset_to_col(char *str, int offset);
 static void _inp_write(char *line, int offset);
 
@@ -125,8 +124,6 @@ create_input_window(void)
     rl_startup_hook = _inp_rl_startup_hook;
     rl_callback_handler_install(NULL, _inp_rl_linehandler);
 
-    signal(SIGWINCH, _inp_resize_signal_handler);
-
     inp_win = newpad(1, INP_WIN_MAX);
     wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));;
     keypad(inp_win, TRUE);
@@ -312,12 +309,6 @@ _inp_offset_to_col(char *str, int offset)
 }
 
 static void
-_inp_resize_signal_handler(int signal)
-{
-    ui_resize();
-}
-
-static void
 _inp_win_handle_scroll(void)
 {
     int col = getcurx(inp_win);
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 5008593f..92f570d5 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -62,6 +62,7 @@ GSList* ui_get_chat_recipients(void);
 gboolean ui_switch_win(const int i);
 void ui_next_win(void);
 void ui_previous_win(void);
+void ui_sigwinch_handler(int sig);
 
 void ui_gone_secure(const char * const barejid, gboolean trusted);
 void ui_gone_insecure(const char * const barejid);