? gtk-new.patch
Index: gdk/x11/gdkdisplay-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkdisplay-x11.c,v
retrieving revision 1.41.2.1
diff -p -u -r1.41.2.1 gdkdisplay-x11.c
--- gdk/x11/gdkdisplay-x11.c	10 May 2004 20:49:35 -0000	1.41.2.1
+++ gdk/x11/gdkdisplay-x11.c	27 Aug 2004 03:31:38 -0000
@@ -221,6 +221,10 @@ gdk_display_open (const gchar *display_n
 
   /* We don't yet know a valid time. */
   display_x11->user_time = 0;
+
+  /* Initialize startup notification information */
+  display_x11->startup_notification_id = NULL;
+  display_x11->startup_notification_timestamp = NULL;
   
 #ifdef HAVE_XKB
   {
@@ -704,6 +708,7 @@ gdk_display_x11_finalize (GObject *objec
     g_object_unref (display_x11->screens[i]);
   g_free (display_x11->screens);
   g_free (display_x11->startup_notification_id);
+  g_free (display_x11->startup_notification_timestamp);
   
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -779,6 +784,7 @@ _gdk_windowing_set_default_display (GdkD
 {
   GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
   const gchar *startup_id;
+  const gchar *startup_timestamp_str;
   
   if (display)
     gdk_display = GDK_DISPLAY_XDISPLAY (display);
@@ -796,11 +802,6 @@ _gdk_windowing_set_default_display (GdkD
       else
 	display_x11->startup_notification_id = g_strdup (startup_id);
       
-      /* Clear the environment variable so it won't be inherited by
-       * child processes and confuse things.  
-       */
-      g_unsetenv ("DESKTOP_STARTUP_ID");
-
       /* Set the startup id on the leader window so it
        * applies to all windows we create on this display
        */
@@ -811,6 +812,34 @@ _gdk_windowing_set_default_display (GdkD
 		       PropModeReplace,
 		       startup_id, strlen (startup_id));
     }
+  /* Clear the environment variable so it won't be inherited by
+   * child processes and confuse things.  
+   */
+  g_unsetenv ("DESKTOP_STARTUP_ID");
+
+  g_free (display_x11->startup_notification_timestamp);
+  display_x11->startup_notification_timestamp = NULL;
+  
+  startup_timestamp_str = g_getenv ("DESKTOP_STARTUP_TIMESTAMP");
+  if (startup_timestamp_str && *startup_timestamp_str != '\0')
+    {
+      gulong timestamp;
+      char *end_char;
+
+      timestamp = strtoul (startup_timestamp_str, &end_char, 10);
+      if (*end_char != '\0')
+	g_warning ("DESKTOP_STARTUP_TIMESTAMP contains invalid characters");
+      else
+	{
+	  display_x11->startup_notification_timestamp = g_new (gulong, 1);
+	  *display_x11->startup_notification_timestamp = timestamp;
+	}
+    }
+
+  /* Clear the environment variable so it won't be inherited by
+   * child processes and confuse things.  
+   */
+  g_unsetenv ("DESKTOP_STARTUP_TIMESTAMP");
 }
 
 static char*
@@ -968,4 +997,37 @@ gdk_notify_startup_complete (void)
                       message);
 
   g_free (message);
+}
+
+/**
+ * gdk_x11_display_get_startup_timestamp:
+ * 
+ * Obtains the timestamp with which the application was started via
+ * startup notification.
+ * 
+ * Only apps that need the timestamp they were started with will
+ * need to call this function.  For example, apps that detect if
+ * another instance is already running and try to tell that instance
+ * to open a new window will need to forward to that instance the
+ * startup timestamp it was started with so that instance can set
+ * the _NET_WM_USER_TIME of the new window appropriately.
+ *
+ * Since: 2.6
+ **/
+Time*
+gdk_x11_display_get_startup_timestamp (void)
+{
+  GdkDisplay *display;
+  GdkDisplayX11 *display_x11;
+
+  display = gdk_display_get_default ();
+  if (!display)
+    return NULL;
+  
+  display_x11 = GDK_DISPLAY_X11 (display);
+
+  if (display_x11->startup_notification_timestamp == NULL)
+    return NULL;
+
+  return display_x11->startup_notification_timestamp;
 }
Index: gdk/x11/gdkdisplay-x11.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkdisplay-x11.h,v
retrieving revision 1.16
diff -p -u -r1.16 gdkdisplay-x11.h
--- gdk/x11/gdkdisplay-x11.h	18 Apr 2004 14:33:07 -0000	1.16
+++ gdk/x11/gdkdisplay-x11.h	27 Aug 2004 03:31:38 -0000
@@ -136,7 +136,8 @@ struct _GdkDisplayX11
   gint   input_gxid_port;
 
   /* Startup notification */
-  gchar *startup_notification_id;
+  gchar  *startup_notification_id;
+  gulong *startup_notification_timestamp;
 
   /* Time of most recent user interaction. */
   gulong user_time;
@@ -152,9 +153,10 @@ struct _GdkDisplayX11Class
   GdkDisplayClass parent_class;
 };
 
-GType      _gdk_display_x11_get_type            (void);
-GdkScreen *_gdk_x11_display_screen_for_xrootwin (GdkDisplay *display,
-						 Window      xrootwin);
+GType      _gdk_display_x11_get_type             (void);
+GdkScreen *_gdk_x11_display_screen_for_xrootwin  (GdkDisplay *display,
+						  Window      xrootwin);
+Time      *gdk_x11_display_get_startup_timestamp ();
 
 G_END_DECLS
 
