From 989dde77cd545ea4cfdf23fbcd445eb121f4ae33 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 15 Jun 2015 18:08:47 +0100 Subject: Added win_resize() function --- src/ui/window.c | 33 +++++++++++++++++++++++++++++++++ src/ui/window.h | 1 + src/ui/windows.c | 30 +----------------------------- 3 files changed, 35 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/ui/window.c b/src/ui/window.c index d6446ff1..b84755b5 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -465,6 +465,39 @@ win_clear(ProfWin *window) win_update_virtual(window); } +void +win_resize(ProfWin *window) +{ + int subwin_cols = 0; + int cols = getmaxx(stdscr); + + if (window->layout->type == LAYOUT_SPLIT) { + ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + if (layout->subwin) { + if (window->type == WIN_CONSOLE) { + subwin_cols = win_roster_cols(); + } else if (window->type == WIN_MUC) { + subwin_cols = win_occpuants_cols(); + } + wresize(layout->base.win, PAD_SIZE, cols - subwin_cols); + wresize(layout->subwin, PAD_SIZE, subwin_cols); + if (window->type == WIN_CONSOLE) { + rosterwin_roster(); + } else if (window->type == WIN_MUC) { + ProfMucWin *mucwin = (ProfMucWin *)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + occupantswin_occupants(mucwin->roomjid); + } + } else { + wresize(layout->base.win, PAD_SIZE, cols); + } + } else { + wresize(window->layout->win, PAD_SIZE, cols); + } + + win_redraw(window); +} + void win_mouse(ProfWin *window, const wint_t ch, const int result) { diff --git a/src/ui/window.h b/src/ui/window.h index 8e5d17e8..f799b1a6 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -193,6 +193,7 @@ int win_unread(ProfWin *window); gboolean win_has_active_subwin(ProfWin *window); void win_clear(ProfWin *window); +void win_resize(ProfWin *window); void win_page_up(ProfWin *window); void win_page_down(ProfWin *window); diff --git a/src/ui/windows.c b/src/ui/windows.c index cb0f00de..54bdb55e 100644 --- a/src/ui/windows.c +++ b/src/ui/windows.c @@ -464,39 +464,11 @@ wins_get_total_unread(void) void wins_resize_all(void) { - int cols = getmaxx(stdscr); - GList *values = g_hash_table_get_values(windows); GList *curr = values; while (curr) { ProfWin *window = curr->data; - int subwin_cols = 0; - - if (window->layout->type == LAYOUT_SPLIT) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; - if (layout->subwin) { - if (window->type == WIN_CONSOLE) { - subwin_cols = win_roster_cols(); - } else if (window->type == WIN_MUC) { - subwin_cols = win_occpuants_cols(); - } - wresize(layout->base.win, PAD_SIZE, cols - subwin_cols); - wresize(layout->subwin, PAD_SIZE, subwin_cols); - if (window->type == WIN_CONSOLE) { - rosterwin_roster(); - } else if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin *)window; - assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - occupantswin_occupants(mucwin->roomjid); - } - } else { - wresize(layout->base.win, PAD_SIZE, cols); - } - } else { - wresize(window->layout->win, PAD_SIZE, cols); - } - - win_redraw(window); + win_resize(window); curr = g_list_next(curr); } g_list_free(values); -- cgit 1.4.1-2-gfad0