--- orig/libwnck-2.27.5/libwnck/tasklist.c	2009-04-19 11:40:32.000000000 -0600
+++ new/libwnck-2.27.5/libwnck/tasklist.c	2009-08-08 00:50:31.705267782 -0600
@@ -91,7 +91,7 @@
 typedef struct _WnckTask        WnckTask;
 typedef struct _WnckTaskClass   WnckTaskClass;
 
-#define DEFAULT_GROUPING_LIMIT 80
+#define DEFAULT_GROUPING_LIMIT -3
 
 #define MINI_ICON_SIZE DEFAULT_MINI_ICON_WIDTH
 #define TASKLIST_BUTTON_PADDING 4
@@ -1146,21 +1146,42 @@
 		      int           *n_cols_out,
 		      int           *n_rows_out)
 {
+  if (allocation->width > allocation->height) {    
+    *n_cols_out = n_buttons;
+    *n_rows_out = 1;
+  } else {
+    *n_cols_out = 1;
+    *n_rows_out = n_buttons;
+  }  
+
+  return max_width;
+  
+  
   int n_cols, n_rows;
 
   /* How many rows fit in the allocation */
   n_rows = allocation->height / max_height;
+  n_cols = allocation->width / max_width;
 
   /* Don't have more rows than buttons */
   n_rows = MIN (n_rows, n_buttons);
+  n_cols = MIN (n_cols, n_buttons);
 
   /* At least one row */
+  /* At least one column */
   n_rows = MAX (n_rows, 1);
-  
+  n_cols = MAX (n_cols, 1);
+
   /* We want to use as many rows as possible to limit the width */
-  n_cols = (n_buttons + n_rows - 1) / n_rows;
+  if (max_width > max_height) {    
+    n_cols = (n_buttons + n_rows - 1) / n_rows;
+  } else {
+    n_rows = (n_buttons + n_cols - 1) / n_cols;
+  }
 
+  /* At least one row */
   /* At least one column */
+  n_rows = MAX (n_rows, 1);
   n_cols = MAX (n_cols, 1);
 
   *n_cols_out = n_cols;
@@ -1307,6 +1328,7 @@
 
   tasklist = WNCK_TASKLIST (widget);
 
+
   /* Calculate max needed height and width of the buttons */
 #define GET_MAX_WIDTH_HEIGHT_FROM_BUTTONS(list)                 \
   l = list;                                                     \
@@ -1340,6 +1362,11 @@
   fake_allocation.width = GTK_WIDGET (tasklist)->allocation.width;
   fake_allocation.height = GTK_WIDGET (tasklist)->allocation.height;
 
+  if (fake_allocation.height > fake_allocation.width) {  
+    g_message("fake: %d %d    \n", fake_allocation.height, fake_allocation.width);
+  }
+
+
   array = g_array_new (FALSE, FALSE, sizeof (int));
 
   /* Calculate size_hints list */
@@ -1349,7 +1376,7 @@
   n_grouped_buttons = 0;
   ungrouped_class_groups = g_list_copy (tasklist->priv->class_groups);
   score_set = FALSE;
-
+//###
   grouping_limit = MIN (tasklist->priv->grouping_limit,
 			tasklist->priv->max_button_width);
   
@@ -1359,64 +1386,38 @@
 			tasklist->priv->max_button_height,
 			n_windows + n_startup_sequences,
 			&n_cols, &n_rows);
-
+  if (fake_allocation.height > fake_allocation.width){
+    g_message("layout: %d %d %d %d\n", fake_allocation.height, fake_allocation.width, n_cols, n_rows);
+  }
   last_n_cols = G_MAXINT;
   lowest_range = G_MAXINT;
   if (tasklist->priv->grouping != WNCK_TASKLIST_ALWAYS_GROUP)
     {
-      val = n_cols * tasklist->priv->max_button_width;
+      val = MAX(400, n_rows * tasklist->priv->max_button_height);
       g_array_insert_val (array, array->len, val);
-      val = n_cols * grouping_limit;
+      val = 400;
       g_array_insert_val (array, array->len, val);
+    
+/*      if (fake_allocation.height < fake_allocation.width){*/
+/*        val = n_cols * tasklist->priv->max_button_width;*/
+/*        g_array_insert_val (array, array->len, val);*/
+/*        val = n_cols * grouping_limit;*/
+/*        g_array_insert_val (array, array->len, val);*/
+/*      } else {*/
+/*        val = n_rows * tasklist->priv->max_button_height;*/
+/*        g_array_insert_val (array, array->len, val);*/
+/*        val = 10 * grouping_limit;*/
+/*        g_array_insert_val (array, array->len, val);*/
+/*      }*/
 
       last_n_cols = n_cols;
       lowest_range = val;
     }
 
