After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 637745 - Use new GLib application API for launching
Use new GLib application API for launching
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Owen Taylor
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2010-12-21 14:20 UTC by Colin Walters
Modified: 2011-02-08 16:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use new GLib application API for launching (6.77 KB, patch)
2010-12-21 14:21 UTC, Colin Walters
none Details | Review
Use new GLib application API for launching (6.76 KB, patch)
2011-01-06 22:31 UTC, Colin Walters
committed Details | Review

Description Colin Walters 2010-12-21 14:20:56 UTC
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.
Comment 1 Colin Walters 2010-12-21 14:21:00 UTC
Created attachment 176827 [details] [review]
Use new GLib application API for launching
Comment 2 Colin Walters 2011-01-06 22:31:45 UTC
Created attachment 177709 [details] [review]
Use new GLib application API for launching

Update for renamed glib API, minor code cleanup.
Comment 3 Owen Taylor 2011-01-10 16:14:01 UTC
Review of attachment 177709 [details] [review]:

Basically looks fine to commit, just minor commits.

::: src/shell-app-system.c
@@ +1392,3 @@
+
+  ret = g_desktop_app_info_launch_uris_as_manager (gapp, uris,
+                                                   (GAppLaunchContext*) context,

Use a gobjct-style cast

@@ +1400,1 @@
   g_object_unref (G_OBJECT (gapp));

We don't use the G_OBJECT() cast in this case (g_object_ref/unref take a gpointer for convenience)

::: src/shell-window-tracker.c
@@ +394,3 @@
+  pid = meta_window_get_pid (window);
+
+  return g_hash_table_lookup (tracker->launched_pid_to_app, GINT_TO_POINTER (pid));

Would rather you didn't hash_table_lookup() the pid == -1 case

@@ +848,3 @@
+
+  if (g_hash_table_lookup (tracker->launched_pid_to_app,
+                           &pid_int))

You want GINT_TO_POINTER. Maybe some comment here indicating when this is expected to happen would be good.

 /* Might happen on rapid PID use by the OS */

Or something.

@@ +856,3 @@
+  g_child_watch_add (pid, on_child_exited, NULL);
+  /* TODO: rescan unassociated windows
+   * Very unlikely in practice that the launched app gets ahead of us

Perhaps better expressed as _somewhat_ unlikely
Comment 4 Colin Walters 2011-02-08 16:12:33 UTC
Attachment 177709 [details] pushed as a138f59 - Use new GLib application API for launching