diff options
author | Timo Sirainen <cras@irssi.org> | 2001-10-20 14:30:20 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-10-20 14:30:20 +0000 |
commit | 17f4d6b5de3a2a753091fcea39f63151183b5a30 (patch) | |
tree | f049431a12da77fd32ba7ffdd031e7b68c3f1329 /src/fe-text/statusbar.c | |
parent | a5b32b70a7db8ce41a37d9ee6fdef85300130351 (diff) | |
download | irssi-17f4d6b5de3a2a753091fcea39f63151183b5a30.zip |
added mainwindow_resize_freeze() and .._thaw() functions to temporarily
freeze all window resizes. It's now being used with statusbar code so
changing between split windows don't make the screen jump around.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1860 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-text/statusbar.c')
-rw-r--r-- | src/fe-text/statusbar.c | 86 |
1 files changed, 48 insertions, 38 deletions
diff --git a/src/fe-text/statusbar.c b/src/fe-text/statusbar.c index affbf13e..f8f42b0d 100644 --- a/src/fe-text/statusbar.c +++ b/src/fe-text/statusbar.c @@ -375,6 +375,41 @@ static void statusbars_recalc_ypos(STATUSBAR_REC *bar) } } +static void sig_terminal_resized(void) +{ + GSList *tmp; + + for (tmp = active_statusbar_group->bars; tmp != NULL; tmp = tmp->next) { + STATUSBAR_REC *bar = tmp->data; + + if (bar->config->type == STATUSBAR_TYPE_ROOT && + bar->config->placement == STATUSBAR_BOTTOM) { + statusbars_recalc_ypos(bar); + break; + } + } +} + +static void mainwindow_recalc_ypos(MAIN_WINDOW_REC *window, int placement) +{ + GSList *tmp; + + for (tmp = window->statusbars; tmp != NULL; tmp = tmp->next) { + STATUSBAR_REC *bar = tmp->data; + + if (bar->config->placement == placement) { + statusbars_recalc_ypos(bar); + break; + } + } +} + +static void sig_mainwindow_resized(MAIN_WINDOW_REC *window) +{ + mainwindow_recalc_ypos(window, STATUSBAR_TOP); + mainwindow_recalc_ypos(window, STATUSBAR_BOTTOM); +} + STATUSBAR_REC *statusbar_create(STATUSBAR_GROUP_REC *group, STATUSBAR_CONFIG_REC *config, MAIN_WINDOW_REC *parent_window) @@ -397,6 +432,10 @@ STATUSBAR_REC *statusbar_create(STATUSBAR_GROUP_REC *group, bar->config = config; bar->parent_window = parent_window; + signal_remove("terminal resized", (SIGNAL_FUNC) sig_terminal_resized); + signal_remove("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized); + signal_remove("mainwindow moved", (SIGNAL_FUNC) sig_mainwindow_resized); + if (config->type == STATUSBAR_TYPE_ROOT) { /* top/bottom of the screen */ mainwindows_reserve_lines(config->placement == STATUSBAR_TOP, @@ -414,6 +453,10 @@ STATUSBAR_REC *statusbar_create(STATUSBAR_GROUP_REC *group, parent_window->active->theme : current_theme; } + signal_add("terminal resized", (SIGNAL_FUNC) sig_terminal_resized); + signal_add("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized); + signal_add("mainwindow moved", (SIGNAL_FUNC) sig_mainwindow_resized); + /* get background color from sb_background abstract */ name = g_strdup_printf("{sb_%s_bg}", config->name); value = theme_format_expand(theme, name); @@ -804,41 +847,6 @@ void statusbar_item_destroy(SBAR_ITEM_REC *item) g_free(item); } -static void sig_terminal_resized(void) -{ - GSList *tmp; - - for (tmp = active_statusbar_group->bars; tmp != NULL; tmp = tmp->next) { - STATUSBAR_REC *bar = tmp->data; - - if (bar->config->type == STATUSBAR_TYPE_ROOT && - bar->config->placement == STATUSBAR_BOTTOM) { - statusbars_recalc_ypos(bar); - break; - } - } -} - -static void mainwindow_recalc_ypos(MAIN_WINDOW_REC *window, int placement) -{ - GSList *tmp; - - for (tmp = window->statusbars; tmp != NULL; tmp = tmp->next) { - STATUSBAR_REC *bar = tmp->data; - - if (bar->config->placement == placement) { - statusbars_recalc_ypos(bar); - break; - } - } -} - -static void sig_mainwindow_resized(MAIN_WINDOW_REC *window) -{ - mainwindow_recalc_ypos(window, STATUSBAR_TOP); - mainwindow_recalc_ypos(window, STATUSBAR_BOTTOM); -} - #define STATUSBAR_IS_VISIBLE(bar, window) \ ((bar)->visible == STATUSBAR_VISIBLE_ALWAYS || \ (active_mainwin == (window) && \ @@ -897,8 +905,10 @@ static void sig_window_changed(void) for (tmp = mainwindows; tmp != NULL; tmp = tmp->next) { MAIN_WINDOW_REC *rec = tmp->data; + mainwindow_resize_freeze(rec); statusbars_remove_unvisible(rec); statusbars_add_visible(rec); + mainwindow_resize_thaw(rec); } } @@ -941,15 +951,15 @@ void statusbar_init(void) sbar_item_signals = g_hash_table_new((GHashFunc) g_direct_hash, (GCompareFunc) g_direct_equal); - statusbar_items_init(); - statusbar_config_init(); - signal_add("terminal resized", (SIGNAL_FUNC) sig_terminal_resized); signal_add("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized); signal_add("mainwindow moved", (SIGNAL_FUNC) sig_mainwindow_resized); signal_add("window changed", (SIGNAL_FUNC) sig_window_changed); signal_add("mainwindow destroyed", (SIGNAL_FUNC) sig_mainwindow_destroyed); signal_add_last("setup reread", (SIGNAL_FUNC) sig_setup_reload); + + statusbar_items_init(); + statusbar_config_init(); /* signals need to be before this call */ } void statusbar_deinit(void) |