-  while (ungrouped_class_groups != NULL &&
-	 tasklist->priv->grouping != WNCK_TASKLIST_NEVER_GROUP)
-    {
-      if (!score_set)
-	{
-	  wnck_tasklist_score_groups (tasklist, ungrouped_class_groups);
-	  score_set = TRUE;
-	}
-
-      ungrouped_class_groups = wnck_task_get_highest_scored (ungrouped_class_groups, &class_group_task);
-
-      n_grouped_buttons += g_list_length (class_group_task->windows) - 1;
-
-      wnck_tasklist_layout (&fake_allocation,
-			    tasklist->priv->max_button_width,
-			    tasklist->priv->max_button_height,
-			    n_startup_sequences + n_windows - n_grouped_buttons,
-			    &n_cols, &n_rows);
-      if (n_cols != last_n_cols &&
-	  (tasklist->priv->grouping == WNCK_TASKLIST_AUTO_GROUP ||
-	   ungrouped_class_groups == NULL))
-	{
-	  val = n_cols * tasklist->priv->max_button_width;
-	  if (val >= lowest_range)
-	    { /* Overlaps old range */
-              g_assert (array->len > 0);
-	      lowest_range = n_cols * grouping_limit;
-              g_array_index(array, int, array->len-1) = lowest_range;
-	    }
-	  else
-	    {
-	      /* Full new range */
-	      g_array_insert_val (array, array->len, val);
-	      val = n_cols * grouping_limit;
-	      g_array_insert_val (array, array->len, val);
-	      lowest_range = val;
-	    }
-
-	  last_n_cols = n_cols;
-	}
-    }
-
-  g_list_free (ungrouped_class_groups);
-
+  if (fake_allocation.height > fake_allocation.width){
+    g_message("layout: %d %d\n", n_rows * tasklist->priv->max_button_height, val);
+  }
+  
   /* Always let you go down to a zero size: */
   if (array->len > 0)
     g_array_index(array, int, array->len-1) = 0;
@@ -1434,8 +1435,21 @@
     
   tasklist->priv->size_hints = (int *)g_array_free (array, FALSE);
 
-  requisition->width = tasklist->priv->size_hints[0];
-  requisition->height = fake_allocation.height;
+  if (fake_allocation.height < fake_allocation.width) {  
+    requisition->width = fake_allocation.width;
+    requisition->height = fake_allocation.height;
+  } else {
+    requisition->width = fake_allocation.width;
+    requisition->height = fake_allocation.height;
+/*    tasklist->priv->size_hints[0];*/
+
+    g_message("req: %d %d    \n", requisition->height, requisition->width);
+    if (fake_allocation.height > fake_allocation.width)
+      g_message("hint: %d\n", tasklist->priv->size_hints[0]);
+    
+  }  
+  
+
 }
 
 /**
@@ -1511,6 +1525,9 @@
   GList *visible_tasks = NULL;
   GList *windows_sorted = NULL;
   int grouping_limit;
+
+  g_message("test %d \n", allocation->height);
+  
   
   tasklist = WNCK_TASKLIST (widget);
 
@@ -1529,56 +1546,7 @@
 				       tasklist->priv->max_button_height,
 				       n_startup_sequences + n_windows,
 				       &n_cols, &n_rows);
-  while (ungrouped_class_groups != NULL &&
-	 ((tasklist->priv->grouping == WNCK_TASKLIST_ALWAYS_GROUP) ||
-	  ((tasklist->priv->grouping == WNCK_TASKLIST_AUTO_GROUP) &&
-	   (button_width < grouping_limit))))
-    {
-      if (!score_set)
-	{
-	  wnck_tasklist_score_groups (tasklist, ungrouped_class_groups);
-	  score_set = TRUE;
-	}
-
-      ungrouped_class_groups = wnck_task_get_highest_scored (ungrouped_class_groups, &class_group_task);
-
-      n_grouped_buttons += g_list_length (class_group_task->windows) - 1;
-
-      if (g_list_length (class_group_task->windows) > 1)
-	{
-	  visible_tasks = g_list_prepend (visible_tasks, class_group_task);
-
-          /* Sort */
-          class_group_task->windows = g_list_sort (class_group_task->windows,
-                                                   wnck_task_compare_alphabetically);
-	  
-	  /* Hide all this group's windows */
-	  l = class_group_task->windows;
-	  while (l != NULL)
-	    {
-	      win_task = WNCK_TASK (l->data);
-	      
-	      gtk_widget_set_child_visible (GTK_WIDGET (win_task->button), FALSE);
-
-              cleanup_screenshots (win_task);
-              
-	      l = l->next;
-	    }
-	}
-      else
-	{
-	  visible_tasks = g_list_prepend (visible_tasks, class_group_task->windows->data);
-	  gtk_widget_set_child_visible (GTK_WIDGET (class_group_task->button), FALSE);
-
-          cleanup_screenshots (class_group_task);
-        }
-      
-      button_width = wnck_tasklist_layout (allocation,
-					   tasklist->priv->max_button_width,
-					   tasklist->priv->max_button_height,
-					   n_startup_sequences + n_windows - n_grouped_buttons,
-					   &n_cols, &n_rows);
-    }
+  
 
   /* Add all ungrouped windows to visible_tasks, and hide their class groups */
   l = ungrouped_class_groups;
@@ -1625,19 +1593,23 @@
   while (l != NULL)
     {
       WnckTask *task = WNCK_TASK (l->data);
-      int row = i % n_rows;
-      int col = i / n_rows;
+      int row, col;
+      if (allocation->width > allocation->height) {
+return i/0;       
+      } else {
+        row = i;      
+        col = 0;
+        child_allocation.x = 0;
+        child_allocation.y = MIN(i * 20, allocation->height / n_rows * i);
+        child_allocation.width = allocation->width;
+        child_allocation.height = MIN(20, allocation->height / n_rows);
+        child_allocation.x += allocation->x;
+        child_allocation.y += allocation->y;
+      }
       
       if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
         col = n_cols - col - 1;
 
-      child_allocation.x = total_width*col / n_cols;
-      child_allocation.y = allocation->height*row / n_rows;
-      child_allocation.width = total_width*(col + 1) / n_cols - child_allocation.x;
-      child_allocation.height = allocation->height*(row + 1) / n_rows - child_allocation.y;
-      child_allocation.x += allocation->x;
-      child_allocation.y += allocation->y;
-
       gtk_widget_size_allocate (task->button, &child_allocation);
       gtk_widget_set_child_visible (GTK_WIDGET (task->button), TRUE);
 