From 6fab13434fc069ce73e0c71139815b71f068f1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Thu, 22 Oct 2015 10:51:27 +0200 Subject: [PATCH] Gtk: Optimize the update of transient buttons in the friend list --- gtk/friendlist.c | 30 ++++++++++++++++++++---------- tester/multi_call_tester.c | 4 ---- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/gtk/friendlist.c b/gtk/friendlist.c index 8a485ec36..6cad96ad6 100644 --- a/gtk/friendlist.c +++ b/gtk/friendlist.c @@ -981,29 +981,39 @@ void linphone_gtk_buddy_info_updated(LinphoneCore *lc, LinphoneFriend *lf){ linphone_gtk_show_friends(); } -static void update_hovered_row_path(GtkTreeView *friendlist, int x_window, int y_window) { +static gboolean update_hovered_row_path(GtkTreeView *friendlist, int x_window, int y_window) { int x_bin, y_bin; - GtkTreePath *path; + GtkTreePath *new_path; + GtkTreePath *old_path = (GtkTreePath *)g_object_get_data(G_OBJECT(friendlist), "hovered_row"); gtk_tree_view_convert_widget_to_bin_window_coords(friendlist, x_window, y_window, &x_bin, &y_bin); - gtk_tree_view_get_path_at_pos(friendlist, x_bin, y_bin, &path, NULL, NULL, NULL); - g_object_set_data_full(G_OBJECT(friendlist), "hovered_row", path, (GDestroyNotify)gtk_tree_path_free); + gtk_tree_view_get_path_at_pos(friendlist, x_bin, y_bin, &new_path, NULL, NULL, NULL); + if((new_path == NULL && old_path == NULL) || (new_path && old_path && gtk_tree_path_compare(new_path, old_path) == 0)) { + if(new_path) gtk_tree_path_free(new_path); + return FALSE; + } else { + g_object_set_data_full(G_OBJECT(friendlist), "hovered_row", new_path, (GDestroyNotify)gtk_tree_path_free); + return TRUE; + } } gboolean linphone_gtk_friend_list_enter_event_handler(GtkTreeView *friendlist, GdkEventCrossing *event) { - update_hovered_row_path(friendlist, event->x, event->y); - linphone_gtk_friend_list_update_button_display(friendlist); + gboolean path_has_changed = update_hovered_row_path(friendlist, event->x, event->y); + if(path_has_changed) linphone_gtk_friend_list_update_button_display(friendlist); return FALSE; } gboolean linphone_gtk_friend_list_leave_event_handler(GtkTreeView *friendlist, GdkEventCrossing *event) { - g_object_set_data(G_OBJECT(friendlist), "hovered_row", NULL); - linphone_gtk_friend_list_update_button_display(friendlist); + GtkTreePath *hovered_row = (GtkTreePath *)g_object_get_data(G_OBJECT(friendlist), "hovered_row"); + if(hovered_row) { + g_object_set_data(G_OBJECT(friendlist), "hovered_row", NULL); + linphone_gtk_friend_list_update_button_display(friendlist); + } return FALSE; } gboolean linphone_gtk_friend_list_motion_event_handler(GtkTreeView *friendlist, GdkEventMotion *event) { - update_hovered_row_path(friendlist, event->x, event->y); - linphone_gtk_friend_list_update_button_display(friendlist); + gboolean path_has_changed = update_hovered_row_path(friendlist, event->x, event->y); + if(path_has_changed) linphone_gtk_friend_list_update_button_display(friendlist); return FALSE; } diff --git a/tester/multi_call_tester.c b/tester/multi_call_tester.c index f3d4b32b5..42dae520f 100644 --- a/tester/multi_call_tester.c +++ b/tester/multi_call_tester.c @@ -621,8 +621,6 @@ static void eject_from_4_participants_conference(void) { LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc"); LinphoneCoreManager* michelle = linphone_core_manager_new( "michelle_rc"); int timeout_ms = 5000; - stats initial_marie_stat; - stats initial_pauline_stat; stats initial_laure_stat; stats initial_michelle_stat; @@ -647,8 +645,6 @@ static void eject_from_4_participants_conference(void) { BC_ASSERT_TRUE(pause_call_1(marie,marie_call_michelle,michelle,michelle_called_by_marie)); BC_ASSERT_TRUE(call(marie,laure)); - initial_marie_stat=marie->stat; - initial_pauline_stat=pauline->stat; initial_laure_stat=laure->stat; initial_michelle_stat=michelle->stat;