From 632e2c1eae093dab4a8d801d5568306801e7ee35 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Tue, 1 Jan 2013 13:24:19 +0100 Subject: [PATCH] core: fix scroll in buffer after enabling/disabling some filters (if scroll is on a hidden line) (bug #37885) --- ChangeLog | 2 ++ src/gui/gui-filter.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6dfc65f3d..3fde4906c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ v0.4.0-rc1, 2013-01-01 Version 0.4.0 (under dev!) -------------------------- +* core: fix scroll in buffer after enabling/disabling some filters (if scroll + is on a hidden line) (bug #37885) * core: fix memory leak in case of error when building content of bar item for display * core: fix detection of command in input: a single command char is considered diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c index 616c69047..d2a96efeb 100644 --- a/src/gui/gui-filter.c +++ b/src/gui/gui-filter.c @@ -39,6 +39,7 @@ #include "gui-filter.h" #include "gui-buffer.h" #include "gui-line.h" +#include "gui-window.h" struct t_gui_filter *gui_filters = NULL; /* first filter */ @@ -137,8 +138,10 @@ void gui_filter_buffer (struct t_gui_buffer *buffer) { struct t_gui_line *ptr_line; - int line_displayed, lines_hidden; + struct t_gui_window *ptr_window; + int lines_changed, line_displayed, lines_hidden; + lines_changed = 0; lines_hidden = 0; buffer->lines->prefix_max_length = CONFIG_INTEGER(config_look_prefix_align_min); @@ -156,7 +159,10 @@ gui_filter_buffer (struct t_gui_buffer *buffer) /* force chat refresh if at least one line changed */ if (ptr_line->data->displayed != line_displayed) + { gui_buffer_ask_chat_refresh (buffer, 2); + lines_changed = 1; + } ptr_line->data->displayed = line_displayed; @@ -170,6 +176,27 @@ gui_filter_buffer (struct t_gui_buffer *buffer) hook_signal_send ("buffer_lines_hidden", WEECHAT_HOOK_SIGNAL_POINTER, buffer); } + + /* + * if status of at least one line has changed, check that a scroll in a + * window displaying this buffer is not on a hidden line (if this happens, + * use the previous displayed line as scroll) + */ + if (lines_changed) + { + for (ptr_window = gui_windows; ptr_window; + ptr_window = ptr_window->next_window) + { + if ((ptr_window->buffer == buffer) + && ptr_window->scroll->start_line + && !ptr_window->scroll->start_line->data->displayed) + { + ptr_window->scroll->start_line = + gui_line_get_prev_displayed (ptr_window->scroll->start_line); + ptr_window->scroll->start_line_pos = 0; + } + } + } } /*