Index: gdk/x11/gdkwindow-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkwindow-x11.c,v
retrieving revision 1.244
diff -p -u -r1.244 gdkwindow-x11.c
--- gdk/x11/gdkwindow-x11.c	17 Jun 2005 20:19:30 -0000	1.244
+++ gdk/x11/gdkwindow-x11.c	9 Jul 2005 22:44:21 -0000
@@ -2043,6 +2043,59 @@ gdk_window_focus (GdkWindow *window,
 
   display = GDK_WINDOW_DISPLAY (window);
 
+  /* First, we move the window to the correct workspace; we do this because
+   * the intent of the EWMH is that the window manager will NOT do this
+   * for a _NET_ACTIVE_WINDOW message.  See bug 128380.
+   */
+  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 = 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);
+        }
+    }
+
   if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
 					   gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE)))
     {
Index: gtk/gtkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwindow.c,v
retrieving revision 1.295
diff -p -u -r1.295 gtkwindow.c
--- gtk/gtkwindow.c	5 Jul 2005 22:34:07 -0000	1.295
+++ gtk/gtkwindow.c	9 Jul 2005 22:44:23 -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);
 }
 
 /**
@@ -6047,6 +6037,19 @@ gtk_window_present_with_time (GtkWindow 
       g_assert (widget->window != NULL);
       
       gdk_window_show (widget->window);
+
+      /* 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
+        }
 
       /* note that gdk_window_focus() will also move the window to
        * the current desktop, for WM spec compliant window managers.
