Use new GLib application API for launching

Launch child processes more directly; we retrieve the PID, and
use it to keep track of the .desktop file we launched.

Now, when we get a window, since the X window has a PID, we
have a pretty strong association.

.desktop file <-> PID <-> window

And can thus map window back to .desktop file.

https://bugzilla.gnome.org/show_bug.cgi?id=637745
This commit is contained in:
Colin Walters
2010-12-20 21:06:03 -05:00
parent d3e223c217
commit a138f59cb0
3 changed files with 94 additions and 1 deletions

View File

@ -12,6 +12,7 @@
#include <glib/gi18n.h>
#include "shell-app-private.h"
#include "shell-window-tracker-private.h"
#include "shell-global.h"
#include "display.h"
#include "st.h"
@ -1296,6 +1297,26 @@ shell_app_info_get_source_window (ShellAppInfo *info)
return NULL;
}
static void
_gather_pid_callback (GDesktopAppInfo *gapp,
GPid pid,
gpointer data)
{
ShellApp *app;
ShellAppSystem *appsys;
ShellWindowTracker *tracker;
g_return_if_fail (data != NULL);
app = SHELL_APP (data);
tracker = shell_window_tracker_get_default ();
appsys = shell_app_system_get_default ();
_shell_window_tracker_add_child_process_app (tracker,
pid,
app);
}
/**
* shell_app_info_launch_full:
* @timestamp: Event timestamp, or 0 for current event timestamp
@ -1312,6 +1333,7 @@ shell_app_info_launch_full (ShellAppInfo *info,
char **startup_id,
GError **error)
{
ShellApp *shell_app;
GDesktopAppInfo *gapp;
GdkAppLaunchContext *context;
gboolean ret;
@ -1363,7 +1385,15 @@ shell_app_info_launch_full (ShellAppInfo *info,
gdk_app_launch_context_set_timestamp (context, timestamp);
gdk_app_launch_context_set_desktop (context, workspace);
ret = g_app_info_launch (G_APP_INFO (gapp), uris, (GAppLaunchContext*) context, error);
shell_app = shell_app_system_get_app (shell_app_system_get_default (),
shell_app_info_get_id (info));
ret = g_desktop_app_info_launch_uris_as_manager (gapp, uris,
(GAppLaunchContext*) context,
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
NULL, NULL,
_gather_pid_callback, shell_app,
error);
g_object_unref (G_OBJECT (gapp));