diff --git a/lib/tty/tty-ncurses.c b/lib/tty/tty-ncurses.c index 5abb14d65..6d1378bfc 100644 --- a/lib/tty/tty-ncurses.c +++ b/lib/tty/tty-ncurses.c @@ -75,6 +75,33 @@ /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ +/* --------------------------------------------------------------------------------------------- */ + +static void +tty_setup_sigwinch (void (*handler) (int)) +{ +#if (NCURSES_VERSION_MAJOR >= 4) && defined (SIGWINCH) + struct sigaction act, oact; + act.sa_handler = handler; + sigemptyset (&act.sa_mask); + act.sa_flags = 0; +#ifdef SA_RESTART + act.sa_flags |= SA_RESTART; +#endif /* SA_RESTART */ + sigaction (SIGWINCH, &act, &oact); +#endif /* SIGWINCH */ +} + +/* --------------------------------------------------------------------------------------------- */ + +void +sigwinch_handler (int dummy) +{ + (void) dummy; + + mc_global.tty.winch_flag = TRUE; +} + /* --------------------------------------------------------------------------------------------- */ /*** public functions ****************************************************************************/ /* --------------------------------------------------------------------------------------------- */ @@ -175,6 +202,8 @@ tty_init (gboolean slow, gboolean ugly_lines, gboolean mouse_enable, gboolean is noecho (); keypad (stdscr, TRUE); nodelay (stdscr, FALSE); + + tty_setup_sigwinch (sigwinch_handler); } /* --------------------------------------------------------------------------------------------- */ @@ -488,23 +517,6 @@ tty_refresh (void) /* --------------------------------------------------------------------------------------------- */ -void -tty_setup_sigwinch (void (*handler) (int)) -{ -#if (NCURSES_VERSION_MAJOR >= 4) && defined (SIGWINCH) - struct sigaction act, oact; - act.sa_handler = handler; - sigemptyset (&act.sa_mask); - act.sa_flags = 0; -#ifdef SA_RESTART - act.sa_flags |= SA_RESTART; -#endif /* SA_RESTART */ - sigaction (SIGWINCH, &act, &oact); -#endif /* SIGWINCH */ -} - -/* --------------------------------------------------------------------------------------------- */ - void tty_beep (void) { diff --git a/lib/tty/tty-slang.c b/lib/tty/tty-slang.c index 1653068c7..f09214144 100644 --- a/lib/tty/tty-slang.c +++ b/lib/tty/tty-slang.c @@ -132,6 +132,34 @@ static const struct /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ +static void +tty_setup_sigwinch (void (*handler) (int)) +{ +#ifdef SIGWINCH + struct sigaction act, oact; + act.sa_handler = handler; + sigemptyset (&act.sa_mask); + act.sa_flags = 0; +#ifdef SA_RESTART + act.sa_flags |= SA_RESTART; +#endif /* SA_RESTART */ + sigaction (SIGWINCH, &act, &oact); +#endif /* SIGWINCH */ +} + +/* --------------------------------------------------------------------------------------------- */ + +static void +sigwinch_handler (int dummy) +{ + (void) dummy; + + tty_change_screen_size (); + mc_global.tty.winch_flag = TRUE; +} + +/* --------------------------------------------------------------------------------------------- */ + /* HP Terminals have capabilities (pfkey, pfloc, pfx) to program function keys. elm 2.4pl15 invoked with the -K option utilizes these softkeys and the consequence is that function keys don't work in MC sometimes... @@ -318,6 +346,8 @@ tty_init (gboolean slow, gboolean ugly_lines, gboolean mouse_enable, gboolean is do_enter_ca_mode (); tty_keypad (TRUE); tty_nodelay (FALSE); + + tty_setup_sigwinch (sigwinch_handler); } /* --------------------------------------------------------------------------------------------- */ @@ -690,23 +720,6 @@ tty_refresh (void) /* --------------------------------------------------------------------------------------------- */ -void -tty_setup_sigwinch (void (*handler) (int)) -{ -#ifdef SIGWINCH - struct sigaction act, oact; - act.sa_handler = handler; - sigemptyset (&act.sa_mask); - act.sa_flags = 0; -#ifdef SA_RESTART - act.sa_flags |= SA_RESTART; -#endif /* SA_RESTART */ - sigaction (SIGWINCH, &act, &oact); -#endif /* SIGWINCH */ -} - -/* --------------------------------------------------------------------------------------------- */ - void tty_beep (void) { diff --git a/lib/tty/tty.c b/lib/tty/tty.c index 51277dfe0..cb482791d 100644 --- a/lib/tty/tty.c +++ b/lib/tty/tty.c @@ -260,7 +260,7 @@ tty_resize (int fd) /* --------------------------------------------------------------------------------------------- */ void -tty_low_level_change_screen_size (void) +tty_change_screen_size (void) { #if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 #if defined TIOCGWINSZ diff --git a/lib/tty/tty.h b/lib/tty/tty.h index 13a839bc0..fed54051c 100644 --- a/lib/tty/tty.h +++ b/lib/tty/tty.h @@ -134,9 +134,7 @@ extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch) extern int tty_resize (int fd); extern void tty_refresh (void); -extern void tty_setup_sigwinch (void (*handler) (int)); -extern void tty_low_level_change_screen_size (void); - +extern void tty_change_screen_size (void); extern int mc_tty_normalize_lines_char (const char *); diff --git a/lib/widget/dialog-switch.c b/lib/widget/dialog-switch.c index f4ae9e86c..5fb5c8387 100644 --- a/lib/widget/dialog-switch.c +++ b/lib/widget/dialog-switch.c @@ -331,7 +331,7 @@ dialog_change_screen_size (void) tty_noraw_mode (); tty_reset_screen (); #endif - tty_low_level_change_screen_size (); + tty_change_screen_size (); #ifdef HAVE_SLANG /* XSI Curses spec states that portable applications shall not invoke * initscr() more than once. This kludge could be done within the scope diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c index ce9b2579d..f2ee0a688 100644 --- a/src/filemanager/layout.c +++ b/src/filemanager/layout.c @@ -722,18 +722,6 @@ setup_panels (void) /* --------------------------------------------------------------------------------------------- */ -void -sigwinch_handler (int dummy) -{ - (void) dummy; -#if !(defined(USE_NCURSES) || defined(USE_NCURSESW)) /* don't do malloc in a signal handler */ - tty_low_level_change_screen_size (); -#endif - mc_global.tty.winch_flag = TRUE; -} - -/* --------------------------------------------------------------------------------------------- */ - void use_dash (gboolean flag) { diff --git a/src/filemanager/layout.h b/src/filemanager/layout.h index 89a1f698e..0e778d7f2 100644 --- a/src/filemanager/layout.h +++ b/src/filemanager/layout.h @@ -36,7 +36,6 @@ void layout_change (void); void layout_box (void); void setup_panels (void); void destroy_panels (void); -void sigwinch_handler (int dummy); void set_display_type (int num, panel_view_mode_t type); void panel_update_cols (Widget * widget, panel_display_t frame_size); void swap_panels (void); diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index 7f92ea0e5..b6347ff53 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -829,8 +829,6 @@ setup_mc (void) add_select_channel (mc_global.tty.subshell_pty, load_prompt, 0); #endif /* !HAVE_SUBSHELL_SUPPORT */ - tty_setup_sigwinch (sigwinch_handler); - if ((tty_baudrate () < 9600) || tty_is_slow ()) verbose = 0; }