Index: libsn/sn-launcher.c
===================================================================
RCS file: /cvs/startup-notification/startup-notification/libsn/sn-launcher.c,v
retrieving revision 1.8
diff -u -r1.8 sn-launcher.c
--- libsn/sn-launcher.c	1 Dec 2002 02:49:20 -0000	1.8
+++ libsn/sn-launcher.c	23 Jan 2004 18:06:20 -0000
@@ -41,12 +41,14 @@
   char               *name;
   char               *description;
   int                 workspace;
+  Time                timestamp;
   char               *wmclass;
   char               *binary_name;
   char               *icon_name;
   struct timeval      initiation_time;
   unsigned int        completed : 1;
   unsigned int        canceled : 1;
+  unsigned int        timestamp_set : 1;
 };
 
 /**
@@ -80,6 +82,8 @@
   sn_display_ref (context->display);
 
   context->workspace = -1;
+  context->timestamp = 0;
+  context->timestamp_set = FALSE;
   
   sn_list_prepend (context_list, context);
 
@@ -146,7 +150,6 @@
  * @context: an #SnLaunchContext
  * @launcher_name: name of the launcher app, suitable for debug output
  * @launchee_name: name of the launchee app, suitable for debug output
- * @timestamp: X timestamp of event causing the launch
  *
  * Initiates a startup sequence. All the properties of the launch (such
  * as type, geometry, description) should be set up prior to
@@ -155,8 +158,7 @@
 void
 sn_launcher_context_initiate (SnLauncherContext *context,
                               const char        *launcher_name,
-                              const char        *launchee_name,
-                              Time               timestamp)
+                              const char        *launchee_name)
 {
   static int sequence_number = 0;
   static sn_bool_t have_hostname = FALSE;
@@ -171,6 +173,7 @@
   char *values[MAX_PROPS];  
   char *message;
   char workspacebuf[257];
+  char timestampbuf[257];
   char screenbuf[257];
   
   if (context->startup_id != NULL)
@@ -196,8 +199,8 @@
     256; /* 256 is longer than a couple %d and some slashes */
   
   s = sn_malloc (len + 3);
-  snprintf (s, len, "%s/%s/%lu/%d-%d-%s",
-            canonicalized_launcher, canonicalized_launchee, (unsigned long) timestamp,
+  snprintf (s, len, "%s/%s/%d-%d-%s",
+            canonicalized_launcher, canonicalized_launchee,
             (int) getpid (), (int) sequence_number, hostbuf);
   ++sequence_number;
   
@@ -239,6 +242,14 @@
       ++i;
     }
 
+  if (context->timestamp_set)
+    {
+      names[i] = "TIMESTAMP";
+      sprintf (timestampbuf, "%lu", context->timestamp);
+      values[i] = timestampbuf;
+      ++i;
+    }
+
   if (context->wmclass != NULL)
     {
       names[i] = "WMCLASS";
@@ -396,6 +407,16 @@
 }
 
 void
+sn_launcher_context_set_timestamp (SnLauncherContext *context,
+                                   Time               timestamp)
+{
+  WARN_ALREADY_INITIATED (context);
+
+  context->timestamp = timestamp;
+  context->timestamp_set = TRUE;
+}
+
+void
 sn_launcher_context_set_wmclass (SnLauncherContext *context,
                                  const char        *klass)
 {
Index: libsn/sn-launcher.h
===================================================================
RCS file: /cvs/startup-notification/startup-notification/libsn/sn-launcher.h,v
retrieving revision 1.6
diff -u -r1.6 sn-launcher.h
--- libsn/sn-launcher.h	1 Dec 2002 02:49:20 -0000	1.6
+++ libsn/sn-launcher.h	23 Jan 2004 18:06:20 -0000
@@ -41,8 +41,8 @@
 
 void        sn_launcher_context_initiate          (SnLauncherContext *context,
                                                    const char        *launcher_name,
-                                                   const char        *launchee_name,
-                                                   Time               timestamp);
+                                                   const char        *launchee_name);
+
 void        sn_launcher_context_complete          (SnLauncherContext *context);
 const char* sn_launcher_context_get_startup_id    (SnLauncherContext *context);
 sn_bool_t   sn_launcher_context_get_initiated     (SnLauncherContext *context);
@@ -55,6 +55,8 @@
                                           const char        *description);
 void sn_launcher_context_set_workspace   (SnLauncherContext *context,
                                           int                workspace);
