Mercurial > hg
changeset 1838:d10c291d31a7
Do not call hk_unread_list_change() too frequently
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 27 Mar 2010 18:09:29 +0100 |
parents | a09eddfdb6e8 |
children | f0a07658e009 |
files | mcabber/mcabber/hooks.c |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/mcabber/hooks.c Sat Mar 27 16:26:52 2010 +0100 +++ b/mcabber/mcabber/hooks.c Sat Mar 27 18:09:29 2010 +0100 @@ -653,6 +653,19 @@ guint muc_unread, guint muc_attention) { #ifdef MODULES_ENABLE + // Previous static variables are initialized with an unlikely value + static guint prev_unread = 65535; + static guint prev_attention = 65535; + static guint prev_muc_unread = 65535; + static guint prev_muc_attention = 65535; + + // Do not call the handlers if the unread values haven't changed + if (unread_count == prev_unread && + attention_count == prev_attention && + muc_unread == prev_muc_unread && + muc_attention == prev_muc_attention) + return; + gchar *str_unread = g_strdup_printf("%u", unread_count); gchar *str_attention = g_strdup_printf("%u", attention_count); gchar *str_muc_unread = g_strdup_printf("%u", muc_unread); @@ -669,6 +682,11 @@ g_free(str_attention); g_free(str_muc_unread); g_free(str_muc_attention); + + prev_unread = unread_count; + prev_attention = attention_count; + prev_muc_unread = muc_unread; + prev_muc_attention = muc_attention; #endif }