diff options
author | Andrzej <ndrwrdck@gmail.com> | 2012-01-28 01:31:59 +0900 |
---|---|---|
committer | Andrzej <ndrwrdck@gmail.com> | 2012-03-11 10:22:55 +0900 |
commit | 75715329587059cd0808e88dc723be59f7af4b74 (patch) | |
tree | bc2d30cea6a84ddf48baf430151d7ec5b4dd805b | |
parent | 22867c5e4f507864c45cb43f1b984a4f2f2934b9 (diff) |
systray: fixing visual artifacts, bug #8399.andrzejr/systray
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.
-rw-r--r-- | 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 13ab3c84..a64664d2 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)); |