Index: libgnome-desktop/gnome-desktop-item.c
===================================================================
RCS file: /cvs/gnome/gnome-desktop/libgnome-desktop/gnome-desktop-item.c,v
retrieving revision 1.140
diff -p -u -r1.140 gnome-desktop-item.c
--- libgnome-desktop/gnome-desktop-item.c	24 Dec 2004 08:29:44 -0000	1.140
+++ libgnome-desktop/gnome-desktop-item.c	8 Jan 2005 21:55:49 -0000
@@ -63,6 +63,12 @@
 
 extern char **environ;
 
+struct _GnomeDesktopItemTimestampInfo {
+	guint32  stamp;
+	gboolean set;
+};
+typedef struct _GnomeDesktopItemTimestampInfo GnomeDesktopItemTimestampInfo;
+
 struct _GnomeDesktopItem {
 	int refcount;
 
@@ -87,6 +93,8 @@ struct _GnomeDesktopItem {
 	char *location;
 
 	time_t mtime;
+
+	GnomeDesktopItemTimestampInfo *time;
 };
 
 /* If mtime is set to this, set_location won't update mtime,
@@ -366,6 +374,9 @@ gnome_desktop_item_new (void)
 				       GNOME_DESKTOP_ITEM_VERSION,
 				       "1.0");
 
+	retval->time = g_new0 (GnomeDesktopItemTimestampInfo, 1);
+	retval->time->set = FALSE;
+
 	return retval;
 }
 
@@ -418,6 +429,8 @@ gnome_desktop_item_copy (const GnomeDesk
 	retval->modified = item->modified;
 	retval->location = g_strdup (item->location);
 	retval->mtime = item->mtime;
+	retval->time->set = item->time->set;
+	retval->time->stamp = item->time->stamp;
 
 	/* Languages */
 	retval->languages = g_list_copy (item->languages);
@@ -823,6 +836,9 @@ gnome_desktop_item_unref (GnomeDesktopIt
 	g_free (item->location);
 	item->location = NULL;
 
+	g_free (item->time);
+	item->time = NULL;
+
 	g_free (item);
 }
 
@@ -1801,10 +1817,18 @@ ditem_execute (const GnomeDesktopItem *i
 			sn_launcher_context_set_binary_name (sn_context,
 							     real_argv[0]);
 			
+			if (!item->time->set) {
+				g_warning ("Application error: gnome_desktop_item_set_launch_time() should have been called.  Falling back to gtk_get_current_event_time()\n");
+				item->time->stamp = gtk_get_current_event_time ();
+			}
+
 			sn_launcher_context_initiate (sn_context,
 						      g_get_prgname () ? g_get_prgname () : "unknown",
 						      real_argv[0],
-						      gtk_get_current_event_time ());
+						      item->time->stamp);
+
+			/* Don't allow accidental reuse of same timestamp */
+			item->time->set = FALSE;
 
 			envp = make_spawn_environment_for_sn_context (sn_context, envp);
 			if (free_me)
@@ -2977,8 +3001,21 @@ gnome_desktop_item_set_boolean (GnomeDes
 	set (item, attr, value ? "true" : "false");
 }
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+void
+gnome_desktop_item_set_launch_time (GnomeDesktopItem *item,
+				    guint32           timestamp)
+{
+	if (timestamp == GDK_CURRENT_TIME)
+		g_warning ("Application requested to launch with timestamp of 0, meaning that the launched application should not be focused.  Although this may be correct, it is more frequently the case that the application has a bug.\n");
+
+	item->time->stamp = timestamp;
+	item->time->set = TRUE;
+}
+#endif
+
 /*
-* Clearing attributes
+ * Clearing attributes
  */
 void
 gnome_desktop_item_clear_section (GnomeDesktopItem *item,
Index: libgnome-desktop/libgnome/gnome-desktop-item.h
===================================================================
RCS file: /cvs/gnome/gnome-desktop/libgnome-desktop/libgnome/gnome-desktop-item.h,v
retrieving revision 1.49
diff -p -u -r1.49 gnome-desktop-item.h
--- libgnome-desktop/libgnome/gnome-desktop-item.h	28 Nov 2002 11:38:41 -0000	1.49
+++ libgnome-desktop/libgnome/gnome-desktop-item.h	8 Jan 2005 21:55:49 -0000
@@ -285,6 +285,14 @@ void                    gnome_desktop_it
 							      const char		 *attr,
 							      gboolean                    value);
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+/*
+ * Xserver time of user action that caused the application launch to start.
+ */
+void                    gnome_desktop_item_set_launch_time   (GnomeDesktopItem           *item,
+							      guint32                     timestamp);
+#endif
+
 /*
  * Clearing attributes
  */
