[gnome-shell/wip/app-system-rewrite: 6/13] app: Remove the use of g_desktop_app_info_launch_uris_as_manager



commit d8e2de006c225c513dea2f02daa633df36c711bc
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Apr 21 00:27:58 2013 -0400

    app: Remove the use of g_desktop_app_info_launch_uris_as_manager
    
    ... and at the same time, remove tracking windows by launched PID.
    It will fail working after a Shell restart, and Ryan wants to
    remove the method as it's racy and not a great idea.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=698486

 src/Makefile.am                    |    1 -
 src/shell-app-system.c             |    1 -
 src/shell-app.c                    |   29 ++-----------
 src/shell-window-tracker-private.h |   11 -----
 src/shell-window-tracker.c         |   78 +-----------------------------------
 5 files changed, 5 insertions(+), 115 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 8041052..7a83a12 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -157,7 +157,6 @@ libgnome_shell_sources =            \
        shell-app-private.h             \
        shell-app-system-private.h      \
        shell-global-private.h          \
-       shell-window-tracker-private.h  \
        shell-wm-private.h              \
        gnome-shell-plugin.c            \
        shell-app.c                     \
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index 6581211..41ac030 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -10,7 +10,6 @@
 #include <glib/gi18n.h>
 
 #include "shell-app-private.h"
-#include "shell-window-tracker-private.h"
 #include "shell-app-system-private.h"
 #include "shell-global.h"
 #include "shell-util.h"
diff --git a/src/shell-app.c b/src/shell-app.c
index 1759d6d..fc283eb 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -12,8 +12,8 @@
 #include "shell-enum-types.h"
 #include "shell-global.h"
 #include "shell-util.h"
+#include "shell-window-tracker.h"
 #include "shell-app-system-private.h"
-#include "shell-window-tracker-private.h"
 #include "st.h"
 #include "gtkactionmuxer.h"
 
@@ -1167,24 +1167,6 @@ shell_app_request_quit (ShellApp   *app)
   return TRUE;
 }
 
-static void
-_gather_pid_callback (GDesktopAppInfo   *gapp,
-                      GPid               pid,
-                      gpointer           data)
-{
-  ShellApp *app;
-  ShellWindowTracker *tracker;
-
-  g_return_if_fail (data != NULL);
-
-  app = SHELL_APP (data);
-  tracker = shell_window_tracker_get_default ();
-
-  _shell_window_tracker_add_child_process_app (tracker,
-                                               pid,
-                                               app);
-}
-
 /**
  * shell_app_launch:
  * @timestamp: Event timestamp, or 0 for current event timestamp
@@ -1236,12 +1218,9 @@ shell_app_launch (ShellApp     *app,
   gdk_app_launch_context_set_timestamp (context, timestamp);
   gdk_app_launch_context_set_desktop (context, workspace);
 
-  ret = g_desktop_app_info_launch_uris_as_manager (app->info, uris,
-                                                   G_APP_LAUNCH_CONTEXT (context),
-                                                   G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
-                                                   NULL, NULL,
-                                                   _gather_pid_callback, app,
-                                                   error);
+  ret = g_app_info_launch_uris (G_APP_INFO (app->info), uris,
+                                G_APP_LAUNCH_CONTEXT (context),
+                                error);
   g_object_unref (context);
 
   return ret;
diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c
index ed9d9b4..13ff071 100644
--- a/src/shell-window-tracker.c
+++ b/src/shell-window-tracker.c
@@ -17,7 +17,7 @@
 #define SN_API_NOT_YET_FROZEN 1
 #include <libsn/sn.h>
 
-#include "shell-window-tracker-private.h"
+#include "shell-window-tracker.h"
 #include "shell-app-private.h"
 #include "shell-global.h"
 #include "st.h"
@@ -47,9 +47,6 @@ struct _ShellWindowTracker
 
   /* <MetaWindow * window, ShellApp *app> */
   GHashTable *window_to_app;
