# HG changeset patch # User franky # Date 1477985947 -3600 # Node ID 0d350e979bde8543a4366669b5b18cfcce5e1c12 # Parent 71ec417320355ccb451c0804fafdbea75830e394 Don't rebuild the buddylist multiple times before a screen refresh diff -r 71ec41732035 -r 0d350e979bde mcabber/mcabber/commands.c --- a/mcabber/mcabber/commands.c Wed Dec 21 20:43:58 2016 +0100 +++ b/mcabber/mcabber/commands.c Tue Nov 01 08:39:07 2016 +0100 @@ -602,7 +602,7 @@ lock = !(buddy_getflags(bud) & ROSTER_FLAG_USRLOCK); buddy_setflags(bud, ROSTER_FLAG_USRLOCK, lock); if (may_need_refresh) { - buddylist_build(); + buddylist_defer_build(); update_roster = TRUE; } } @@ -833,15 +833,15 @@ } else if (!strcasecmp(subcmd, "hide_offline")) { buddylist_set_hide_offline_buddies(TRUE); if (current_buddy) - buddylist_build(); + buddylist_defer_build(); update_roster = TRUE; } else if (!strcasecmp(subcmd, "show_offline")) { buddylist_set_hide_offline_buddies(FALSE); - buddylist_build(); + buddylist_defer_build(); update_roster = TRUE; } else if (!strcasecmp(subcmd, "toggle_offline")) { buddylist_set_hide_offline_buddies(-1); - buddylist_build(); + buddylist_defer_build(); update_roster = TRUE; } else if (!strcasecmp(subcmd, "display")) { scr_roster_display(arg); @@ -1257,7 +1257,7 @@ buddy_hide_group(group, group_state); - buddylist_build(); + buddylist_defer_build(); update_roster = TRUE; do_group_return: @@ -2627,7 +2627,7 @@ g_free(roomname_tmp); g_free(nick); g_free(pass_utf8); - buddylist_build(); + buddylist_defer_build(); update_roster = TRUE; free_arg_lst(paramlst); } @@ -2926,7 +2926,7 @@ // Delete the room roster_del_user(buddy_getjid(bud)); scr_update_buddy_window(); - buddylist_build(); + buddylist_defer_build(); update_roster = TRUE; } diff -r 71ec41732035 -r 0d350e979bde mcabber/mcabber/hooks.c --- a/mcabber/mcabber/hooks.c Wed Dec 21 20:43:58 2016 +0100 +++ b/mcabber/mcabber/hooks.c Tue Nov 01 08:39:07 2016 +0100 @@ -567,7 +567,7 @@ roster_setstatus(bjid, rn, prio, status, status_msg, timestamp, role_none, affil_none, NULL); - buddylist_build(); + buddylist_defer_build(); update_roster = TRUE; hlog_write_status(bjid, timestamp, status, status_msg); diff -r 71ec41732035 -r 0d350e979bde mcabber/mcabber/roster.c --- a/mcabber/mcabber/roster.c Wed Dec 21 20:43:58 2016 +0100 +++ b/mcabber/mcabber/roster.c Tue Nov 01 08:39:07 2016 +0100 @@ -121,6 +121,7 @@ static GSList *unread_list; static GHashTable *unread_jids; GList *buddylist; +static gboolean _rebuild_buddylist = FALSE; GList *current_buddy; GList *alternate_buddy; GList *last_activity_buddy; @@ -472,7 +473,7 @@ // We need to rebuild the list if (current_buddy) - buddylist_build(); + buddylist_defer_build(); // TODO What we could do, too, is to check if the deleted node is // current_buddy, in which case we could move current_buddy to the // previous (or next) node. @@ -518,7 +519,7 @@ groups = NULL; // Update (i.e. free) buddylist if (buddylist) - buddylist_build(); + buddylist_defer_build(); } } @@ -718,7 +719,7 @@ } if (buddylist && (new_roster_item || !g_list_find(buddylist, roster_usr))) - buddylist_build(); + buddylist_defer_build(); roster_msg_setflag_return: if (unread_list_modified) { @@ -949,6 +950,11 @@ return display_filter; } +void buddylist_defer_build(void) +{ + _rebuild_buddylist = TRUE; +} + // buddylist_build() // Creates the buddylist from the roster entries. void buddylist_build(void) @@ -960,6 +966,10 @@ roster *roster_last_activity_buddy = NULL; int shrunk_group; + if (_rebuild_buddylist == FALSE) + return; + _rebuild_buddylist = FALSE; + // We need to remember which buddy is selected. if (current_buddy) roster_current_buddy = BUDDATA(current_buddy); @@ -1094,7 +1104,7 @@ my_newgroup->list = g_slist_insert_sorted(my_newgroup->list, roster_usr, (GCompareFunc)&roster_compare_name); - buddylist_build(); + buddylist_defer_build(); } void buddy_setname(gpointer rosterdata, char *newname) @@ -1118,7 +1128,7 @@ sl_group = &((roster*)((GSList*)roster_usr->list)->data)->list; *sl_group = g_slist_sort(*sl_group, (GCompareFunc)&roster_compare_name); - buddylist_build(); + buddylist_defer_build(); } const char *buddy_getname(gpointer rosterdata) @@ -1552,6 +1562,7 @@ GList *buddy; roster *roster_usr; + buddylist_build(); if (!buddylist) return NULL; for (buddy = buddylist; buddy; buddy = g_list_next(buddy)) { @@ -1570,6 +1581,7 @@ { GList *buddy = current_buddy; roster *roster_usr; + buddylist_build(); if (!buddylist || !current_buddy) return NULL; for (;;) { gchar *jid_locale, *name_locale; diff -r 71ec41732035 -r 0d350e979bde mcabber/mcabber/roster.h --- a/mcabber/mcabber/roster.h Wed Dec 21 20:43:58 2016 +0100 +++ b/mcabber/mcabber/roster.h Tue Nov 01 08:39:07 2016 +0100 @@ -190,6 +190,7 @@ guint roster_getsubscription(const char *jid); void roster_unsubscribed(const char *jid); +void buddylist_defer_build(void); void buddylist_build(void); void buddy_hide_group(gpointer rosterdata, int hide); void buddylist_set_hide_offline_buddies(int hide); diff -r 71ec41732035 -r 0d350e979bde mcabber/mcabber/screen.c --- a/mcabber/mcabber/screen.c Wed Dec 21 20:43:58 2016 +0100 +++ b/mcabber/mcabber/screen.c Tue Nov 01 08:39:07 2016 +0100 @@ -1795,7 +1795,7 @@ // Build the buddylist at least once, to make sure the special buffer // is added - buddylist_build(); + buddylist_defer_build(); // Init prev_chatwidth; this variable will be used to prevent us // from rewrapping buffers when the width doesn't change. @@ -2088,6 +2088,8 @@ // We can reset update_roster update_roster = FALSE; + buddylist_build(); + getmaxyx(rosterWnd, maxy, maxx); maxx--; // Last char is for vertical border @@ -2538,7 +2540,7 @@ } // We should rebuild the buddylist but not everytime if (!(buddylist_get_filter() & 1<data, ROSTER_TYPE_ROOM); } - buddylist_build(); + buddylist_defer_build(); scr_draw_roster(); goto gotmessage_return; } diff -r 71ec41732035 -r 0d350e979bde mcabber/mcabber/xmpp_iq.c --- a/mcabber/mcabber/xmpp_iq.c Wed Dec 21 20:43:58 2016 +0100 +++ b/mcabber/mcabber/xmpp_iq.c Tue Nov 01 08:39:07 2016 +0100 @@ -668,7 +668,7 @@ lm_message_unref(result); } - buddylist_build(); + buddylist_defer_build(); update_roster = TRUE; if (need_refresh) scr_update_buddy_window(); diff -r 71ec41732035 -r 0d350e979bde mcabber/mcabber/xmpp_iqrequest.c --- a/mcabber/mcabber/xmpp_iqrequest.c Wed Dec 21 20:43:58 2016 +0100 +++ b/mcabber/mcabber/xmpp_iqrequest.c Tue Nov 01 08:39:07 2016 +0100 @@ -670,7 +670,7 @@ } g_free(bjid); - buddylist_build(); + buddylist_defer_build(); update_roster = TRUE; }