From 299fd12061be8eec8cdb97b7b0afb0307ef86944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Mon, 28 Mar 2016 18:20:19 +0200 Subject: clock: update tooltip only when new text is different This can prevent problems with OpenGL on some drivers (see #397) --- applets/clock/clock.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'applets') diff --git a/applets/clock/clock.c b/applets/clock/clock.c index 6bb0890b..17aeb172 100644 --- a/applets/clock/clock.c +++ b/applets/clock/clock.c @@ -674,6 +674,8 @@ update_clock (ClockData * cd) static void update_tooltip (ClockData * cd) { + char *tip; + char *old_tip; if (!cd->showdate) { struct tm *tm; char date[256]; @@ -681,7 +683,6 @@ update_tooltip (ClockData * cd) char *zone; time_t now_t; struct tm now; - char *tip; tm = localtime (&cd->current_time); @@ -714,17 +715,23 @@ update_tooltip (ClockData * cd) tip = g_strdup_printf (utf8, zone); - gtk_widget_set_tooltip_text (cd->panel_button, tip); g_free (utf8); - g_free (tip); } else { - if (cd->calendar_popup) - gtk_widget_set_tooltip_text (cd->panel_button, - _("Click to hide month calendar")); - else - gtk_widget_set_tooltip_text (cd->panel_button, - _("Click to view month calendar")); + if (cd->calendar_popup) + tip = _("Click to hide month calendar"); + else + tip = _("Click to view month calendar"); } + + /* Update only when the new tip is different. + * This can prevent problems with OpenGL on some drivers */ + old_tip = gtk_widget_get_tooltip_text (cd->panel_button); + if (g_strcmp0 (old_tip, tip)) + gtk_widget_set_tooltip_text (cd->panel_button, tip); + + g_free (old_tip); + if (!cd->showdate) + g_free (tip); } static void -- cgit v1.2.1