diff -upr libwnck/libwnck/tasklist.c libwnck.new/libwnck/tasklist.c
--- libwnck/libwnck/tasklist.c	2005-07-24 05:09:36.000000000 +0400
+++ libwnck.new/libwnck/tasklist.c	2005-08-15 18:19:59.000000000 +0400
@@ -2769,6 +2769,7 @@ wnck_task_drag_leave (GtkWidget         
       g_source_remove (task->button_activate);
       task->button_activate = 0;
     }
+  gtk_drag_unhighlight (widget);
 }
 
 static gboolean
@@ -2779,16 +2780,81 @@ wnck_task_drag_motion (GtkWidget        
 		       guint               time,
 		       WnckTask            *task)
 {
-  task->dnd_timestamp = time;
-  if (task->button_activate == 0 && task->type == WNCK_TASK_WINDOW)
-      task->button_activate = g_timeout_add (WNCK_ACTIVATE_TIMEOUT,
-                                             wnck_task_motion_timeout,
-                                             task);
-  gdk_drag_status (context,0,time);
 
+  if (gtk_drag_dest_find_target (widget, context, NULL))
+    {
+      gtk_drag_highlight (widget);
+      gdk_drag_status (context, context->suggested_action, time);
+    }
+  else
+    {
+      task->dnd_timestamp = time;
+
+      if (task->button_activate == 0 && task->type == WNCK_TASK_WINDOW)
+          task->button_activate = g_timeout_add (WNCK_ACTIVATE_TIMEOUT,
+                                                 wnck_task_motion_timeout,
+                                                 task);
+      gdk_drag_status (context, 0, time);
+    }
+    
   return TRUE;
 }
 