-
-  /* <int, ShellApp *app> */
-  GHashTable *launched_pid_to_app;
 };
 
 G_DEFINE_TYPE (ShellWindowTracker, shell_window_tracker, G_TYPE_OBJECT);
@@ -326,38 +323,6 @@ get_app_from_window_group (ShellWindowTracker  *tracker,
 }
 
 /**
- * get_app_from_window_pid:
- * @tracker: a #ShellWindowTracker
- * @window: a #MetaWindow
- *
- * Check if the pid associated with @window corresponds to an
- * application we launched.
- *
- * Return value: (transfer full): A newly-referenced #ShellApp, or %NULL
- */
-static ShellApp *
-get_app_from_window_pid (ShellWindowTracker  *tracker,
-                         MetaWindow          *window)
-{
-  ShellApp *result;
-  int pid;
-
-  if (meta_window_is_remote (window))
-    return NULL;
-
-  pid = meta_window_get_pid (window);
-
-  if (pid == -1)
-    return NULL;
-
-  result = g_hash_table_lookup (tracker->launched_pid_to_app, GINT_TO_POINTER (pid));
-  if (result != NULL)
-    g_object_ref (result);
-
-  return result;
-}
-
-/**
  * get_app_for_window:
  *
  * Determines the application associated with a window, using
@@ -404,10 +369,6 @@ get_app_for_window (ShellWindowTracker    *tracker,
   if (result != NULL)
     return result;
 
-  result = get_app_from_window_pid (tracker, window);
-  if (result != NULL)
-    return result;
-
   /* Now we check whether we have a match through startup-notification */
   startup_id = meta_window_get_startup_id (window);
   if (startup_id)
@@ -641,8 +602,6 @@ shell_window_tracker_init (ShellWindowTracker *self)
   self->window_to_app = g_hash_table_new_full (g_direct_hash, g_direct_equal,
                                                NULL, (GDestroyNotify) g_object_unref);
 
-  self->launched_pid_to_app = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_object_unref);
-
   screen = shell_global_get_screen (shell_global_get ());
 
   g_signal_connect (G_OBJECT (screen), "startup-sequence-changed",
@@ -658,7 +617,6 @@ shell_window_tracker_finalize (GObject *object)
   ShellWindowTracker *self = SHELL_WINDOW_TRACKER (object);
 
   g_hash_table_destroy (self->window_to_app);
-  g_hash_table_destroy (self->launched_pid_to_app);
 
   G_OBJECT_CLASS (shell_window_tracker_parent_class)->finalize(object);
 }
@@ -733,40 +691,6 @@ shell_window_tracker_get_app_from_pid (ShellWindowTracker *tracker,
 }
 
 static void
-on_child_exited (GPid      pid,
-                 gint      status,
-                 gpointer  unused_data)
-{
-  ShellWindowTracker *tracker;
-
-  tracker = shell_window_tracker_get_default ();
-
-  g_hash_table_remove (tracker->launched_pid_to_app, GINT_TO_POINTER((gint)pid));
-}
-
-void
-_shell_window_tracker_add_child_process_app (ShellWindowTracker *tracker,
-                                             GPid                pid,
-                                             ShellApp           *app)
-{
-  gpointer pid_ptr = GINT_TO_POINTER((int)pid);
-
-  if (g_hash_table_lookup (tracker->launched_pid_to_app,
-                           &pid_ptr))
-    return;
-
-  g_hash_table_insert (tracker->launched_pid_to_app,
-                       pid_ptr,
-                       g_object_ref (app));
-  g_child_watch_add (pid, on_child_exited, NULL);
-  /* TODO: rescan unassociated windows
-   * Unlikely in practice that the launched app gets ahead of us
-   * enough to map an X window before we get scheduled after the fork(),
-   * but adding this note for future reference.
-   */
-}
-
-static void
 set_focus_app (ShellWindowTracker  *tracker,
                ShellApp            *new_focus_app)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]