summaryrefslogtreecommitdiff
path: root/src/plugins/buflist/buflist-mouse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/buflist/buflist-mouse.c')
-rw-r--r--src/plugins/buflist/buflist-mouse.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/plugins/buflist/buflist-mouse.c b/src/plugins/buflist/buflist-mouse.c
index c574edb59..297bf2305 100644
--- a/src/plugins/buflist/buflist-mouse.c
+++ b/src/plugins/buflist/buflist-mouse.c
@@ -1,7 +1,7 @@
/*
* buflist-mouse.c - mouse actions for buflist
*
- * Copyright (C) 2003-2017 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2018 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -40,7 +40,7 @@ buflist_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
const char *ptr_bar_item_name, *ptr_bar_item_line, *keys, *ptr_value;
long item_line;
char *error, str_value[128], **list_keys;
- int i, num_keys, type;
+ int i, item_index, num_keys, type;
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
@@ -49,12 +49,13 @@ buflist_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
ptr_buffer = NULL;
- if (!buflist_list_buffers)
- goto end;
-
/* check bar item name */
ptr_bar_item_name = weechat_hashtable_get (info, "_bar_item_name");
- if (strcmp (ptr_bar_item_name, BUFLIST_BAR_ITEM_NAME) != 0)
+ item_index = buflist_bar_item_get_index (ptr_bar_item_name);
+ if (item_index < 0)
+ goto end;
+
+ if (!buflist_list_buffers[item_index])
goto end;
/* check bar item line */
@@ -65,13 +66,14 @@ buflist_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
if (!error || error[0])
goto end;
if ((item_line < 0)
- || (item_line >= weechat_arraylist_size (buflist_list_buffers)))
+ || (item_line >= weechat_arraylist_size (buflist_list_buffers[item_index])))
{
goto end;
}
/* check if buffer pointer is still valid */
- ptr_buffer = weechat_arraylist_get (buflist_list_buffers, item_line);
+ ptr_buffer = weechat_arraylist_get (buflist_list_buffers[item_index],
+ item_line);
if (!ptr_buffer)
goto end;
if (!weechat_hdata_check_pointer (
@@ -128,10 +130,10 @@ end:
break;
case WEECHAT_HDATA_TIME:
snprintf (str_value, sizeof (str_value),
- "%ld",
+ "%lld",
(ptr_buffer) ?
- (long int)weechat_hdata_time (buflist_hdata_buffer,
- ptr_buffer, list_keys[i]) : -1);
+ (long long)weechat_hdata_time (buflist_hdata_buffer,
+ ptr_buffer, list_keys[i]) : -1);
weechat_hashtable_set (info, list_keys[i], str_value);
break;
default: /* ignore other types */
@@ -321,10 +323,16 @@ buflist_hsignal_cb (const void *pointer, void *data, const char *signal,
int
buflist_mouse_init ()
{
- weechat_hook_focus (BUFLIST_BAR_ITEM_NAME, &buflist_focus_cb, NULL, NULL);
+ int i;
+
+ for (i = 0; i < BUFLIST_BAR_NUM_ITEMS; i++)
+ {
+ weechat_hook_focus (buflist_bar_item_get_name (i),
+ &buflist_focus_cb, NULL, NULL);
+ }
- weechat_hook_hsignal(BUFLIST_MOUSE_HSIGNAL,
- &buflist_hsignal_cb, NULL, NULL);
+ weechat_hook_hsignal (BUFLIST_MOUSE_HSIGNAL,
+ &buflist_hsignal_cb, NULL, NULL);
return 1;
}