mirror of
https://github.com/irssi/irssi.git
synced 2024-10-27 05:20:20 -04:00
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
This commit is contained in:
parent
a5b32b70a7
commit
17f4d6b5de
@ -75,6 +75,12 @@ static void mainwindow_resize_windows(MAIN_WINDOW_REC *window)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
if (window->resize_freeze_counter > 0) {
|
||||
window->resize_needed = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
mainwindow_set_screen_size(window);
|
||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||
WINDOW_REC *rec = tmp->data;
|
||||
|
||||
@ -84,6 +90,8 @@ static void mainwindow_resize_windows(MAIN_WINDOW_REC *window)
|
||||
MAIN_WINDOW_TEXT_HEIGHT(window));
|
||||
}
|
||||
}
|
||||
|
||||
signal_emit("mainwindow resized", 1, window);
|
||||
}
|
||||
|
||||
static void mainwindow_resize(MAIN_WINDOW_REC *window, int xdiff, int ydiff)
|
||||
@ -93,12 +101,7 @@ static void mainwindow_resize(MAIN_WINDOW_REC *window, int xdiff, int ydiff)
|
||||
|
||||
window->width += xdiff;
|
||||
window->height = window->last_line-window->first_line+1;
|
||||
mainwindow_set_screen_size(window);
|
||||
mainwindow_resize_windows(window);
|
||||
|
||||
textbuffer_view_set_window(WINDOW_GUI(window->active)->view,
|
||||
window->screen_win);
|
||||
signal_emit("mainwindow resized", 1, window);
|
||||
}
|
||||
|
||||
static GSList *get_sticky_windows_sorted(MAIN_WINDOW_REC *mainwin)
|
||||
@ -517,14 +520,26 @@ int mainwindow_set_statusbar_lines(MAIN_WINDOW_REC *window,
|
||||
window->statusbar_lines += bottom;
|
||||
}
|
||||
|
||||
if (top+bottom != 0) {
|
||||
mainwindow_set_screen_size(window);
|
||||
if (top+bottom != 0)
|
||||
mainwindow_resize_windows(window);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void mainwindow_resize_freeze(MAIN_WINDOW_REC *window)
|
||||
{
|
||||
window->resize_freeze_counter++;
|
||||
}
|
||||
|
||||
void mainwindow_resize_thaw(MAIN_WINDOW_REC *window)
|
||||
{
|
||||
if (--window->resize_freeze_counter == 0 &&
|
||||
window->resize_needed) {
|
||||
window->resize_needed = FALSE;
|
||||
mainwindow_resize_windows(window);
|
||||
}
|
||||
}
|
||||
|
||||
static void mainwindows_resize_two(MAIN_WINDOW_REC *grow_win,
|
||||
MAIN_WINDOW_REC *shrink_win, int count)
|
||||
{
|
||||
|
@ -21,7 +21,10 @@ typedef struct {
|
||||
GSList *statusbars;
|
||||
int statusbar_lines_top;
|
||||
int statusbar_lines_bottom;
|
||||
int statusbar_lines; /* top+bottom */
|
||||
int statusbar_lines; /* top+bottom */
|
||||
|
||||
int resize_freeze_counter;
|
||||
unsigned int resize_needed:1; /* We'll need to resize the window, but haven't got around doing it just yet. */
|
||||
} MAIN_WINDOW_REC;
|
||||
|
||||
extern GSList *mainwindows;
|
||||
@ -50,6 +53,8 @@ void mainwindow_change_active(MAIN_WINDOW_REC *mainwin,
|
||||
int mainwindows_reserve_lines(int top, int bottom);
|
||||
int mainwindow_set_statusbar_lines(MAIN_WINDOW_REC *window,
|
||||
int top, int bottom);
|
||||
void mainwindow_resize_freeze(MAIN_WINDOW_REC *window);
|
||||
void mainwindow_resize_thaw(MAIN_WINDOW_REC *window);
|
||||
|
||||
GSList *mainwindows_get_sorted(int reverse);
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user