[gnome-shell] [ShellWindowTracker] Add shell_window_tracker_app_from_pid
- From: Colin Walters <walters src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell] [ShellWindowTracker] Add shell_window_tracker_app_from_pid
- Date: Thu, 4 Feb 2010 00:06:48 +0000 (UTC)
commit ed129b40a3de339cae0bf909b0560b251d6ad16e
Author: Colin Walters <walters verbum org>
Date: Wed Feb 3 18:42:43 2010 -0500
[ShellWindowTracker] Add shell_window_tracker_app_from_pid
In some situations we might need to look up an application from
a process identifier, such as the notification system where we
will determine application from the message sender.
src/shell-window-tracker.c | 37 +++++++++++++++++++++++++++++++++++++
src/shell-window-tracker.h | 2 ++
2 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c
index 3c9bec6..0865b2b 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 a61439e..acc3028 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]