diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c index 3c9bec64c..0865b2b86 100644 --- a/src/shell-window-tracker.c +++ b/src/shell-window-tracker.c @@ -639,6 +639,43 @@ shell_window_tracker_get_window_app (ShellWindowTracker *monitor, return app; } + +/** + * shell_app_system_get_from_pid: + * @self; A #ShellAppSystem + * @pid: A Unix process identifier + * + * Look up the application corresponding to a process. + * + * Returns: (transfer full): A #ShellApp, or %NULL if none + */ +ShellApp * +shell_window_tracker_get_app_from_pid (ShellWindowTracker *self, + int pid) +{ + ShellGlobal *global = shell_global_get (); + GList *windows, *iter; + + windows = shell_global_get_windows (global); + for (iter = windows; iter; iter = iter->next) + { + MutterWindow *win = iter->data; + MetaWindow *metawin; + int windowpid; + ShellApp *app; + + metawin = mutter_window_get_meta_window (win); + windowpid = meta_window_get_pid (metawin); + if (windowpid != pid) + continue; + + app = shell_window_tracker_get_window_app (self, metawin); + if (app) + return app; + } + return NULL; +} + /** * shell_window_tracker_get_running_apps: * @monitor: An app monitor instance diff --git a/src/shell-window-tracker.h b/src/shell-window-tracker.h index a61439e13..acc3028a9 100644 --- a/src/shell-window-tracker.h +++ b/src/shell-window-tracker.h @@ -36,6 +36,8 @@ GSList * shell_window_tracker_get_running_apps (ShellWindowTracker *monitor, ShellApp *shell_window_tracker_get_window_app (ShellWindowTracker *monitor, MetaWindow *metawin); +ShellApp *shell_window_tracker_get_app_from_pid (ShellWindowTracker *monitor, int pid); + gboolean shell_window_tracker_is_window_interesting (MetaWindow *window); const char *_shell_window_tracker_get_app_context (ShellWindowTracker *tracker, ShellApp *app);