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.
--- 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)
--- 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 */
--- 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 <config.h>
#include <locale.h>
#include <assert.h>
+#ifdef USE_SIGWINCH
+# include <sys/ioctl.h>
+# include <termios.h>
+# include <unistd.h>
+#endif
#ifdef HAVE_LOCALCHARSET_H
# include <localcharset.h>
@@ -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;