[Xfce4-commits] [apps/xfce4-taskmanager] 05/21: get PID from a window
noreply at xfce.org
noreply at xfce.org
Thu Jan 26 22:59:09 CET 2017
This is an automated email from the git hooks/post-receive script.
ochosi pushed a commit to branch master
in repository apps/xfce4-taskmanager.
commit 049ad546e607f17d75174ed4f1aaeca3c05cafc3
Author: Florian Schüller <florian.schueller at gmail.com>
Date: Tue Jan 24 00:37:53 2017 +0100
get PID from a window
---
src/process-window.c | 42 +++++++++++++++++++++++++++++++++---------
1 file changed, 33 insertions(+), 9 deletions(-)
diff --git a/src/process-window.c b/src/process-window.c
index fa9eb51..9dc7fa1 100644
--- a/src/process-window.c
+++ b/src/process-window.c
@@ -142,18 +142,42 @@ xwininfo_clicked_cb (GtkButton *button, gpointer user_data) {
Display *dpy = NULL;
XID id = None;
+ Atom atom_NET_WM_PID;
+ long _nitems;
+ int size;
+ Atom actual_type;
+ int actual_format;
+ unsigned char *prop;
+ int status;
+ unsigned long bytes_after;
+
+ int pid = -1;
+
dpy = XOpenDisplay (NULL);
window = Select_Window (dpy, 0);
if (window) {
-/* Window root;
- int dummyi;
- unsigned int dummy;
-
- if (XGetGeometry (dpy, window, &root, &dummyi, &dummyi,
- &dummy, &dummy, &dummy, &dummy) && window != root) */
- window = XmuClientWindow (dpy, window);
- }
- g_warning ("Window ID: 0x%lx", window);
+ window = XmuClientWindow (dpy, window);
+ }
+
+ atom_NET_WM_PID = XInternAtom(dpy, "_NET_WM_PID", False);
+
+ status = XGetWindowProperty(dpy, window, atom_NET_WM_PID, 0, (~0L),
+ False, AnyPropertyType, &actual_type,
+ &actual_format, &_nitems, &bytes_after,
+ &prop);
+ if (status == BadWindow) {
+ g_warning("window id # 0x%lx does not exists!", window);
+ } if (status != Success) {
+ g_warning("XGetWindowProperty failed!");
+ } else {
+ if (_nitems > 0) {
+ pid = (int) *((unsigned long*)prop);
+ g_warning("PID: %d", pid);
+ } else {
+ g_warning("No Pid found");
+ }
+ g_free(prop);
+ }
}
static void
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list