From 58fe70175b096b94d462e59e86ca721abc2b6c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= Date: Tue, 11 Oct 2022 18:22:01 +0300 Subject: tasklist: avoid useless tooltips Do not show tooltip if text does not differ from button text and is already fully visible / not ellipsized. https://gitlab.gnome.org/GNOME/libwnck/-/issues/115 --- libwnck/tasklist.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libwnck/tasklist.c b/libwnck/tasklist.c index f5b5299..ccc7427 100644 --- a/libwnck/tasklist.c +++ b/libwnck/tasklist.c @@ -590,12 +590,32 @@ wnck_button_query_tooltip (GtkWidget *widget, GtkTooltip *tooltip) { WnckButton *self; + GtkLabel *label; + char *tooltip_text; self = WNCK_BUTTON (widget); if (!self->tasklist->priv->tooltips_enabled) return FALSE; + label = GTK_LABEL (self->label); + tooltip_text = gtk_widget_get_tooltip_text (widget); + + if (g_strcmp0 (gtk_label_get_text (label), tooltip_text) == 0) + { + PangoLayout *layout; + + layout = gtk_label_get_layout (label); + + if (!pango_layout_is_ellipsized (layout)) + { + g_free (tooltip_text); + return FALSE; + } + } + + g_free (tooltip_text); + return GTK_WIDGET_CLASS (wnck_button_parent_class)->query_tooltip (widget, x, y, -- cgit v1.2.1