From 639796384a4736e5dd0e433f1c62d0f042d7fd1f Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 7 Oct 2014 17:06:02 +0100 Subject: [PATCH] Handle occupant list resize --- src/ui/ui.h | 1 + src/ui/window.c | 13 ++++++++----- src/ui/windows.c | 20 ++++++++++++++------ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/ui/ui.h b/src/ui/ui.h index f168b8be..f6fad254 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -52,6 +52,7 @@ #include "xmpp/xmpp.h" #define INP_WIN_MAX 1000 +#define OCCUPANT_WIN_SIZE 5 void ui_init_module(void); void console_init_module(void); diff --git a/src/ui/window.c b/src/ui/window.c index da4deb0f..03ed18e1 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -46,6 +46,7 @@ #endif #include "config/theme.h" +#include "ui/ui.h" #include "ui/window.h" #include "xmpp/xmpp.h" @@ -60,10 +61,10 @@ win_create(const char * const title, int cols, win_type_t type) new_win->from = strdup(title); if (type == WIN_MUC) { - new_win->win = newpad(PAD_SIZE, (cols/4) * 3); + new_win->win = newpad(PAD_SIZE, (cols/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1)); wbkgd(new_win->win, COLOUR_TEXT); - new_win->subwin = newpad(PAD_SIZE, cols/4); + new_win->subwin = newpad(PAD_SIZE, cols/OCCUPANT_WIN_SIZE); wvline(new_win->subwin, 0, 0); wbkgd(new_win->subwin, COLOUR_TEXT); } else { @@ -92,6 +93,9 @@ win_free(ProfWin* window) { buffer_free(window->buffer); delwin(window->win); + if (window->subwin) { + delwin(window->subwin); + } free(window->from); form_destroy(window->form); free(window); @@ -104,12 +108,11 @@ win_update_virtual(ProfWin *window) getmaxyx(stdscr, rows, cols); if (window->type == WIN_MUC) { - pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, ((cols/4) * 3) -1); - pnoutrefresh(window->subwin, 0, 0, 1, (cols/4) * 3, rows-3, cols-1); + pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, ((cols/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1)) -1); + pnoutrefresh(window->subwin, 0, 0, 1, (cols/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1), rows-3, cols-1); } else { pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, cols-1); } - } void diff --git a/src/ui/windows.c b/src/ui/windows.c index a2d8276a..3f636fdb 100644 --- a/src/ui/windows.c +++ b/src/ui/windows.c @@ -293,16 +293,24 @@ wins_resize_all(void) GList *values = g_hash_table_get_values(windows); GList *curr = values; while (curr != NULL) { - ProfWin *window = curr->data; - wresize(window->win, PAD_SIZE, cols); - win_redraw(window); - curr = g_list_next(curr); + ProfWin *window = curr->data; + if (window->type == WIN_MUC) { + wresize(window->win, PAD_SIZE, (cols/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1)); + } else { + wresize(window->win, PAD_SIZE, cols); + } + win_redraw(window); + curr = g_list_next(curr); } g_list_free(values); ProfWin *current_win = wins_get_current(); - - pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, cols-1); + if (current_win->type == WIN_MUC) { + pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, ((cols/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1)) -1); + pnoutrefresh(current_win->subwin, 0, 0, 1, (cols/OCCUPANT_WIN_SIZE) * (OCCUPANT_WIN_SIZE-1), rows-3, cols-1); + } else { + pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, cols-1); + } } gboolean