? clamp-constrain.patch
? constraints-ideas.txt
? current.patch
? debug-focus.patch
? patches
? simple-example
? simple-example.c
? stamp-h1
? testit
? testit.c
Index: src/keybindings.c
===================================================================
RCS file: /cvs/gnome/metacity/src/keybindings.c,v
retrieving revision 1.110
diff -p -u -r1.110 keybindings.c
--- src/keybindings.c	22 Feb 2005 02:11:25 -0000	1.110
+++ src/keybindings.c	27 Feb 2005 06:08:51 -0000
@@ -35,11 +35,14 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #ifdef HAVE_XKB
 #include <X11/XKBlib.h>
 #endif
 
+extern char **environ;
+
 static gboolean all_bindings_disabled = FALSE;
 
 typedef void (* MetaKeyHandlerFunc) (MetaDisplay    *display,
@@ -2611,13 +2614,76 @@ set_display_setup_func (void *data)
   /* do not free full, because putenv is lame */
 } 
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+static void
+sn_error_trap_push (SnDisplay *sn_display,
+                    Display   *xdisplay)
+{
+  MetaDisplay *display;
+  display = meta_display_for_x_display (xdisplay);
+  if (display != NULL)
+    meta_error_trap_push (display);
+}
+
+static void
+sn_error_trap_pop (SnDisplay *sn_display,
+                   Display   *xdisplay)
+{
+  MetaDisplay *display;
+  display = meta_display_for_x_display (xdisplay);
+  if (display != NULL)
+    meta_error_trap_pop (display, FALSE);
+}
+
+static char **
+make_spawn_environment_for_sn_context (SnLauncherContext *sn_context)
+{
+  char **envp;
+  char **retval = NULL;
+  int    i, j;
+  int    desktop_startup_id_len;
+
+  envp = environ;
+  for (i = 0; envp[i]; i++)
+    ;
+
+  retval = g_new (char *, i + 2);
+
+  desktop_startup_id_len = strlen ("DESKTOP_STARTUP_ID");
+	
+  for (i = 0, j = 0; envp[i]; i++)
+    {
+      if (strncmp (envp[i], "DESKTOP_STARTUP_ID", desktop_startup_id_len) != 0)
+        {
+          retval[j] = g_strdup (envp[i]);
+          ++j;
+        }
+    }
+
+  retval[j] = g_strdup_printf ("DESKTOP_STARTUP_ID=%s",
+                               sn_launcher_context_get_startup_id (sn_context));
+  ++j;
+  retval[j] = NULL;
+
+  return retval;
+}
+#endif
+
 static gboolean
 meta_spawn_command_line_async_on_screen (const gchar *command_line,
                                          MetaScreen  *screen,
+                                         Time         launch_time,
                                          GError     **error)
 {
   gboolean retval;
   gchar **argv = NULL;
+  gchar **envp = NULL;
+  gchar *name, *description;
+  int ret;
+#ifdef HAVE_STARTUP_NOTIFICATION
+  SnLauncherContext *sn_context;
+  SnDisplay *sn_display;
+#endif
 
   g_return_val_if_fail (command_line != NULL, FALSE);
 
@@ -2626,15 +2692,63 @@ meta_spawn_command_line_async_on_screen 
                            error))
     return FALSE;
   
+  envp = NULL;
+#ifdef HAVE_STARTUP_NOTIFICATION
+  sn_display = sn_display_new (screen->display->xdisplay,
+                               sn_error_trap_push,
+                               sn_error_trap_pop);
+
+  sn_context = sn_launcher_context_new (sn_display,
+                                        screen->number);
+
+  name = argv[0];
+  sn_launcher_context_set_name (sn_context, name);
+
+  description = g_strdup_printf (_("Starting %s"), name);
+  sn_launcher_context_set_description (sn_context, description);
+  g_free (description);
+
+  int workspace = meta_workspace_index (screen->active_workspace);
+  sn_launcher_context_set_workspace (sn_context, workspace);
+                                     
+  sn_launcher_context_set_binary_name (sn_context, name);
+
+  sn_launcher_context_initiate (sn_context,
+                                g_get_prgname () ? g_get_prgname () : "unknown",
+                                argv[0],
+                                launch_time);
+
+  envp = make_spawn_environment_for_sn_context (sn_context);
+#endif /* HAVE_STARTUP_NOTIFICATION */
+
   retval = g_spawn_async (NULL,
                           argv,
-                          NULL,
-                          G_SPAWN_SEARCH_PATH,
-                          set_display_setup_func,
-                          screen->screen_name,
-                          NULL,
+                          envp,
+                          G_SPAWN_SEARCH_PATH /* flags */,
+                          set_display_setup_func, /* child_setup_func */
+                          screen->screen_name, /* child_setup_func_data */
+                          &ret /* child_pid */,
                           error);
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+  if (sn_context != NULL) {
+    if (ret < 0)
+      sn_launcher_context_complete (sn_context); /* end sequence */
+    /*
+    else
+      add_startup_timeout (screen ? screen :
+                           gdk_display_get_default_screen (gdk_display_get_default ()),
+                           sn_context);
+    */
+    sn_launcher_context_unref (sn_context);
+  }
+	
+  sn_display_unref (sn_display);
+#endif /* HAVE_STARTUP_NOTIFICATION */
+	
   g_strfreev (argv);
+  if (envp)
+    g_strfreev (envp);
 
   return retval;
 }
@@ -2672,9 +2786,16 @@ handle_run_command (MetaDisplay    *disp
     }
 
   err = NULL;
-  if (!meta_spawn_command_line_async_on_screen (command, screen, &err))
-    {
-      error_on_command (which, command, err->message, screen->number, event->xkey.time);
+  if (!meta_spawn_command_line_async_on_screen (command,
+                                                screen,
+                                                event->xkey.time,
+                                                &err))
+    {
+      error_on_command (which, 
+                        command,
+                        err->message,
+                        screen->number,
+                        event->xkey.time);
       
       g_error_free (err);
     }
@@ -3516,9 +3637,14 @@ handle_run_terminal (MetaDisplay    *dis
     }
 
   err = NULL;
-  if (!meta_spawn_command_line_async_on_screen (command, screen, &err))
-    {
-      error_on_terminal_command (command, err->message, screen->number,
+  if (!meta_spawn_command_line_async_on_screen (command, 
+                                                screen,
+                                                event->xkey.time,
+                                                &err))
+    {
+      error_on_terminal_command (command,
+                                 err->message,
+                                 screen->number,
 		      		 event->xkey.time);
       
       g_error_free (err);
