Index: src/terminal-window.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-window.c,v
retrieving revision 1.105
diff -p -u -r1.105 terminal-window.c
--- src/terminal-window.c	23 Nov 2004 05:36:26 -0000	1.105
+++ src/terminal-window.c	28 Feb 2005 19:58:07 -0000
@@ -1175,8 +1175,14 @@ terminal_window_show (GtkWidget *widget)
       context = sn_launchee_context_new (sn_display,
                                          gdk_screen_get_number (screen),
                                          window->priv->startup_id);
-      sn_launchee_context_setup_window (context,
-                                        GDK_WINDOW_XWINDOW (widget->window));
+
+      /* Handle the setup for the window if the startup_id is valid; I
+       * don't think it can hurt to do this even if it was invalid,
+       * but why do the extra work...
+       */
+      if (strncmp (sn_launchee_context_get_startup_id (context), "_TIME", 5) != 0)
+        sn_launchee_context_setup_window (context,
+                                          GDK_WINDOW_XWINDOW (widget->window));
 
       /* Now, set the _NET_WM_USER_TIME for the new window to the timestamp
        * that caused the window to be launched.
@@ -1187,12 +1193,6 @@ terminal_window_show (GtkWidget *widget)
 
           timestamp = sn_launchee_context_get_timestamp (context);
           gdk_x11_window_set_user_time (widget->window, timestamp);
-        }
-      else
-        {
-          g_warning ("Launched by a non-compliant or obsolete startup "
-                     "notification launcher.  Focus-stealing-prevention "
-                     "may fail.\n");
         }
     }
   
Index: src/terminal.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal.c,v
retrieving revision 1.80
diff -p -u -r1.80 terminal.c
--- src/terminal.c	29 Nov 2004 09:40:19 -0000	1.80
+++ src/terminal.c	28 Feb 2005 19:58:07 -0000
@@ -1511,6 +1511,57 @@ insert_args (int        *argc,
   argv[*argc] = NULL;
 }
 
+/* Copied from libnautilus/nautilus-program-choosing.c; Needed in case
+ * we have no DESKTOP_STARTUP_ID (with its accompanying timestamp).
+ */
+static Time
+slowly_and_stupidly_obtain_timestamp (Display *xdisplay)
+{
+	Window xwindow;
+	XEvent event;
+	
+	{
+		XSetWindowAttributes attrs;
+		Atom atom_name;
+		Atom atom_type;
+		char* name;
+		
+		attrs.override_redirect = True;
+		attrs.event_mask = PropertyChangeMask | StructureNotifyMask;
+		
+		xwindow =
+			XCreateWindow (xdisplay,
+				       RootWindow (xdisplay, 0),
+				       -100, -100, 1, 1,
+				       0,
+				       CopyFromParent,
+				       CopyFromParent,
+				       CopyFromParent,
+				       CWOverrideRedirect | CWEventMask,
+				       &attrs);
+		
+		atom_name = XInternAtom (xdisplay, "WM_NAME", TRUE);
+		g_assert (atom_name != None);
+		atom_type = XInternAtom (xdisplay, "STRING", TRUE);
+		g_assert (atom_type != None);
+		
+		name = "Fake Window";
+		XChangeProperty (xdisplay, 
+				 xwindow, atom_name,
+				 atom_type,
+				 8, PropModeReplace, name, strlen (name));
+	}
+	
+	XWindowEvent (xdisplay,
+		      xwindow,
+		      PropertyChangeMask,
+		      &event);
+	
+	XDestroyWindow(xdisplay, xwindow);
+	
+	return event.xproperty.time;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -1572,6 +1623,16 @@ main (int argc, char **argv)
                                                      */
   
   gtk_init (&argc, &argv);
+
+  /* Do this here so that gdk_display is initialized */
+  if (results->startup_id == NULL)
+    {
+      /* Create a fake one containing a timestamp that we can use */
+      Time timestamp;
+      timestamp = slowly_and_stupidly_obtain_timestamp (gdk_display);
+      results->startup_id = g_strdup_printf ("_TIME%lu",
+                                             timestamp);
+    }
 
   display = gdk_display_get_default ();
   display_name = gdk_display_get_name (display);
