changeset 14273:2f82c2494f3f

[gaim-migrate @ 16958] Patch from Mark Schneider (queueRAM): this automatically updates the widgets when the terminal is resized. Pressing alt+l does a better job at refreshing the screen if things get scrambled. But it's not perfect yet. I warmenhoved the patch. I have been waiting to say that =) committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 21 Aug 2006 21:35:38 +0000
parents 7635195195c0
children 43d9afee9c3c
files COPYRIGHT console/libgnt/gntmain.c
diffstat 2 files changed, 41 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Mon Aug 21 20:58:20 2006 +0000
+++ b/COPYRIGHT	Mon Aug 21 21:35:38 2006 +0000
@@ -1,5 +1,5 @@
 Gaim
-Copyright (C) 1998-2005 by the following:
+Copyright (C) 1998-2006 by the following:
 
 If you have contributed to Gaim, you deserve to be on this list.
 Contact us (see: AUTHORS) and we'll add you.
@@ -250,6 +250,7 @@
 Luke Schierer
 Ralph Schmieder
 David Schmitt
+Mark Schneider
 Evan Schoenberg
 Federico Schwindt
 Torrey Searle
--- a/console/libgnt/gntmain.c	Mon Aug 21 20:58:20 2006 +0000
+++ b/console/libgnt/gntmain.c	Mon Aug 21 21:35:38 2006 +0000
@@ -11,6 +11,7 @@
 #include <stdlib.h>
 #include <locale.h>
 #include <unistd.h>
+#include <signal.h>
 #include <string.h>
 #include <ctype.h>
 
@@ -60,6 +61,8 @@
 static void draw_taskbar(gboolean reposition);
 static void bring_on_top(GntWidget *widget);
 
+static gboolean refresh_screen();
+
 static gboolean
 update_screen(gpointer null)
 {
@@ -572,17 +575,7 @@
 				}
 				else if (strcmp(buffer + 1, "l") == 0)
 				{
-					update_screen(NULL);
-					werase(stdscr);
-					wrefresh(stdscr);
-
-					X_MAX = getmaxx(stdscr);
-					Y_MAX = getmaxy(stdscr) - 1;
-
-					g_hash_table_foreach(nodes, (GHFunc)refresh_node, NULL);
-
-					update_screen(NULL);
-					draw_taskbar(TRUE);
+					refresh_screen();
 				}
 				else if (strlen(buffer) == 2 && isdigit(*(buffer + 1)))
 				{
@@ -716,11 +709,41 @@
 		}
 	}
 
+	return TRUE;
+}
+
+static gboolean
+refresh_screen()
+{
+	endwin();
 	refresh();
 
-	return TRUE;
+	X_MAX = getmaxx(stdscr);
+	Y_MAX = getmaxy(stdscr) - 1;
+
+	g_hash_table_foreach(nodes, (GHFunc)refresh_node, NULL);
+	update_screen(NULL);
+	draw_taskbar(TRUE);
+
+	return FALSE;
 }
 
+#ifdef SIGWINCH
+static void
+sighandler(int sig)
+{
+	if (sig == SIGWINCH)
+	{
+		werase(stdscr);
+		wrefresh(stdscr);
+
+		g_idle_add(refresh_screen, NULL);
+	}
+
+	signal(SIGWINCH, sighandler);
+}
+#endif
+
 void gnt_init()
 {
 	static GIOChannel *channel = NULL;
@@ -780,6 +803,10 @@
 	werase(stdscr);
 	wrefresh(stdscr);
 
+#ifdef SIGWINCH
+	signal(SIGWINCH, sighandler);
+#endif
+
 	g_type_init();
 }