+void  
+wnck_task_drag_data_get  (GtkWidget          *widget,
+		       GdkDragContext     *context,
+		       GtkSelectionData   *selection_data,
+		       guint               info,
+		       guint               time,
+		       WnckTask           *task)
+{
+  gulong xid;    
+
+  xid = wnck_window_get_xid (task->window);
+  gtk_selection_data_set (selection_data,
+ 		          selection_data->target,
+			  8, (gchar *)&xid, sizeof (gulong));
+}
+
+void  
+wnck_task_drag_data_received (GtkWidget          *widget,
+			    GdkDragContext     *context,
+			    gint                x,
+			    gint                y,
+			    GtkSelectionData   *data,
+			    guint               info,
+			    guint               time,
+			    WnckTask           *task)
+{
+    WnckTasklist *tasklist = task->tasklist;
+
+    if ((data->length == sizeof (gulong)) && (data->format == 8))
+     {
+       GList *l;
+	WnckTask *drag_task;
+	gulong *xid = (gulong *)data->data;
+	guint old_order, new_order;
+	
+	for (l = tasklist->priv->windows; l; l = l->next)
+	  {
+	    drag_task = WNCK_TASK (l->data);
+	    if (wnck_window_get_xid (drag_task->window) == *xid) 
+	      {
+	        new_order = wnck_window_get_sort_order (task->window);
+	        old_order = wnck_window_get_sort_order (drag_task->window);
+	          
+		wnck_window_set_sort_order (task->window, old_order);
+	        wnck_window_set_sort_order (drag_task->window, new_order);
+		  
+	        gtk_widget_queue_resize (GTK_WIDGET (tasklist));
+	      }
+	  }	
+          gtk_drag_finish (context, TRUE, FALSE, time);
+	  return;
+     }    
+  gtk_drag_finish (context, FALSE, FALSE, time);
+}
+
 static gboolean
 wnck_task_button_press_event (GtkWidget	      *widget,
 			      GdkEventButton  *event,
@@ -2866,6 +2932,10 @@ wnck_task_create_widgets (WnckTask *task
   GdkPixbuf *pixbuf;
   char *text;
   static GQuark disable_sound_quark = 0;
+
+  static const GtkTargetEntry targets[] = {
+    { "application/x-window-id", GTK_TARGET_SAME_APP, 0}
+  };
   
   if (!disable_sound_quark)
     disable_sound_quark = g_quark_from_static_string ("gnome_disable_sound_events");
@@ -2885,9 +2955,18 @@ wnck_task_create_widgets (WnckTask *task
   
   gtk_widget_set_name (task->button,
 		       "tasklist-button");
-
-  gtk_drag_dest_set (GTK_WIDGET(task->button), 0, NULL, 0, 0);
-
+  
+  if (task->type == WNCK_TASK_WINDOW)
+    {
+      gtk_drag_source_set (GTK_WIDGET (task->button),
+		           GDK_BUTTON1_MASK,
+		           targets, 1,
+		           GDK_ACTION_MOVE);
+      gtk_drag_dest_set (GTK_WIDGET(task->button), GTK_DEST_DEFAULT_DROP, targets, 1, GDK_ACTION_MOVE);
+    }
+  else  
+      gtk_drag_dest_set (GTK_WIDGET(task->button), 0, NULL, 0, GDK_ACTION_DEFAULT);
+ 
   hbox = gtk_hbox_new (FALSE, 0);
 
   pixbuf = wnck_task_get_icon (task);
@@ -2945,6 +3024,20 @@ wnck_task_create_widgets (WnckTask *task
                            G_OBJECT (task),
                            0); 
 
+  if (task->type == WNCK_TASK_WINDOW) 
+    {
+      g_signal_connect_object (G_OBJECT(task->button), "drag_data_get",
+                               G_CALLBACK (wnck_task_drag_data_get),
+                               G_OBJECT (task),
+                               0); 
+
+      g_signal_connect_object (G_OBJECT(task->button), "drag_data_received",
+                               G_CALLBACK (wnck_task_drag_data_received),
+                               G_OBJECT (task),
+                               0); 
+
+    }
+
   g_signal_connect_object (G_OBJECT(task->button), "drag_leave",
                            G_CALLBACK (wnck_task_drag_leave),
                            G_OBJECT (task),
diff -upr libwnck/libwnck/window.c libwnck.new/libwnck/window.c
--- libwnck/libwnck/window.c	2005-07-19 14:18:04.000000000 +0400
+++ libwnck.new/libwnck/window.c	2005-08-15 18:15:02.000000000 +0400
@@ -579,7 +579,7 @@ wnck_window_get_pid (WnckWindow *window)
  * @window: a #WnckWindow
  *
  * Gets the sort order of @window; used for ordering of the window in
- * the tasklist.  This is defined when the window is created.
+ * the tasklist. 
  *
  * Return value: sort order of @window, or G_MAXINT if none available
  **/
@@ -592,6 +592,24 @@ wnck_window_get_sort_order (WnckWindow *
 }
 
 /**
+ * wnck_window_set_sort_order:
+ * @window: a #WnckWindow
+ * @order: new order
+ *
+ * Sets the sort order of @window; used for ordering of the window in
+ * the tasklist. 
+ *
+ **/
+void        wnck_window_set_sort_order        (WnckWindow *window, 
+					       gint order)
+{ 
+  g_return_if_fail (WNCK_IS_WINDOW (window));
+  
+  window->priv->sort_order = order;
+  return;
+}
+
+/**
  * wnck_window_get_window_type:
  * @window: a #WnckWindow
  * 
diff -upr libwnck/libwnck/window.h libwnck.new/libwnck/window.h
--- libwnck/libwnck/window.h	2005-07-19 14:18:04.000000000 +0400
+++ libwnck.new/libwnck/window.h	2005-08-15 18:15:02.000000000 +0400
@@ -147,6 +147,8 @@ const char* wnck_window_get_session_id  
 const char* wnck_window_get_session_id_utf8   (WnckWindow *window);
 int         wnck_window_get_pid               (WnckWindow *window);
 gint        wnck_window_get_sort_order        (WnckWindow *window);
+void        wnck_window_set_sort_order        (WnckWindow *window, 
+					       gint order);
 
 WnckWindowType wnck_window_get_window_type    (WnckWindow *window);
 void           wnck_window_set_window_type    (WnckWindow *window,
