Move SIGWINCH handler initialization to tty_init()

... and rename tty_low_level_change_screen_size() to
tty_change_screen_size().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2011-09-01 11:21:47 +04:00
parent ad0a5015d3
commit 387bad2c7e
8 changed files with 62 additions and 54 deletions

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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

View File

@ -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 *);

View File

@ -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

View File

@ -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)
{

View File

@ -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);

View File

@ -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;
}