[Xfce4-commits] [xfce/xfce4-panel] 01/01: tasklist: Only base bg color of group indicator on gtk theme

noreply at xfce.org noreply at xfce.org
Sun Jun 30 22:42:15 CEST 2019


This is an automated email from the git hooks/post-receive script.

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-panel.

commit 90faa4c5b56e12b5d19fbc8a553fcb99d5a2b214
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Sun Jun 30 22:36:59 2019 +0200

    tasklist: Only base bg color of group indicator on gtk theme
    
    The previous approach never worked because we cannot easily get the
    *actual* background color of the panel (e.g. users can override the
    background color or use an image). So we now just take the fg color,
    which is reliable, as it's used for all text on the panel, use that for
    drawing the bubble and then "calculate" whether to write into that with
    white or black. This should work in most cases.
---
 plugins/tasklist/tasklist-widget.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c
index 7126ad3..8857fa0 100644
--- a/plugins/tasklist/tasklist-widget.c
+++ b/plugins/tasklist/tasklist-widget.c
@@ -3643,13 +3643,17 @@ xfce_tasklist_group_button_button_draw (GtkWidget         *widget,
 
       gtk_widget_get_allocation (GTK_WIDGET (widget), allocation);
       cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
-      /* Get the theme colors. We use the foreground alpha for both fg and bg for
-         consistent alpha. */
+      /* Get the theme fg color for drawing the circle background. We then use a
+         simple calculation to decide whether the background color - which is ironically
+         used for the text - should be white or black.
+         We use the theme fg color alpha for the fg and the bg for consistency. */
       context = gtk_widget_get_style_context (widget);
       gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg);
-      gtk_style_context_get (context, gtk_style_context_get_state (context),
-                             GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
-                             &bg, NULL);
+      /* The magical number 1.5 is a third of the sum of the max rgb values */
+      if ((fg.red + fg.green + fg.blue) < 1.5)
+        gdk_rgba_parse (&bg, "#ffffff");
+      else
+        gdk_rgba_parse (&bg, "#000000");
 
       n_windows = g_strdup_printf ("%d", group_child->n_windows);
       n_windows_layout = gtk_widget_create_pango_layout (GTK_WIDGET (widget), n_windows);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list