From 023a3b90fa03a6afb9f9341c0d84c768c1fedd7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Mon, 10 Jun 2024 14:29:29 +0200 Subject: [PATCH] core: fix refresh of bar item "scroll" in root bar after `/buffer clear` (closes #590) --- CHANGELOG.md | 1 + src/gui/gui-line.c | 19 +++++++++++++++++++ src/gui/gui-window.c | 3 +++ src/gui/gui-window.h | 1 + 4 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9db59847b..18df97579 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - irc: clear /list buffer when disconnecting from server ([#2133](https://github.com/weechat/weechat/issues/2133)) - irc: display an explicit message on /list buffer when the list of channels is empty ([#2133](https://github.com/weechat/weechat/issues/2133)) - xfer: fix send of data on the DCC chat buffer after `/upgrade` if the buffer was opened before the upgrade ([#2092](https://github.com/weechat/weechat/issues/2092)) +- core: fix refresh of bar item "scroll" in root bar after `/buffer clear` ([#590](https://github.com/weechat/weechat/issues/590)) - php: fix return value of function hdata_longlong - tcl: fix return value of function hdata_longlong ([#2119](https://github.com/weechat/weechat/issues/2119)) - relay: fix websocket permessage-deflate extension when the client doesn't send the max window bits parameters ([#1549](https://github.com/weechat/weechat/issues/1549)) diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index 1ade89191..7ea098057 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -1288,6 +1288,7 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer, ptr_scroll->lines_after = 0; gui_window_ask_refresh (1); } + ptr_win->scroll_changed = 1; } if (ptr_scroll->text_search_start_line == line) @@ -1441,10 +1442,28 @@ gui_line_free (struct t_gui_buffer *buffer, struct t_gui_line *line) void gui_line_free_all (struct t_gui_buffer *buffer) { + struct t_gui_window *ptr_win; + + for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) + { + ptr_win->scroll_changed = 0; + } + while (buffer->own_lines->first_line) { gui_line_free (buffer, buffer->own_lines->first_line); } + + for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) + { + if (ptr_win->scroll_changed) + { + ptr_win->scroll_changed = 0; + (void) hook_signal_send ("window_scrolled", + WEECHAT_HOOK_SIGNAL_POINTER, + ptr_win); + } + } } /* diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index e73d216ec..20ea5464b 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -716,6 +716,7 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer, /* scroll */ gui_window_scroll_init (new_window->scroll, buffer); + new_window->scroll_changed = 0; /* coordinates */ new_window->coords_size = 0; @@ -1964,6 +1965,7 @@ gui_window_hdata_window_cb (const void *pointer, void *data, HDATA_VAR(struct t_gui_window, layout_plugin_name, STRING, 0, NULL, NULL); HDATA_VAR(struct t_gui_window, layout_buffer_name, STRING, 0, NULL, NULL); HDATA_VAR(struct t_gui_window, scroll, POINTER, 0, NULL, "window_scroll"); + HDATA_VAR(struct t_gui_window, scroll_changed, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_window, ptr_tree, POINTER, 0, NULL, "window_tree"); HDATA_VAR(struct t_gui_window, prev_window, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_window, next_window, POINTER, 0, NULL, hdata_name); @@ -2134,6 +2136,7 @@ gui_window_print_log () log_printf (" layout_plugin_name. : '%s'", ptr_window->layout_plugin_name); log_printf (" layout_buffer_name. : '%s'", ptr_window->layout_buffer_name); log_printf (" scroll. . . . . . . : %p", ptr_window->scroll); + log_printf (" scroll_changed. . . : %d", ptr_window->scroll_changed); log_printf (" coords_size . . . . : %d", ptr_window->coords_size); log_printf (" coords. . . . . . . : %p", ptr_window->coords); log_printf (" ptr_tree. . . . . . : %p", ptr_window->ptr_tree); diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h index e576753e8..72795e48e 100644 --- a/src/gui/gui-window.h +++ b/src/gui/gui-window.h @@ -72,6 +72,7 @@ struct t_gui_window /* scroll */ struct t_gui_window_scroll *scroll; /* scroll infos for each buffer */ /* scrolled in this window */ + int scroll_changed; /* scrolled changed? */ /* coordinates (for focus) */ int coords_size; /* size of coords (number of lines) */