[Xfce4-commits] <xfce4-panel:devel> Don't request any size on the tasklist if there are no visible children.

Nick Schermer nick at xfce.org
Tue Aug 11 20:32:03 CEST 2009


Updating branch refs/heads/devel
         to 063f465140d068588a54cfa82dc3ea2dc0f9a08f (commit)
       from 501400095a4895c3a17768805ea665bf553dfcc3 (commit)

commit 063f465140d068588a54cfa82dc3ea2dc0f9a08f
Author: Nick Schermer <nick at xfce.org>
Date:   Thu May 14 23:02:30 2009 +0200

    Don't request any size on the tasklist if there are no visible children.

 plugins/tasklist/tasklist-widget.c |   45 ++++++++++++++++++++---------------
 1 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c
index 78bbd84..1f3a7ca 100644
--- a/plugins/tasklist/tasklist-widget.c
+++ b/plugins/tasklist/tasklist-widget.c
@@ -443,7 +443,7 @@ xfce_tasklist_size_request (GtkWidget      *widget,
   XfceTasklistChild *child;
   gint               n;
   gint               rows, cols, length;
-
+  
   /* walk all the children */
   for (li = tasklist->children, n = 0; li != NULL; li = li->next)
     {
@@ -459,28 +459,35 @@ xfce_tasklist_size_request (GtkWidget      *widget,
       n++;
     }
 
-  /* calculate the number of rows */
-  rows = tasklist->size / tasklist->max_button_size;
-  rows = MIN (rows, n);
-  rows = MAX (rows, 1);
-
-  /* calculate the number of columns */
-  cols = n / rows;
-  cols = MAX (cols, 1);
-  if (cols * rows < n)
-    cols++;
-
-  /* get the requested length of the tasklist */
-  if (tasklist->show_labels)
+  if (G_UNLIKELY (n == 0))
     {
-      if (tasklist->max_button_length != -1)
-        length = cols * tasklist->max_button_length;
-      else
-        length = cols * DEFAULT_BUTTON_LENGTH;
+      /* don't request any size if there are no visible children */
+      length = 0;
     }
   else
     {
-      length = (tasklist->size / rows) * cols;
+      /* calculate the number of rows */
+      rows = tasklist->size / tasklist->max_button_size;
+      rows = CLAMP (rows, 1, n);
+
+      /* calculate the number of columns */
+      cols = n / rows;
+      cols = MAX (cols, 1);
+      if (cols * rows < n)
+        cols++;
+
+      /* get the requested length of the tasklist */
+      if (tasklist->show_labels)
+        {
+          if (tasklist->max_button_length != -1)
+            length = cols * tasklist->max_button_length;
+          else
+            length = cols * DEFAULT_BUTTON_LENGTH;
+        }
+      else
+        {
+          length = (tasklist->size / rows) * cols;
+        }
     }
 
   /* set the requested sizes */



More information about the Xfce4-commits mailing list