diff options
-rw-r--r-- | src/gui/curses/gui-curses-bar-window.c | 8 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-main.c | 58 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 58 | ||||
-rw-r--r-- | src/gui/gui-bar-window.c | 91 | ||||
-rw-r--r-- | src/gui/gui-bar-window.h | 4 | ||||
-rw-r--r-- | src/gui/gui-bar.c | 58 |
6 files changed, 120 insertions, 157 deletions
diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c index 072b0c150..a874f0122 100644 --- a/src/gui/curses/gui-curses-bar-window.c +++ b/src/gui/curses/gui-curses-bar-window.c @@ -384,7 +384,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, if (items_count == 0) { if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]) == 0) - gui_bar_window_set_current_size (bar_window->bar, 1); + gui_bar_window_set_current_size (bar_window, window, 1); gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG])); } @@ -426,12 +426,12 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, num_lines = optimal_number_of_lines; else num_lines = items_count; - gui_bar_window_set_current_size (bar_window->bar, + gui_bar_window_set_current_size (bar_window, window, num_lines); break; case GUI_BAR_POSITION_LEFT: case GUI_BAR_POSITION_RIGHT: - gui_bar_window_set_current_size (bar_window->bar, + gui_bar_window_set_current_size (bar_window, window, max_length); break; case GUI_BAR_NUM_POSITIONS: @@ -558,7 +558,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, else { if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]) == 0) - gui_bar_window_set_current_size (bar_window->bar, 1); + gui_bar_window_set_current_size (bar_window, window, 1); gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG])); } diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index 615b45678..843ae66e4 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -256,41 +256,41 @@ gui_main_loop () gui_window_refresh_screen (); gui_window_refresh_needed = 0; } - else + + /* refresh bars if needed */ + for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) { - /* refresh bars if needed */ - for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) - { - if (ptr_bar->bar_refresh_needed) - gui_bar_draw (ptr_bar); - } - - for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) + if (ptr_bar->bar_refresh_needed) + gui_bar_draw (ptr_bar); + } + + for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) + { + if (ptr_win->refresh_needed) { - if (ptr_win->refresh_needed) - { - gui_window_switch_to_buffer (ptr_win, ptr_win->buffer, 0); - gui_window_redraw_buffer (ptr_win->buffer); - ptr_win->refresh_needed = 0; - } + gui_window_switch_to_buffer (ptr_win, ptr_win->buffer, 0); + gui_window_redraw_buffer (ptr_win->buffer); + ptr_win->refresh_needed = 0; } - - for (ptr_buffer = gui_buffers; ptr_buffer; - ptr_buffer = ptr_buffer->next_buffer) + } + + for (ptr_buffer = gui_buffers; ptr_buffer; + ptr_buffer = ptr_buffer->next_buffer) + { + /* refresh chat if needed */ + if (ptr_buffer->chat_refresh_needed) { - /* refresh chat if needed */ - if (ptr_buffer->chat_refresh_needed) - { - gui_chat_draw (ptr_buffer, - (ptr_buffer->chat_refresh_needed) > 1 ? 1 : 0); - } + gui_chat_draw (ptr_buffer, + (ptr_buffer->chat_refresh_needed) > 1 ? 1 : 0); } - - /* refresh bars if needed */ - for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) + } + + /* refresh bars if needed */ + for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) + { + if (ptr_bar->bar_refresh_needed) { - if (ptr_bar->bar_refresh_needed) - gui_bar_draw (ptr_bar); + gui_bar_draw (ptr_bar); } } diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index e125fb121..5daf5b7ff 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -477,24 +477,26 @@ gui_window_switch_to_buffer (struct t_gui_window *window, } window->buffer = buffer; + buffer->num_displayed++; - if (gui_ok && (old_buffer == buffer)) - { - gui_bar_window_remove_unused_bars (window); - gui_bar_window_add_missing_bars (window); - } - - gui_window_calculate_pos_size (window); + gui_hotlist_remove_buffer (buffer); if (gui_ok) { + gui_bar_window_remove_unused_bars (window); + gui_bar_window_add_missing_bars (window); + /* create bar windows */ for (ptr_bar_window = window->bar_windows; ptr_bar_window; ptr_bar_window = ptr_bar_window->next_bar_window) { + gui_bar_window_content_build (ptr_bar_window, window); + gui_bar_window_calculate_pos_size (ptr_bar_window, window); gui_bar_window_create_win (ptr_bar_window); } + gui_window_calculate_pos_size (window); + /* destroy Curses windows */ gui_window_objects_free (window, 0); @@ -505,34 +507,21 @@ gui_window_switch_to_buffer (struct t_gui_window *window, window->win_chat_width, window->win_chat_y, window->win_chat_x); + gui_buffer_ask_chat_refresh (window->buffer, 2); } - buffer->num_displayed++; - - gui_hotlist_remove_buffer (buffer); - - if (gui_ok && (buffer != old_buffer)) + if (window->buffer->type == GUI_BUFFER_TYPE_FREE) { - gui_bar_window_remove_unused_bars (window); - gui_bar_window_add_missing_bars (window); + window->scroll = 0; + window->scroll_lines_after = 0; } - /* redraw bars in window */ for (ptr_bar_window = window->bar_windows; ptr_bar_window; ptr_bar_window = ptr_bar_window->next_bar_window) { - gui_bar_window_content_build (ptr_bar_window, window); ptr_bar_window->bar->bar_refresh_needed = 1; } - if (window->buffer->type == GUI_BUFFER_TYPE_FREE) - { - window->scroll = 0; - window->scroll_lines_after = 0; - } - - window->refresh_needed = 1; - hook_signal_send ("buffer_switch", WEECHAT_HOOK_SIGNAL_POINTER, buffer); } @@ -927,7 +916,7 @@ gui_window_refresh_windows () { gui_bar_window_calculate_pos_size (ptr_bar->bar_window, NULL); gui_bar_window_create_win (ptr_bar->bar_window); - gui_bar_draw (ptr_bar); + gui_bar_ask_refresh (ptr_bar); } } @@ -946,15 +935,7 @@ gui_window_refresh_windows () for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { - gui_window_switch_to_buffer (ptr_win, ptr_win->buffer, 0); - gui_window_draw_separator (ptr_win); - ptr_win->refresh_needed = 0; - } - - for (ptr_buffer = gui_buffers; ptr_buffer; - ptr_buffer = ptr_buffer->next_buffer) - { - gui_window_redraw_buffer (ptr_buffer); + ptr_win->refresh_needed = 1; } gui_current_window = old_current_window; @@ -995,8 +976,9 @@ gui_window_split_horizontal (struct t_gui_window *window, int percentage) /* assign same buffer for new window (top window) */ new_window->buffer->num_displayed++; - gui_window_switch_to_buffer (window, window->buffer, 1); - + window->refresh_needed = 1; + new_window->refresh_needed = 1; + gui_window_switch (new_window); } } @@ -1038,7 +1020,8 @@ gui_window_split_vertical (struct t_gui_window *window, int percentage) /* assign same buffer for new window (right window) */ new_window->buffer->num_displayed++; - gui_window_switch_to_buffer (window, window->buffer, 1); + window->refresh_needed = 1; + new_window->refresh_needed = 1; gui_window_switch (new_window); @@ -1130,7 +1113,6 @@ gui_window_merge (struct t_gui_window *window) gui_window_tree_node_to_leaf (parent, window); gui_window_switch_to_buffer (window, window->buffer, 1); - window->refresh_needed = 1; return 1; } return 0; diff --git a/src/gui/gui-bar-window.c b/src/gui/gui-bar-window.c index ad3e905ae..961e3bf4f 100644 --- a/src/gui/gui-bar-window.c +++ b/src/gui/gui-bar-window.c @@ -224,7 +224,8 @@ gui_bar_window_find_pos (struct t_gui_bar *bar, struct t_gui_window *window) for (ptr_bar_window = window->bar_windows; ptr_bar_window; ptr_bar_window = ptr_bar_window->next_bar_window) { - if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_PRIORITY]) >= CONFIG_INTEGER(ptr_bar_window->bar->options[GUI_BAR_OPTION_PRIORITY])) + if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_PRIORITY]) >= + CONFIG_INTEGER(ptr_bar_window->bar->options[GUI_BAR_OPTION_PRIORITY])) return ptr_bar_window; } @@ -685,8 +686,6 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window) { gui_bar_window_calculate_pos_size (new_bar_window, window); gui_bar_window_create_win (new_bar_window); - if (window) - window->refresh_needed = 1; } return 1; @@ -697,43 +696,6 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window) } /* - * gui_bar_window_recreate_bar_windows: recreate bar windows for all windows - */ - -void -gui_bar_window_recreate_bar_windows (struct t_gui_bar *bar) -{ - struct t_gui_window *ptr_win; - struct t_gui_bar_window *ptr_bar_win; - - if (CONFIG_BOOLEAN(bar->options[GUI_BAR_OPTION_HIDDEN])) - return; - - if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT) - { - gui_bar_window_calculate_pos_size (bar->bar_window, NULL); - gui_bar_window_create_win (bar->bar_window); - gui_window_refresh_needed = 1; - } - else - { - for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) - { - for (ptr_bar_win = ptr_win->bar_windows; ptr_bar_win; - ptr_bar_win = ptr_bar_win->next_bar_window) - { - if (ptr_bar_win->bar == bar) - { - gui_bar_window_calculate_pos_size (ptr_bar_win, ptr_win); - gui_bar_window_create_win (ptr_bar_win); - ptr_win->refresh_needed = 1; - } - } - } - } -} - -/* * gui_bar_window_get_current_size: get current size of bar window * return width or height, depending on bar * position @@ -819,10 +781,9 @@ gui_bar_window_get_max_size (struct t_gui_bar_window *bar_window, */ void -gui_bar_window_set_current_size (struct t_gui_bar *bar, int size) +gui_bar_window_set_current_size (struct t_gui_bar_window *bar_window, + struct t_gui_window *window, int size) { - struct t_gui_window *ptr_window; - struct t_gui_bar_window *ptr_bar_window; int new_size, max_size; if (size == 0) @@ -830,42 +791,30 @@ gui_bar_window_set_current_size (struct t_gui_bar *bar, int size) else { new_size = size; - if ((size != 0) && (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE_MAX]) > 0) - && (size > CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE_MAX]))) + if ((size != 0) && (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE_MAX]) > 0) + && (size > CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE_MAX]))) { - new_size = CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE_MAX]); + new_size = CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE_MAX]); if (new_size < 1) new_size = 1; } } - if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT) + if (bar_window->current_size != new_size) { - if (bar->bar_window->current_size != new_size) + max_size = gui_bar_window_get_max_size (bar_window, window); + new_size = (max_size < new_size) ? max_size : new_size; + if (bar_window->current_size != new_size) { - max_size = gui_bar_window_get_max_size (bar->bar_window, NULL); - bar->bar_window->current_size = (max_size < new_size) ? - max_size : new_size; - gui_bar_window_recreate_bar_windows (bar); - } - } - else - { - for (ptr_window = gui_windows; ptr_window; - ptr_window = ptr_window->next_window) - { - for (ptr_bar_window = ptr_window->bar_windows; ptr_bar_window; - ptr_bar_window = ptr_bar_window->next_bar_window) + bar_window->current_size = new_size; + if (!CONFIG_BOOLEAN(bar_window->bar->options[GUI_BAR_OPTION_HIDDEN])) { - if ((ptr_bar_window->bar == bar) - && (ptr_bar_window->current_size != new_size)) - { - max_size = gui_bar_window_get_max_size (ptr_bar_window, - ptr_window); - ptr_bar_window->current_size = (max_size < new_size) ? - max_size : new_size; - gui_bar_window_recreate_bar_windows (bar); - } + gui_bar_window_calculate_pos_size (bar_window, window); + gui_bar_window_create_win (bar_window); + if (window) + window->refresh_needed = 1; + else + gui_window_refresh_needed = 1; } } } @@ -890,8 +839,6 @@ gui_bar_window_free (struct t_gui_bar_window *bar_window, window->bar_windows = bar_window->next_bar_window; if (window->last_bar_window == bar_window) window->last_bar_window = bar_window->prev_bar_window; - - window->refresh_needed = 1; } /* free data */ diff --git a/src/gui/gui-bar-window.h b/src/gui/gui-bar-window.h index db453ba5f..75dfa15fc 100644 --- a/src/gui/gui-bar-window.h +++ b/src/gui/gui-bar-window.h @@ -55,7 +55,9 @@ extern char *gui_bar_window_content_get_with_filling (struct t_gui_bar_window *b extern struct t_gui_bar_window *gui_bar_window_search_bar (struct t_gui_window *window, struct t_gui_bar *bar); extern int gui_bar_window_get_current_size (struct t_gui_bar_window *bar_window); -extern void gui_bar_window_set_current_size (struct t_gui_bar *bar, int size); +extern void gui_bar_window_set_current_size (struct t_gui_bar_window *bar_window, + struct t_gui_window *window, + int size); extern int gui_bar_window_get_size (struct t_gui_bar *bar, struct t_gui_window *window, enum t_gui_bar_position position); diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index 02ae62970..2246d1df8 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -586,17 +586,51 @@ gui_bar_draw (struct t_gui_bar *bar) struct t_gui_window *ptr_win; struct t_gui_bar_window *ptr_bar_win; - if (CONFIG_BOOLEAN(bar->options[GUI_BAR_OPTION_HIDDEN])) - return; + if (!CONFIG_BOOLEAN(bar->options[GUI_BAR_OPTION_HIDDEN])) + { + if (bar->bar_window) + { + /* root bar */ + gui_bar_window_draw (bar->bar_window, NULL); + } + else + { + /* bar on each window */ + for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) + { + for (ptr_bar_win = ptr_win->bar_windows; ptr_bar_win; + ptr_bar_win = ptr_bar_win->next_bar_window) + { + if (ptr_bar_win->bar == bar) + { + gui_bar_window_draw (ptr_bar_win, ptr_win); + } + } + } + } + } + bar->bar_refresh_needed = 0; +} + +/* + * gui_bar_apply_current_size: apply new size for all bar windows of bar + */ + +void +gui_bar_apply_current_size (struct t_gui_bar *bar) +{ + struct t_gui_window *ptr_win; + struct t_gui_bar_window *ptr_bar_win; - if (bar->bar_window) + if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT) { - /* root bar */ - gui_bar_window_draw (bar->bar_window, NULL); + gui_bar_window_set_current_size (bar->bar_window, + NULL, + CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE])); + gui_window_refresh_needed = 1; } else { - /* bar on each window */ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { for (ptr_bar_win = ptr_win->bar_windows; ptr_bar_win; @@ -604,13 +638,13 @@ gui_bar_draw (struct t_gui_bar *bar) { if (ptr_bar_win->bar == bar) { - gui_bar_window_draw (ptr_bar_win, ptr_win); + gui_bar_window_set_current_size (ptr_bar_win, + ptr_win, + CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SIZE])); } } } } - - bar->bar_refresh_needed = 0; } /* @@ -937,9 +971,7 @@ gui_bar_config_change_size (void *data, struct t_config_option *option) ptr_bar = gui_bar_search_with_option_name (option->name); if (ptr_bar) { - gui_bar_window_set_current_size (ptr_bar, - CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE])); - gui_window_refresh_needed = 1; + } } @@ -1156,7 +1188,7 @@ gui_bar_set_size (struct t_gui_bar *bar, const char *size) snprintf (value, sizeof (value), "%d", new_size); config_file_option_set (bar->options[GUI_BAR_OPTION_SIZE], value, 1); - gui_bar_window_set_current_size (bar, new_size); + gui_bar_apply_current_size (bar); } } |