# HG changeset patch # User Mikael Berthe # Date 1269709769 -3600 # Node ID d10c291d31a77cc16da1803416fa4cbc0eb6fa04 # Parent a09eddfdb6e856fae49c30912a32bd7aacfab474 Do not call hk_unread_list_change() too frequently diff -r a09eddfdb6e8 -r d10c291d31a7 mcabber/mcabber/hooks.c --- 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 }