]> www.fi.muni.cz Git - evince.git/commitdiff
Set DESKTOP_STARTUP_ID env var on spawned evince processes to prevent focus stealing
authorCarlos Garcia Campos <carlosgc@gnome.org>
Wed, 21 Oct 2009 18:04:08 +0000 (20:04 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Wed, 21 Oct 2009 18:04:08 +0000 (20:04 +0200)
shell/ev-application.c

index 0690cdb6f7b108dae3f1a1f8d47b72b7574127fd..d8aff98be235fdbc498accaa38d496cb302a182b 100644 (file)
@@ -398,12 +398,24 @@ build_args (GdkScreen      *screen,
        return args;
 }
 
+static void
+child_setup (gpointer user_data)
+{
+       gchar *startup_id;
+
+       startup_id = g_strdup_printf ("_TIME%lu",
+                                     (unsigned long)GPOINTER_TO_INT (user_data));
+       g_setenv ("DESKTOP_STARTUP_ID", startup_id, TRUE);
+       g_free (startup_id);
+}
+
 static void
 ev_spawn (const char     *uri,
          GdkScreen      *screen,
          EvLinkDest     *dest,
          EvWindowRunMode mode,
-         const gchar    *search_string)
+         const gchar    *search_string,
+         guint           timestamp)
 {
        gchar   *argv[6];
        guint    arg = 0;
@@ -446,7 +458,10 @@ ev_spawn (const char     *uri,
        argv[arg] = NULL;
 
        res = gdk_spawn_on_screen (screen, NULL /* wd */, argv, NULL /* env */,
-                                  0, NULL, NULL, NULL, &error);
+                                  0,
+                                  child_setup,
+                                  GINT_TO_POINTER(timestamp),
+                                  NULL, &error);
        if (!res) {
                g_warning ("Error launching evince %s: %s\n", uri, error->message);
                g_error_free (error);
@@ -608,7 +623,7 @@ ev_application_open_uri_at_dest (EvApplication  *application,
        if (application->window && !ev_window_is_empty (application->window)) {
                if (application->uri && strcmp (application->uri, uri) != 0) {
                        /* spawn a new evince process */
-                       ev_spawn (uri, screen, dest, mode, search_string);
+                       ev_spawn (uri, screen, dest, mode, search_string, timestamp);
                        return;
                }
        } else {