# HG changeset patch # User Mikael Berthe # Date 1207250456 -7200 # Node ID 6b98dc22946d6f8f9e357d0e8f7d6a6e3f2e5332 # Parent f560710a6ad16ec20bc1262f1fdcf80b1ae9e0b5 Add optional SIGWINCH handler (Markus Hennecke) This patch from Markus Hennecke adds a configure option to provide a SIGWINCH handler. It is useful on some systems like OpenBSD where there is no default handler for this signal. diff -r f560710a6ad1 -r 6b98dc22946d mcabber/configure.ac --- a/mcabber/configure.ac Wed Apr 02 22:31:23 2008 +0200 +++ b/mcabber/configure.ac Thu Apr 03 21:20:56 2008 +0200 @@ -67,6 +67,16 @@ # Check for tm_gmtoff MC_TM_GMTOFF +# Check if we must provide a SIGWINCH handler +AC_ARG_ENABLE(sigwinch, + [ --enable-sigwinch compile with SIGWINCH handler], + [with_sigwinch=$enableval], + [with_sigwinch=$with_ext_funcs]) +AC_MSG_RESULT($with_sigwinch) +if test "$with_sigwinch" = yes; then + AC_DEFINE(USE_SIGWINCH, [], [Provide own SIGWINCH handler]) +fi + # Checks for libraries. AC_CHECK_LIB(charset, locale_charset) diff -r f560710a6ad1 -r 6b98dc22946d mcabber/src/main.c --- a/mcabber/src/main.c Wed Apr 02 22:31:23 2008 +0200 +++ b/mcabber/src/main.c Thu Apr 03 21:20:56 2008 +0200 @@ -222,6 +222,10 @@ mcabber_terminate("Killed by SIGTERM"); } else if (signum == SIGINT) { mcabber_terminate("Killed by SIGINT"); +#ifdef USE_SIGWINCH + } else if (signum == SIGWINCH) { + ungetch(KEY_RESIZE); +#endif } else { scr_LogPrint(LPRINT_LOGNORM, "Caught signal: %d", signum); } @@ -376,6 +380,9 @@ signal(SIGTERM, sig_handler); signal(SIGINT, sig_handler); signal(SIGCHLD, sig_handler); +#ifdef USE_SIGWINCH + signal(SIGWINCH, sig_handler); +#endif signal(SIGPIPE, SIG_IGN); /* Parse command line options */ diff -r f560710a6ad1 -r 6b98dc22946d mcabber/src/screen.c --- a/mcabber/src/screen.c Wed Apr 02 22:31:23 2008 +0200 +++ b/mcabber/src/screen.c Thu Apr 03 21:20:56 2008 +0200 @@ -29,6 +29,11 @@ #include #include #include +#ifdef USE_SIGWINCH +# include +# include +# include +#endif #ifdef HAVE_LOCALCHARSET_H # include @@ -3771,7 +3776,17 @@ scr_handle_CtrlC(); break; case KEY_RESIZE: +#ifdef USE_SIGWINCH + { + struct winsize size; + if (ioctl(STDIN_FILENO, TIOCGWINSZ, &size) != -1) + resizeterm(size.ws_row, size.ws_col); + } scr_Resize(); + process_command(mkcmdstr("screen_refresh"), TRUE); +#else + scr_Resize(); +#endif break; default: display_char = TRUE;