diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2009-02-28 13:09:55 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2009-02-28 13:09:55 +0100 |
commit | f4538dee688e5d0f8ea7cf37517f423bade0be40 (patch) | |
tree | 2f84044bd489d25c9cc6fac45c51f39624ecf359 /src/gui | |
parent | d69efe7cda0b72841fc4db96e17ae46b01abdb9c (diff) | |
download | weechat-f4538dee688e5d0f8ea7cf37517f423bade0be40.zip |
Fix freeze/crash when sigwinch signal is received during refresh (for example if repaint is done during terminal resize)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-main.c | 33 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 44 | ||||
-rw-r--r-- | src/gui/curses/gui-curses.h | 1 |
3 files changed, 39 insertions, 39 deletions
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index d31decd8f..f35769b78 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -28,7 +28,6 @@ #include <unistd.h> #include <string.h> #include <signal.h> -#include <sys/ioctl.h> #include "../../core/weechat.h" #include "../../core/wee-command.h" @@ -87,7 +86,6 @@ gui_main_init () struct t_gui_buffer *ptr_buffer; struct t_gui_bar *ptr_bar; struct t_gui_bar_window *ptr_bar_win; - struct winsize size; initscr (); @@ -106,15 +104,7 @@ gui_main_init () gui_term_cols = COLS; gui_term_lines = LINES; - if (ioctl (fileno (stdout), TIOCGWINSZ, &size) == 0) - { - resizeterm(size.ws_row, size.ws_col); - gui_term_cols = size.ws_col; - gui_term_lines = size.ws_row; - } - - gui_ok = ((gui_term_cols >= GUI_WINDOW_MIN_WIDTH) - && (gui_term_lines >= GUI_WINDOW_MIN_HEIGHT)); + gui_window_read_terminal_size (); /* init clipboard buffer */ gui_input_clipboard = NULL; @@ -215,26 +205,7 @@ gui_main_signal_sighup () void gui_main_signal_sigwinch () { - struct winsize size; - int new_width, new_height; - - if (ioctl (fileno (stdout), TIOCGWINSZ, &size) == 0) - { - resizeterm (size.ws_row, size.ws_col); - gui_term_cols = size.ws_col; - gui_term_lines = size.ws_row; - gui_ok = ((gui_term_cols >= GUI_WINDOW_MIN_WIDTH) - && (gui_term_lines >= GUI_WINDOW_MIN_HEIGHT)); - wrefresh (curscr); - } - else - { - getmaxyx (stdscr, new_height, new_width); - gui_term_cols = new_width; - gui_term_lines = new_height; - } - - gui_window_ask_refresh (1); + gui_window_ask_refresh (2); } /* diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index 125e8560f..14d514bcb 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -26,6 +26,7 @@ #include <stdlib.h> #include <string.h> #include <libgen.h> +#include <sys/ioctl.h> #include "../../core/weechat.h" #include "../../core/wee-config.h" @@ -73,6 +74,33 @@ gui_window_get_height () } /* + * gui_window_read_terminal_size: read terminal size + */ + +void +gui_window_read_terminal_size () +{ + struct winsize size; + int new_width, new_height; + + if (ioctl (fileno (stdout), TIOCGWINSZ, &size) == 0) + { + resizeterm (size.ws_row, size.ws_col); + gui_term_cols = size.ws_col; + gui_term_lines = size.ws_row; + } + else + { + getmaxyx (stdscr, new_height, new_width); + gui_term_cols = new_width; + gui_term_lines = new_height; + } + + gui_ok = ((gui_term_cols >= GUI_WINDOW_MIN_WIDTH) + && (gui_term_lines >= GUI_WINDOW_MIN_HEIGHT)); +} + +/* * gui_window_objects_init: init Curses windows */ @@ -1322,21 +1350,21 @@ gui_window_switch_right (struct t_gui_window *window) /* * gui_window_refresh_screen: called when term size is modified - * full_refresh == 1 when Ctrl+L is pressed + * full_refresh == 1 when Ctrl+L is pressed, + * or if terminal is resized */ void gui_window_refresh_screen (int full_refresh) { - if (gui_ok) + if (full_refresh) { - if (full_refresh) - { - endwin (); - refresh (); - } - gui_window_refresh_windows (); + endwin (); + refresh (); + gui_window_read_terminal_size (); } + + gui_window_refresh_windows (); } /* diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index fef46369a..6ec8910c9 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -70,6 +70,7 @@ extern void gui_keyboard_default_bindings (); extern int gui_keyboard_read_cb (void *data, int fd); /* window functions */ +extern void gui_window_read_terminal_size (); extern void gui_window_redraw_buffer (struct t_gui_buffer *buffer); extern int gui_window_utf_char_valid (const char *utf_char); extern void gui_window_clear (WINDOW *window, int bg); |