From 413ca350cf9ed8d0b7678e2e43fde7e937916e64 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 10 Mar 2017 14:26:56 -0800 Subject: xwindow: add vwm_xwin_get_pid() helper --- src/xwindow.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/xwindow.c') diff --git a/src/xwindow.c b/src/xwindow.c index f19180e..e22ca49 100644 --- a/src/xwindow.c +++ b/src/xwindow.c @@ -95,6 +95,26 @@ int vwm_xwin_is_mapped(vwm_t *vwm, vwm_xwindow_t *xwin) } +/* helper to get the client pid for a window */ +static int vwm_xwin_get_pid(vwm_t *vwm, vwm_xwindow_t *xwin) +{ + Atom type; + int fmt; + unsigned long nitems; + unsigned long nbytes; + long *foo = NULL; + int pid; + + if (XGetWindowProperty(VWM_XDISPLAY(vwm), xwin->id, vwm->wm_pid_atom, 0, 1, False, XA_CARDINAL, + &type, &fmt, &nitems, &nbytes, (unsigned char **)&foo) != Success || !foo) return -1; + + pid = *foo; + XFree(foo); + + return pid; +} + + /* creates and potentially manages a new window (called in response to CreateNotify events, and during startup for all existing windows) */ /* if the window is already mapped and not an override_redirect window, it becomes managed here. */ vwm_xwindow_t * vwm_xwin_create(vwm_t *vwm, Window win, vwm_grab_mode_t grabbed) -- cgit v1.2.3