Mercurial > pidgin.yaz
diff console/libgnt/gntmain.c @ 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 | e7de1f6d9f35 |
children | 22ad3b783bbe |
line wrap: on
line diff
--- 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(); }