Index: libwnck/libwnck/tasklist.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/tasklist.c,v
retrieving revision 1.75
diff -u -p -r1.75 tasklist.c
--- libwnck/libwnck/tasklist.c	20 Feb 2005 23:30:35 -0000	1.75
+++ libwnck/libwnck/tasklist.c	23 Feb 2005 06:47:15 -0000
@@ -217,12 +217,19 @@ static void     wnck_tasklist_remove	   
 					     GtkWidget	    *widget);
 static void     wnck_tasklist_free_tasks    (WnckTasklist   *tasklist);
 static void     wnck_tasklist_update_lists  (WnckTasklist   *tasklist);
-static int      wnck_tasklist_layout        (GtkAllocation  *allocation,
-					     int             max_width,
-					     int             max_height,
-					     int             n_buttons,
-					     int            *n_cols_out,
-					     int            *n_rows_out);
+static void     wnck_tasklist_request_layout (int             min_width,
+                                              int             min_height,
+                                              int             button_max_width,
+                                              int             button_max_height,
+                                              int             n_buttons,
+                                              GtkRequisition *requisition,
+                                              int            *n_cols_out,
+                                              int            *n_rows_out);
+static int      wnck_tasklist_allocate_layout (GtkAllocation *allocation,
+                                               int            button_height,
+                                               int            n_buttons,
+                                               int           *n_cols_out,
+                                               int           *n_rows_out);
 
 static void     wnck_tasklist_active_window_changed    (WnckScreen   *screen,
 							WnckTasklist *tasklist);
@@ -733,21 +740,41 @@ wnck_tasklist_set_icon_loader (WnckTaskl
   tasklist->priv->free_icon_loader_data = free_data_func;  
 }
 
+/* determines the maximum size the tasklist can be, and sets n_cols_out
+ * n_rows_out respectively.  note this is far from ideal, as we cannot
+ * know the required geometry until we know the height (and thus how
+ * many rows to use.) (or can we--anyone know more than me?) */
+static void
+wnck_tasklist_request_layout (int             min_width,
+                              int             min_height,
+                              int             button_max_width,
+                              int             button_max_height,
+                              int             n_buttons,
+                              GtkRequisition *requisition,
+                              int            *n_cols_out,
+                              int            *n_rows_out)
+{  
+  requisition->width = MAX(min_width, button_max_width * n_buttons);
+  requisition->height = MAX(min_height, button_max_height * n_buttons);
+  
+  *n_cols_out = n_buttons;
+  *n_rows_out = n_buttons;
+}
+
 /* returns the maximal possible button width (i.e. if you
  * don't want to stretch the buttons to fill the alloctions
  * the width can be smaller) */
 static int
-wnck_tasklist_layout (GtkAllocation *allocation,
-		      int            max_width,
-		      int            max_height,
-		      int            n_buttons,
-		      int           *n_cols_out,
-		      int           *n_rows_out)
+wnck_tasklist_allocate_layout (GtkAllocation *allocation,
+                               int            button_height,
+                               int            n_buttons,
+                               int           *n_cols_out,
+                               int           *n_rows_out)
 {
   int n_cols, n_rows;
 
   /* How many rows fit in the allocation */
-  n_rows = allocation->height / max_height;
+  n_rows = allocation->height / button_height;
 
   /* Don't have more rows than buttons */
   n_rows = MIN (n_rows, n_buttons);
@@ -852,7 +879,6 @@ wnck_tasklist_size_request  (GtkWidget  
 {
   WnckTasklist *tasklist;
   GtkRequisition child_req;
-  GtkAllocation  fake_allocation;
   int max_height = 1;
   int max_width = 1;
   /* int u_width, u_height; */
@@ -942,12 +968,7 @@ wnck_tasklist_size_request  (GtkWidget  
   requisition->width = MAX(requisition->width, tasklist->priv->minimum_width);
   requisition->height = MAX(requisition->height, tasklist->priv->minimum_height);
   */
-  requisition->width = tasklist->priv->minimum_width;
-  requisition->height = tasklist->priv->minimum_height;
   
-  fake_allocation.width = requisition->width;
-  fake_allocation.height = requisition->height;
-
   array = g_array_new (FALSE, FALSE, sizeof (int));
 
   /* Calculate size_hints list */
@@ -962,11 +983,12 @@ wnck_tasklist_size_request  (GtkWidget  
 			tasklist->priv->max_button_width);
   
   /* Try ungrouped mode */
-  wnck_tasklist_layout (&fake_allocation,
+  wnck_tasklist_request_layout (tasklist->priv->minimum_width,
+			tasklist->priv->minimum_height,
 			tasklist->priv->max_button_width,
 			tasklist->priv->max_button_height,
 			n_windows + n_startup_sequences,
-			&n_cols, &n_rows);
+			requisition, &n_cols, &n_rows);
 
   last_n_cols = G_MAXINT;
   lowest_range = G_MAXINT;
@@ -994,11 +1016,12 @@ wnck_tasklist_size_request  (GtkWidget  
 
       n_grouped_buttons += g_list_length (class_group_task->windows) - 1;
 
-      wnck_tasklist_layout (&fake_allocation,
+      wnck_tasklist_request_layout (tasklist->priv->minimum_width,
+			    tasklist->priv->minimum_height,
 			    tasklist->priv->max_button_width,
 			    tasklist->priv->max_button_height,
 			    n_startup_sequences + n_windows - n_grouped_buttons,
-			    &n_cols, &n_rows);
+			    requisition, &n_cols, &n_rows);
       if (n_cols != last_n_cols &&
 	  (tasklist->priv->grouping == WNCK_TASKLIST_AUTO_GROUP ||
 	   ungrouped_class_groups == NULL))
@@ -1084,8 +1107,7 @@ wnck_tasklist_size_allocate (GtkWidget  
 			tasklist->priv->max_button_width);
 
   /* Try ungrouped mode */
-  button_width = wnck_tasklist_layout (allocation,
-				       tasklist->priv->max_button_width,
+  button_width = wnck_tasklist_allocate_layout (allocation,
 				       tasklist->priv->max_button_height,
 				       n_startup_sequences + n_windows,
 				       &n_cols, &n_rows);
@@ -1124,8 +1146,7 @@ wnck_tasklist_size_allocate (GtkWidget  
 	  gtk_widget_set_child_visible (GTK_WIDGET (class_group_task->button), FALSE);
 	}
       
-      button_width = wnck_tasklist_layout (allocation,
-					   tasklist->priv->max_button_width,
+      button_width = wnck_tasklist_allocate_layout (allocation,
 					   tasklist->priv->max_button_height,
 					   n_startup_sequences + n_windows - n_grouped_buttons,
 					   &n_cols, &n_rows);
