Skip to content
Browse files

core: add non-active merged buffers with activity in hotlist (if anot…

…her merged buffer is zoomed) (task #12845)

There was a bug with "num_displayed" in buffers when they are merged and
that one buffer is zoomed: now the num_displayed is > 0 for the active buffer,
and it is set to 0 for all merged non-active buffers (only in case of zoom).

A variable "zoomed" has been added in buffers to know if a buffer with this
number is zoomed or not (possibly another buffer).
  • Loading branch information...
1 parent 1fedd44 commit 0e561104fa18ee0ba5b38b0679279202ab2f04ae @flashcode flashcode committed Mar 31, 2014
View
2 ChangeLog.asciidoc
@@ -15,6 +15,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
== Version 0.4.4 (under dev)
+* core: add non-active merged buffers with activity in hotlist (if another
+ merged buffer is zoomed) (task #12845)
* core: fix refresh of bar item "buffer_zoom" on buffer switch
* core: fix reset of attributes in bars when "resetcolor" is used (closes #41)
* core: fix alignment of lines in merged buffers when options
View
1 doc/de/autogen/plugin_api/hdata.txt
@@ -490,6 +490,7 @@
*** 'notify' (integer)
*** 'num_displayed' (integer)
*** 'active' (integer)
+*** 'zoomed' (integer)
*** 'print_hooks_enabled' (integer)
*** 'day_change' (integer)
*** 'clear' (integer)
View
1 doc/en/autogen/plugin_api/hdata.txt
@@ -490,6 +490,7 @@
*** 'notify' (integer)
*** 'num_displayed' (integer)
*** 'active' (integer)
+*** 'zoomed' (integer)
*** 'print_hooks_enabled' (integer)
*** 'day_change' (integer)
*** 'clear' (integer)
View
1 doc/fr/autogen/plugin_api/hdata.txt
@@ -490,6 +490,7 @@
*** 'notify' (integer)
*** 'num_displayed' (integer)
*** 'active' (integer)
+*** 'zoomed' (integer)
*** 'print_hooks_enabled' (integer)
*** 'day_change' (integer)
*** 'clear' (integer)
View
1 doc/it/autogen/plugin_api/hdata.txt
@@ -490,6 +490,7 @@
*** 'notify' (integer)
*** 'num_displayed' (integer)
*** 'active' (integer)
+*** 'zoomed' (integer)
*** 'print_hooks_enabled' (integer)
*** 'day_change' (integer)
*** 'clear' (integer)
View
1 doc/ja/autogen/plugin_api/hdata.txt
@@ -490,6 +490,7 @@
*** 'notify' (integer)
*** 'num_displayed' (integer)
*** 'active' (integer)
+*** 'zoomed' (integer)
*** 'print_hooks_enabled' (integer)
*** 'day_change' (integer)
*** 'clear' (integer)
View
1 doc/pl/autogen/plugin_api/hdata.txt
@@ -490,6 +490,7 @@
*** 'notify' (integer)
*** 'num_displayed' (integer)
*** 'active' (integer)
+*** 'zoomed' (integer)
*** 'print_hooks_enabled' (integer)
*** 'day_change' (integer)
*** 'clear' (integer)
View
6 src/gui/curses/gui-curses-window.c
@@ -1219,7 +1219,9 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
}
window->buffer = buffer;
- gui_buffer_add_value_num_displayed (buffer, 1);
+
+ gui_buffer_set_active_buffer (buffer);
+ gui_buffer_compute_num_displayed ();
if (!weechat_upgrading && (old_buffer != buffer))
gui_hotlist_remove_buffer (buffer);
@@ -1263,8 +1265,6 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
window->scroll->lines_after = 0;
}
- gui_buffer_set_active_buffer (buffer);
-
for (ptr_bar_window = window->bar_windows; ptr_bar_window;
ptr_bar_window = ptr_bar_window->next_bar_window)
{
View
28 src/gui/gui-buffer.c
@@ -76,14 +76,14 @@ char *gui_buffer_notify_string[GUI_BUFFER_NUM_NOTIFY] =
char *gui_buffer_properties_get_integer[] =
{ "number", "layout_number", "layout_number_merge_order", "type", "notify",
- "num_displayed", "active", "print_hooks_enabled", "day_change", "clear",
- "lines_hidden", "prefix_max_length", "time_for_each_line", "nicklist",
- "nicklist_case_sensitive", "nicklist_max_length", "nicklist_display_groups",
- "nicklist_count", "nicklist_groups_count", "nicklist_nicks_count",
- "nicklist_visible_count", "input", "input_get_unknown_commands",
- "input_size", "input_length", "input_pos", "input_1st_display",
- "num_history", "text_search", "text_search_exact", "text_search_regex",
- "text_search_where", "text_search_found",
+ "num_displayed", "active", "zoomed", "print_hooks_enabled", "day_change",
+ "clear", "lines_hidden", "prefix_max_length", "time_for_each_line",
+ "nicklist", "nicklist_case_sensitive", "nicklist_max_length",
+ "nicklist_display_groups", "nicklist_count", "nicklist_groups_count",
+ "nicklist_nicks_count", "nicklist_visible_count", "input",
+ "input_get_unknown_commands", "input_size", "input_length", "input_pos",
+ "input_1st_display", "num_history", "text_search", "text_search_exact",
+ "text_search_regex", "text_search_where", "text_search_found",
NULL
};
char *gui_buffer_properties_get_string[] =
@@ -591,6 +591,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
new_buffer->notify = CONFIG_INTEGER(config_look_buffer_notify_default);
new_buffer->num_displayed = 0;
new_buffer->active = 1;
+ new_buffer->zoomed = 0;
new_buffer->print_hooks_enabled = 1;
new_buffer->day_change = 1;
new_buffer->clear = 1;
@@ -978,6 +979,8 @@ gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property)
return buffer->num_displayed;
else if (string_strcasecmp (property, "active") == 0)
return buffer->active;
+ else if (string_strcasecmp (property, "zoomed") == 0)
+ return buffer->zoomed;
else if (string_strcasecmp (property, "print_hooks_enabled") == 0)
return buffer->print_hooks_enabled;
else if (string_strcasecmp (property, "day_change") == 0)
@@ -1976,8 +1979,11 @@ gui_buffer_compute_num_displayed ()
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- if (ptr_buffer->number == ptr_window->buffer->number)
+ if ((ptr_buffer->number == ptr_window->buffer->number)
+ && (!ptr_buffer->zoomed || (ptr_buffer->active == 2)))
+ {
ptr_buffer->num_displayed++;
+ }
}
}
}
@@ -3821,6 +3827,7 @@ gui_buffer_hdata_buffer_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_gui_buffer, notify, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, num_displayed, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, active, INTEGER, 0, NULL, NULL);
+ HDATA_VAR(struct t_gui_buffer, zoomed, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, print_hooks_enabled, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, day_change, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, clear, INTEGER, 0, NULL, NULL);
@@ -3996,6 +4003,8 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_integer (ptr_item, "active", buffer->active))
return 0;
+ if (!infolist_new_var_integer (ptr_item, "zoomed", buffer->zoomed))
+ return 0;
if (!infolist_new_var_integer (ptr_item, "print_hooks_enabled", buffer->print_hooks_enabled))
return 0;
if (!infolist_new_var_integer (ptr_item, "day_change", buffer->day_change))
@@ -4206,6 +4215,7 @@ gui_buffer_print_log ()
log_printf (" notify. . . . . . . . . : %d", ptr_buffer->notify);
log_printf (" num_displayed . . . . . : %d", ptr_buffer->num_displayed);
log_printf (" active. . . . . . . . . : %d", ptr_buffer->active);
+ log_printf (" zoomed. . . . . . . . . : %d", ptr_buffer->zoomed);
log_printf (" print_hooks_enabled . . : %d", ptr_buffer->print_hooks_enabled);
log_printf (" day_change. . . . . . . : %d", ptr_buffer->day_change);
log_printf (" clear . . . . . . . . . : %d", ptr_buffer->clear);
View
3 src/gui/gui-buffer.h
@@ -96,6 +96,8 @@ struct t_gui_buffer
int active; /* 0 = buffer merged and not active */
/* 1 = active (merged or not) */
/* 2 = the only active (merged) */
+ int zoomed; /* 1 if a merged buffer is zoomed */
+ /* (it can be another buffer) */
int print_hooks_enabled; /* 1 if print hooks are enabled */
int day_change; /* 1 if "day change" displayed */
int clear; /* 1 if clear of buffer is allowed */
@@ -278,6 +280,7 @@ extern void gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
const char *value);
extern void gui_buffer_set_pointer (struct t_gui_buffer *buffer,
const char *property, void *pointer);
+extern void gui_buffer_compute_num_displayed ();
extern void gui_buffer_add_value_num_displayed (struct t_gui_buffer *buffer,
int value);
extern int gui_buffer_is_main (const char *plugin_name, const char *name);
View
15 src/gui/gui-input.c
@@ -1617,6 +1617,7 @@ void
gui_input_zoom_merged_buffer (struct t_gui_buffer *buffer)
{
struct t_gui_window *ptr_window;
+ struct t_gui_buffer *ptr_buffer;
int buffer_was_zoomed;
/* do nothing if current buffer is not merged with another buffer */
@@ -1660,6 +1661,20 @@ gui_input_zoom_merged_buffer (struct t_gui_buffer *buffer)
buffer->lines = buffer->mixed_lines;
}
+ /* set "zoomed" in merged buffers */
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if (ptr_buffer->number > buffer->number)
+ break;
+ if (ptr_buffer->number == buffer->number)
+ {
+ ptr_buffer->zoomed = (buffer->active == 2) ? 1 : 0;
+ }
+ }
+
+ gui_buffer_compute_num_displayed ();
+
gui_buffer_ask_chat_refresh (buffer, 2);
(void) hook_signal_send ((buffer_was_zoomed) ?

0 comments on commit 0e56110

Please sign in to comment.
Something went wrong with that request. Please try again.