Associate process identifiers with applications

Cache the set of pids for an application, in preparation for
landing an XSMP patch which requires this information.

https://bugzilla.gnome.org/show_bug.cgi?id=619542
This commit is contained in:
Colin Walters
2010-05-24 10:59:52 -04:00
parent e4a6bf994f
commit bf6d0dc808
3 changed files with 55 additions and 20 deletions

View File

@ -739,6 +739,32 @@ _shell_app_remove_window (ShellApp *app,
}
}
/**
* shell_app_get_pids:
* @app: a #ShellApp
*
* Returns: (transfer container) (element-type int): An unordered list of process identifers associated with this application.
*/
GSList *
shell_app_get_pids (ShellApp *app)
{
GSList *result;
GSList *iter;
result = NULL;
for (iter = shell_app_get_windows (app); iter; iter = iter->next)
{
MetaWindow *window = iter->data;
int pid = meta_window_get_pid (window);
/* Note in the (by far) common case, app will only have one pid, so
* we'll hit the first element, so don't worry about O(N^2) here.
*/
if (!g_slist_find (result, GINT_TO_POINTER (pid)))
result = g_slist_prepend (result, GINT_TO_POINTER (pid));
}
return result;
}
void
_shell_app_set_starting (ShellApp *app,
gboolean starting)