From 73262221f54428a29156f52e429237182cac51f0 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 9 Oct 2014 21:27:16 +0100 Subject: [PATCH] Implemented /occupants hide --- src/ui/core.c | 4 ++-- src/ui/window.c | 16 +++++++++++++++- src/ui/window.h | 1 + src/ui/windows.c | 15 ++++++++++++++- src/ui/windows.h | 1 + 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/ui/core.c b/src/ui/core.c index 6ed88e11..b61c4627 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2797,7 +2797,7 @@ _ui_room_hide_occupants(const char * const room) { ProfWin *window = wins_get_by_recipient(room); if (window && window->subwin) { - cons_debug("Hiding occupants"); + wins_hide_subwin(window); } } @@ -3097,7 +3097,7 @@ ui_init_module(void) ui_handle_room_role_list_error = _ui_handle_room_role_list_error; ui_handle_room_role_list = _ui_handle_room_role_list; ui_muc_roster = _ui_muc_roster; - ui_room_show_occupants = _ui_room_show_occupants; + ui_room_show_occupants = _ui_room_show_occupants; ui_room_hide_occupants = _ui_room_hide_occupants; } diff --git a/src/ui/window.c b/src/ui/window.c index d9c2275e..40d40b24 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -88,6 +88,20 @@ win_create(const char * const title, int cols, win_type_t type) return new_win; } +void +win_hide_subwin(ProfWin *window) +{ + if (window->subwin) { + delwin(window->subwin); + } + window->subwin = NULL; + window->sub_y_pos = 0; + + int cols = getmaxx(stdscr); + wresize(window->win, PAD_SIZE, cols); + win_redraw(window); +} + void win_free(ProfWin* window) { @@ -107,7 +121,7 @@ win_update_virtual(ProfWin *window) int rows, cols; getmaxyx(stdscr, rows, cols); - if (window->type == WIN_MUC) { + if ((window->type == WIN_MUC) && (window->subwin)) { pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, ((cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1)) -1); pnoutrefresh(window->subwin, window->sub_y_pos, 0, 1, (cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1), rows-3, cols-1); } else { diff --git a/src/ui/window.h b/src/ui/window.h index 02045305..a12be754 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -102,5 +102,6 @@ void win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp, int void win_save_println(ProfWin *window, const char * const message); void win_save_newline(ProfWin *window); void win_redraw(ProfWin *window); +void win_hide_subwin(ProfWin *window); #endif diff --git a/src/ui/windows.c b/src/ui/windows.c index c3e72899..03e09726 100644 --- a/src/ui/windows.c +++ b/src/ui/windows.c @@ -305,7 +305,7 @@ wins_resize_all(void) g_list_free(values); ProfWin *current_win = wins_get_current(); - if (current_win->type == WIN_MUC) { + if ((current_win->type == WIN_MUC) && (current_win->subwin)) { pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, ((cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1)) -1); pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1), rows-3, cols-1); } else { @@ -313,6 +313,19 @@ wins_resize_all(void) } } +void +wins_hide_subwin(ProfWin *window) +{ + int rows, cols; + getmaxyx(stdscr, rows, cols); + + win_hide_subwin(window); + ProfWin *current_win = wins_get_current(); + if (current_win->type == WIN_MUC) { + pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, cols-1); + } +} + gboolean wins_duck_exists(void) { diff --git a/src/ui/windows.h b/src/ui/windows.h index 55dd5ed7..3f79e808 100644 --- a/src/ui/windows.h +++ b/src/ui/windows.h @@ -63,5 +63,6 @@ GList * wins_get_nums(void); gboolean wins_xmlconsole_exists(void); ProfWin * wins_get_xmlconsole(void); gboolean wins_swap(int source_win, int target_win); +void wins_hide_subwin(ProfWin *window); #endif