From 8b7b41df419aca7f5471c64432dd80ea4eedbcb1 Mon Sep 17 00:00:00 2001 From: Tomas Frydrych Date: Fri, 31 Jul 2009 18:52:25 +0100 Subject: [PATCH] Accessors for pid and name of client machine associated with MetaWindow http://bugzilla.gnome.org/show_bug.cgi?id=590388 --- src/core/window.c | 37 +++++++++++++++++++++++++++++++++++++ src/include/window.h | 3 ++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/core/window.c b/src/core/window.c index 6f62e0cb6..168ca0eb8 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -8668,3 +8668,40 @@ meta_window_get_transient_for (MetaWindow *window) else return NULL; } + +/** + * meta_window_get_pid: + * @window: a #MetaWindow + * + * Returns pid of the process that created this window, if known (obtained from + * the _NET_WM_PID property). + * + * Return value: (transfer none): the pid, or -1 if not known. + */ +int +meta_window_get_pid (MetaWindow *window) +{ + g_return_val_if_fail (META_IS_WINDOW (window), -1); + + return window->net_wm_pid; +} + +/** + * meta_window_get_client_machine: + * @window: a #MetaWindow + * + * Returns name of the client machine from which this windows was created, + * if known (obtained from the WM_CLIENT_MACHINE property). + * + * Return value: (transfer none): the machine name, or NULL; the string is + * owned by the window manager and should not be freed or modified by the + * caller. + */ +const char * +meta_window_get_client_machine (MetaWindow *window) +{ + g_return_val_if_fail (META_IS_WINDOW (window), NULL); + + return window->wm_client_machine; +} + diff --git a/src/include/window.h b/src/include/window.h index d5929fdf7..d26c9723f 100644 --- a/src/include/window.h +++ b/src/include/window.h @@ -112,5 +112,6 @@ const char *meta_window_get_title (MetaWindow *window); MetaWindow *meta_window_get_transient_for (MetaWindow *window); void meta_window_delete (MetaWindow *window, guint32 timestamp); - +int meta_window_get_pid (MetaWindow *window); +const char *meta_window_get_client_machine (MetaWindow *window); #endif