[Xfce4-commits] <xfce4-panel:andrzejr/systray> systray: fixing visual artifacts, bug #8399.

Andrzej noreply at xfce.org
Thu Apr 4 01:14:04 CEST 2013


Updating branch refs/heads/andrzejr/systray
         to 75715329587059cd0808e88dc723be59f7af4b74 (commit)
       from 22867c5e4f507864c45cb43f1b984a4f2f2934b9 (commit)

commit 75715329587059cd0808e88dc723be59f7af4b74
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Sat Jan 28 01:31:59 2012 +0900

    systray: fixing visual artifacts, bug #8399.
    
    cols variable (number of columns in horizontal mode) was calculated
    incorrectly and wasn't checked during allocation.
    
    At start-up (in vertical modes) the allocation->height was occasionally
    equal to 1, which made some icons to be temporarily allocated outside
    the systray. Some applications didn't like it.
    
    In addition to the actual fix, an optimization "fast path" was added to
    filter out common start-up cases early.
    
    A similar (although not that often) issue was observed in older systray
    versions, which could indicate an error in coordinate checking. Coordinate
    checking is now replaced with slot column/row checking.

 plugins/systray/systray-box.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/plugins/systray/systray-box.c b/plugins/systray/systray-box.c
index 13ab3c8..a64664d 100644
--- a/plugins/systray/systray-box.c
+++ b/plugins/systray/systray-box.c
@@ -435,6 +435,11 @@ systray_box_size_allocate (GtkWidget     *widget,
   gint            alloc_size;
   gint            idx;
 
+  /* Performance optimization. The allocation size is checked in detail below. */
+  /* This is just a fast path for some obvious cases, which occur during start-up. */
+  if (allocation->width < 10 || allocation->height < 10)
+    return;
+
   widget->allocation = *allocation;
 
   border = GTK_CONTAINER (widget)->border_width;
@@ -444,10 +449,10 @@ systray_box_size_allocate (GtkWidget     *widget,
   systray_box_size_get_max_child_size (box, alloc_size, &rows, &row_size, &icon_size);
 
   alloc_size = (box->horizontal ? allocation->width : allocation->height) - 2 * border;
-  cols = ceil ((gdouble) (alloc_size - row_size) / (gdouble) (row_size + SPACING)) + 1;
+  cols = floor ((gdouble) (alloc_size - row_size) / (gdouble) (row_size + SPACING)) + 1;
 
-  panel_debug_filtered (PANEL_DEBUG_SYSTRAY, "allocate rows=%d, row_size=%d, w=%d, h=%d, horiz=%s, border=%d",
-                        rows, row_size, allocation->width, allocation->height,
+  panel_debug_filtered (PANEL_DEBUG_SYSTRAY, "allocate rows=%d, cols=%d, row_size=%d, w=%d, h=%d, horiz=%s, border=%d",
+                        rows, cols, row_size, allocation->width, allocation->height,
                         PANEL_DEBUG_BOOL (box->horizontal), border);
 
 
@@ -481,9 +486,11 @@ systray_box_size_allocate (GtkWidget     *widget,
   restart_allocation:
 
   slot = 0;
+  col = 0;
+
   g_slist_free (occupied_slots);
 
-  for (li = box->childeren; li != NULL; li = li->next)
+  for (li = box->childeren; li != NULL && col < cols; li = li->next)
     {
       child = GTK_WIDGET (li->data);
       panel_return_if_fail (XFCE_IS_SYSTRAY_SOCKET (child));


More information about the Xfce4-commits mailing list