Index: libwnck/tasklist.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/tasklist.c,v
retrieving revision 1.69
diff -p -u -r1.69 tasklist.c
--- libwnck/tasklist.c	11 Jan 2005 19:58:23 -0000	1.69
+++ libwnck/tasklist.c	14 Jan 2005 05:38:19 -0000
@@ -1154,8 +1154,8 @@ wnck_tasklist_size_allocate (GtkWidget  
   while (l != NULL)
     {
       WnckTask *task = WNCK_TASK (l->data);
-      int col = i % n_cols;
-      int row = i / n_cols;
+      int row = i % n_rows;
+      int col = i / n_rows;
       
       child_allocation.x = total_width*col / n_cols;
       child_allocation.y = allocation->height*row / n_rows;
@@ -2682,10 +2682,18 @@ wnck_task_compare (gconstpointer  a,
 {
   WnckTask *task1 = WNCK_TASK (a);
   WnckTask *task2 = WNCK_TASK (b);
-  gulong xid1_1, xid1_2;
-  gulong xid2_1, xid2_2;
-  
-  xid1_1 = xid1_2 = xid2_1 = xid2_2 = 0;   /* silence compiler */
+  GList *window_list;
+  gint pos1, pos2;
+
+  pos1 = pos2 = 0;  /* silence the compiler */
+
+  window_list = NULL;
+  /* Only need the window_list if both task1 and task2 are WNCK_TASK_WINDOWs;
+   * and we can only get it if at least one of them is...
+   */
+  if (task1->type == WNCK_TASK_WINDOW)
+    window_list = 
+      wnck_screen_get_windows (wnck_window_get_screen (task1->window));
   
   switch (task1->type)
     {
@@ -2696,11 +2704,11 @@ wnck_task_compare (gconstpointer  a,
 	return -1; /* Sort groups before everything else */
 
     case WNCK_TASK_WINDOW:
-      xid1_1 = wnck_window_get_group_leader (task1->window);
-      xid1_2 = wnck_window_get_xid (task1->window);
+      pos1 = g_list_position (window_list, 
+                              g_list_find (window_list, task1->window));
       break;
     case WNCK_TASK_STARTUP_SEQUENCE:
-      xid1_1 = xid1_2 = G_MAXULONG;
+      pos1 = G_MAXINT;
       break;
     }
 
@@ -2713,17 +2721,17 @@ wnck_task_compare (gconstpointer  a,
 	return 1; /* Sort groups before everything else */
 
     case WNCK_TASK_WINDOW:
-      xid2_1 = wnck_window_get_group_leader (task2->window);
-      xid2_2 = wnck_window_get_xid (task2->window);
+      pos2 = g_list_position (window_list, 
+                              g_list_find (window_list, task2->window));
       break;
     case WNCK_TASK_STARTUP_SEQUENCE:
-      xid2_1 = xid2_2 = G_MAXULONG;
+      pos2 = G_MAXINT;
       break;
     }
       
-  if ((xid1_1 < xid2_1) || ((xid1_1 == xid2_1) && (xid1_2 < xid2_2)))
+  if (pos1 < pos2)
     return -1;
-  else if ((xid1_1 == xid2_1) && (xid1_2 == xid2_2))
+  else if (pos1 == pos2)
     return 0;
   else
     return 1;
