--- pager.c	2009-03-16 23:26:49.000000000 +0100
+++ /home/marcus/temp/svn/libwnck-2.26.0/libwnck/pager.c	2009-05-15 23:02:45.000000000 +0200
@@ -1518,6 +1519,18 @@
   GList *tmp;
   gint i;
   gulong xid;
+  int viewport_x;
+  int viewport_y;
+  int wx;
+  int wy;
+  int wh;
+  int ww;
+  int win_viewport_x;
+  int win_viewport_y;
+  int delta_x;
+  int delta_y;
+  int screen_width;
+  int screen_height;
 
   if ((selection_data->length != sizeof (gulong)) ||
       (selection_data->format != 8))
@@ -1526,7 +1539,7 @@
       return;
     }
   
-  i = workspace_at_point (pager, x, y, NULL, NULL);
+  i = workspace_at_point (pager, x, y, &viewport_x, &viewport_y);
   space = wnck_screen_get_workspace (pager->priv->screen, i);
   if (!space)
     {
@@ -1535,20 +1548,52 @@
     }
   
   xid = *((gulong *)selection_data->data);
-	      
+  
   for (tmp = wnck_screen_get_windows_stacked (pager->priv->screen); tmp != NULL; tmp = tmp->next)
     {
       if (wnck_window_get_xid (tmp->data) == xid)
 	{
 	  WnckWindow *win = tmp->data;
-	  wnck_window_move_to_workspace (win, space);
-	  if (space == wnck_screen_get_active_workspace (pager->priv->screen))
-	    wnck_window_activate (win, time);
+          WnckWorkspace *win_space = wnck_window_get_workspace(win);
+          WnckWorkspace *active_space = wnck_screen_get_active_workspace (pager->priv->screen);
+          //First move window to correct workspace	  
+          wnck_window_move_to_workspace (win, space);
+
+          if (space == win_space) 
+            {
+              //Second, move to right viewport (compiz)
+              screen_width  = wnck_screen_get_width  (pager->priv->screen);
+              screen_height = wnck_screen_get_height (pager->priv->screen);
+
+              wnck_window_get_geometry(win, &wx, &wy, &ww, &wh);
+
+              workspace_at_point(pager, pager->priv->drag_start_x, pager->priv->drag_start_y, &win_viewport_x, &win_viewport_y);
+
+              viewport_x = (viewport_x / screen_width)  * screen_width;
+              viewport_y = (viewport_y / screen_height) * screen_height;
+
+              win_viewport_x = (win_viewport_x / screen_width)  * screen_width;
+              win_viewport_y = (win_viewport_y / screen_height) * screen_height;
+
+              delta_x = viewport_x - win_viewport_x;
+              delta_y = viewport_y - win_viewport_y;
+
+              wnck_window_set_geometry(win, 0, WNCK_WINDOW_CHANGE_X | WNCK_WINDOW_CHANGE_Y, wx + delta_x, wy + delta_y, ww, wh);
+
+              //Third, if window is moved to the current viewport - activate it
+              if (wnck_workspace_get_viewport_x(active_space) == viewport_x && wnck_workspace_get_viewport_y(active_space) == viewport_y)
+                wnck_window_activate (win, time);
+          }
+            else 
+          {
+            if (space == wnck_screen_get_active_workspace (pager->priv->screen))
+              wnck_window_activate (win, time);
+
+          }
 	  gtk_drag_finish (context, TRUE, FALSE, time);
 	  return;
 	}
     }
-
   gtk_drag_finish (context, FALSE, FALSE, time);
 }			       
 