+void sn_launcher_context_set_timestamp   (SnLauncherContext *context,
+                                          Time               timestamp);
 void sn_launcher_context_set_wmclass     (SnLauncherContext *context,
                                           const char        *klass);
 void sn_launcher_context_set_binary_name (SnLauncherContext *context,
Index: libsn/sn-monitor.c
===================================================================
RCS file: /cvs/startup-notification/startup-notification/libsn/sn-monitor.c,v
retrieving revision 1.8
diff -u -r1.8 sn-monitor.c
--- libsn/sn-monitor.c	1 Dec 2002 02:49:20 -0000	1.8
+++ libsn/sn-monitor.c	23 Jan 2004 18:06:20 -0000
@@ -25,6 +25,7 @@
 #include "sn-internals.h"
 #include "sn-xmessages.h"
 #include <sys/time.h>
+#include <assert.h>
 
 struct SnMonitorContext
 {
@@ -63,12 +64,14 @@
   char *wmclass;
 
   int workspace;
+  Time timestamp;
 
   char *binary_name;
   char *icon_name;  
 
   unsigned int completed : 1;
   unsigned int canceled : 1;
+  unsigned int timestamp_set : 1;
   
   int creation_serial;
 
@@ -303,6 +306,19 @@
   return sequence->workspace;
 }
 
+Time
+sn_startup_sequence_get_timestamp (SnStartupSequence *sequence)
+{
+  assert (sn_startup_sequence_get_timestamp_set (sequence));
+  return sequence->timestamp;
+}
+
+int
+sn_startup_sequence_get_timestamp_set (SnStartupSequence *sequence)
+{
+  return sequence->timestamp_set;
+}
+
 const char*
 sn_startup_sequence_get_wmclass (SnStartupSequence *sequence)
 {
@@ -422,6 +438,8 @@
 
   sequence->screen = -1; /* not set */
   sequence->workspace = -1; /* not set */
+  sequence->timestamp = 0;
+  sequence->timestamp_set = FALSE;
 
   sequence->initiation_time.tv_sec = 0;
   sequence->initiation_time.tv_usec = 0;
@@ -783,6 +801,16 @@
               sequence->workspace = workspace;
               changed = TRUE;
             }
+          else if (strcmp (names[i], "TIMESTAMP") == 0)
+            {
+              Time timestamp;
+              
+              timestamp = sn_internal_string_to_ulong (values[i]);
+
+              sequence->timestamp = timestamp;
+              sequence->timestamp_set = TRUE;
+              changed = TRUE;
+            }
           else if (strcmp (names[i], "WMCLASS") == 0)
             {
               if (sequence->wmclass == NULL)
Index: libsn/sn-monitor.h
===================================================================
RCS file: /cvs/startup-notification/startup-notification/libsn/sn-monitor.h,v
retrieving revision 1.5
diff -u -r1.5 sn-monitor.h
--- libsn/sn-monitor.h	30 Nov 2002 05:05:22 -0000	1.5
+++ libsn/sn-monitor.h	23 Jan 2004 18:06:20 -0000
@@ -69,6 +69,8 @@
 const char* sn_startup_sequence_get_name                  (SnStartupSequence *sequence);
 const char* sn_startup_sequence_get_description           (SnStartupSequence *sequence);
 int         sn_startup_sequence_get_workspace             (SnStartupSequence *sequence);
+Time        sn_startup_sequence_get_timestamp             (SnStartupSequence *sequence);
+int         sn_startup_sequence_get_timestamp_set         (SnStartupSequence *sequence);
 const char* sn_startup_sequence_get_wmclass               (SnStartupSequence *sequence);
 const char* sn_startup_sequence_get_binary_name           (SnStartupSequence *sequence);
 const char* sn_startup_sequence_get_icon_name             (SnStartupSequence *sequence);
Index: test/test-launcher.c
===================================================================
RCS file: /cvs/startup-notification/startup-notification/test/test-launcher.c,v
retrieving revision 1.3
diff -u -r1.3 test-launcher.c
--- test/test-launcher.c	21 Oct 2002 02:47:15 -0000	1.3
+++ test/test-launcher.c	23 Jan 2004 18:06:20 -0000
@@ -24,11 +24,65 @@
 
 #include <config.h>
 #include <libsn/sn.h>
+#include <assert.h>
 
 #include "test-boilerplate.h"
 
 static pid_t child_pid = 0;
 
+Time
+obtain_xserver_timestamp (Display *xdisplay)
+{
+  /* This function may look a little gross because I just cobbled some
+   * stuff together between grepping through Metacity source code and
+   * some google searches for Xlib documentation.  It works for me,
+   * but I really don't understand enough of X to determine whether
+   * this is a good way to do this or not.
+   */
+
+  XSetWindowAttributes attrs;
+  XEvent event;
+
+  attrs.event_mask = PropertyChangeMask;
+  attrs.override_redirect = True;
+
+  /* Create a fake_window that is offscreen to send a message to. */
+  Window fake_window;
+  XSetWindowAttributes fake_attrs;
+  fake_attrs.override_redirect = True;
+  fake_attrs.event_mask = PropertyChangeMask;
+  fake_window = XCreateWindow (xdisplay,
+                               DefaultRootWindow (xdisplay),
+                               -100, -100, 1, 1,
+                               0,
+                               CopyFromParent,
+                               CopyFromParent,
+                               CopyFromParent,
+                               CWOverrideRedirect | CWEventMask,
+                               &fake_attrs);
+
+
+  Atom atom_name = XInternAtom(xdisplay, "WM_NAME", TRUE);
+  assert(atom_name != None);
+  Atom atom_type = XInternAtom(xdisplay, "STRING", TRUE);
+  assert(atom_type != None);
+
+  char *name = "Fake Window";
+  XChangeProperty (xdisplay, 
+                   fake_window, atom_name,
+                   atom_type,
+                   8, PropModeReplace, name, strlen (name));
+  
+  XWindowEvent (xdisplay,
+                fake_window,
+                PropertyChangeMask,
+                &event);
+
+  XDestroyWindow(xdisplay, fake_window);
+
+  return event.xproperty.time;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -63,11 +117,12 @@
   sn_launcher_context_set_name (context, "Test Launch");
   sn_launcher_context_set_description (context, "Launching a test program for libsn");
   sn_launcher_context_set_binary_name (context, argv[1]);
-  
+
+  Time timestamp = obtain_xserver_timestamp (xdisplay);
+  sn_launcher_context_set_timestamp(context, timestamp);
   sn_launcher_context_initiate (context,
                                 "test-launcher",
-                                argv[1],
-                                CurrentTime); /* CurrentTime bad */
+                                argv[1]);
 
   switch ((child_pid = fork ()))
     {
