--- libwnck-2.28.0.old/libwnck/tasklist.c	2010-03-09 10:03:41.000000000 +0300
+++ libwnck-2.28.0/libwnck/tasklist.c	2010-03-09 10:15:11.000000000 +0300
@@ -1298,6 +1298,7 @@
   int n_windows;
   int n_startup_sequences;
   int n_rows;
+  int n_buttons;
   int n_cols, last_n_cols;
   int n_grouped_buttons;
   gboolean score_set;
@@ -1355,11 +1356,13 @@
 			tasklist->priv->max_button_width);
   
   /* Try ungrouped mode */
+  n_buttons = n_windows + n_startup_sequences;
   wnck_tasklist_layout (&fake_allocation,
 			tasklist->priv->max_button_width,
 			tasklist->priv->max_button_height,
-			n_windows + n_startup_sequences,
+			n_buttons,
 			&n_cols, &n_rows);
+  n_rows = MAX(1,n_buttons);
 
   last_n_cols = G_MAXINT;
   lowest_range = G_MAXINT;
@@ -1397,11 +1400,14 @@
 
       n_grouped_buttons += g_list_length (class_group_task->windows) - 1;
 
+      n_buttons = n_startup_sequences + n_windows - n_grouped_buttons;
       wnck_tasklist_layout (&fake_allocation,
 			    tasklist->priv->max_button_width,
 			    tasklist->priv->max_button_height,
-			    n_startup_sequences + n_windows - n_grouped_buttons,
+			    n_buttons,
 			    &n_cols, &n_rows);
+      n_rows = MAX(1,n_buttons);
+			    
       if (n_cols != last_n_cols &&
 	  (tasklist->priv->grouping == WNCK_TASKLIST_AUTO_GROUP ||
 	   ungrouped_class_groups == NULL))
