Index: gdk/gdk.symbols
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdk.symbols,v
retrieving revision 1.23
diff -u -p -r1.23 gdk.symbols
--- gdk/gdk.symbols	5 Jul 2005 22:50:53 -0000	1.23
+++ gdk/gdk.symbols	10 Jul 2005 04:39:22 -0000
@@ -1181,6 +1181,7 @@ gdkx_visual_get
 
 #if IN_FILE(__GDK_WINDOW_X11_C__)
 gdk_x11_window_set_user_time
+gdk_x11_window_move_to_current_desktop
 #endif
 
 #if IN_FILE(__GDK_XID_C__)
Index: gdk/x11/gdkwindow-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkwindow-x11.c,v
retrieving revision 1.244
diff -u -p -r1.244 gdkwindow-x11.c
--- gdk/x11/gdkwindow-x11.c	17 Jun 2005 20:19:30 -0000	1.244
+++ gdk/x11/gdkwindow-x11.c	10 Jul 2005 04:39:23 -0000
@@ -2021,13 +2021,76 @@ gdk_window_lower (GdkWindow *window)
 }
 
 /**
+ * gdk_x11_window_move_to_current_desktop:
+ * @window: a #GdkWindow
+ * 
+ * Moves the window to the correct workspace when running under a 
+ * window manager that supports multiple workspaces.
+ * 
+ * Since: 2.8
+ */
+void
+gdk_x11_window_move_to_current_desktop (GdkWindow *window)
+{
+  if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
+					   gdk_atom_intern ("_NET_WM_DESKTOP", FALSE)))
+    {
+      XEvent xev;
+      Atom type;
+      gint format;
+      gulong nitems;
+      gulong bytes_after;
+      guchar *data;
+      gulong *current_desktop;
+      GdkDisplay *display;
+      
+      display = gdk_drawable_get_display (window);
+
+      /* Get current desktop, then set it; this is a race, but not
+       * one that matters much in practice.
+       */
+      XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), 
+                          GDK_WINDOW_XROOTWIN (window),
+			  gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"),
+                          0, G_MAXLONG,
+                          False, XA_CARDINAL, &type, &format, &nitems,
+                          &bytes_after, &data);
+
+      if (type == XA_CARDINAL)
+        {
+	  current_desktop = (gulong *)data;
+	  
+          xev.xclient.type = ClientMessage;
+          xev.xclient.serial = 0;
+          xev.xclient.send_event = True;
+          xev.xclient.window = GDK_WINDOW_XWINDOW (window);
+	  xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP");
+          xev.xclient.format = 32;
+
+          xev.xclient.data.l[0] = *current_desktop;
+          xev.xclient.data.l[1] = 0;
+          xev.xclient.data.l[2] = 0;
+          xev.xclient.data.l[3] = 0;
+          xev.xclient.data.l[4] = 0;
+      
+          XSendEvent (GDK_DISPLAY_XDISPLAY (display), 
+                      GDK_WINDOW_XROOTWIN (window), 
+                      False,
+                      SubstructureRedirectMask | SubstructureNotifyMask,
+                      &xev);
+
+          XFree (current_desktop);
+        }
+    }
+}
+
+/**
  * gdk_window_focus:
  * @window: a #GdkWindow
  * @timestamp: timestamp of the event triggering the window focus
  *
- * Sets keyboard focus to @window. If @window is not onscreen this
- * will not work. In most cases, gtk_window_present() should be used on
- * a #GtkWindow, rather than calling this function.
+ * Sets keyboard focus to @window. In most cases, gtk_window_present() 
+ * should be used on a #GtkWindow, rather than calling this function.
  * 
  **/
 void
Index: gdk/x11/gdkx.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkx.h,v
retrieving revision 1.42
diff -u -p -r1.42 gdkx.h
--- gdk/x11/gdkx.h	15 Jun 2005 18:37:17 -0000	1.42
+++ gdk/x11/gdkx.h	10 Jul 2005 04:39:23 -0000
@@ -55,6 +55,7 @@ Screen * gdk_x11_screen_get_xscreen     
 int      gdk_x11_screen_get_screen_number (GdkScreen   *screen);
 void     gdk_x11_window_set_user_time     (GdkWindow   *window,
 					   guint32      timestamp);
+void     gdk_x11_window_move_to_current_desktop (GdkWindow   *window);
 
 const char* gdk_x11_screen_get_window_manager_name (GdkScreen *screen);
 
@@ -154,7 +155,6 @@ gpointer      gdk_xid_table_lookup   (XI
 gboolean      gdk_net_wm_supports    (GdkAtom    property);
 void          gdk_x11_grab_server    (void);
 void          gdk_x11_ungrab_server  (void);
-
 #endif
 
 GdkDisplay   *gdk_x11_lookup_xdisplay (Display *xdisplay);
Index: gtk/gtkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwindow.c,v
retrieving revision 1.295
diff -u -p -r1.295 gtkwindow.c
--- gtk/gtkwindow.c	5 Jul 2005 22:34:07 -0000	1.295
+++ gtk/gtkwindow.c	10 Jul 2005 04:39:24 -0000
@@ -6007,17 +6007,7 @@ gtk_window_set_frame_dimensions (GtkWind
 void
 gtk_window_present (GtkWindow *window)
 {
-  guint32 timestamp;
-#ifdef GDK_WINDOWING_X11
-  GdkDisplay *display;
-
-  display = gtk_widget_get_display (GTK_WIDGET (window));
-  timestamp = gdk_x11_display_get_user_time (display);
-#else
-  timestamp = gtk_get_current_event_time ();
-#endif
-  
-  gtk_window_present_with_time (window, timestamp);
+  gtk_window_present_with_time (window, GDK_CURRENT_TIME);
 }
 
 /**
@@ -6048,9 +6038,22 @@ gtk_window_present_with_time (GtkWindow 
       
       gdk_window_show (widget->window);
 
-      /* note that gdk_window_focus() will also move the window to
-       * the current desktop, for WM spec compliant window managers.
-       */
+      /* Translate a timestamp of GDK_CURRENT_TIME appropriately */
+      if (timestamp == GDK_CURRENT_TIME)
+        {
+#ifdef GDK_WINDOWING_X11
+          GdkDisplay *display;
+
+          display = gtk_widget_get_display (GTK_WIDGET (window));
+          timestamp = gdk_x11_display_get_user_time (display);
+#else
+          timestamp = gtk_get_current_event_time ();
+#endif
+        }
+
+#ifdef GDK_WINDOWING_X11
+      gdk_x11_window_move_to_current_desktop (widget->window);
+#endif
       gdk_window_focus (widget->window, timestamp);
     }
   else
