Hello xorg-devel,
I've been working on a window manager which utilizes the _NET_WM_PID
property of windows. There are some applications I use which don't set
this correctly (xpdf for example).
Most of the time I'm running local clients connected via unix domain
sockets. Upon investigation I found Xorg already inquires as to the
unix credentials of such clients, which includes the client pid.
Attached is a patch I developed which sets _NET_WM_PID for toplevel
windows using the already retrieved pid. It was developed and tested
against xorg-server-1.12.4-6+deb7u2 from Debian 7.
I'm not an experienced Xorg hacker, so maybe this isn't acceptable or
not the best way to do it. It improves my use case by enabling my
window manager to know the PID of uncooperative local clients.
Please CC me with any replies since I'm not subscribed.
Thanks,
Vito Caputo
--- xorg-server-1.12.4/dix/window.c 2012-05-17 10:09:02.000000000 -0700
+++ xorg-server-1.12.4.hacked/dix/window.c 2014-06-04 18:54:33.570855708
-0700
@@ -840,6 +840,20 @@
event.u.createNotify.override = pWin->overrideRedirect;
DeliverEvents(pParent, &event, 1, NullWindow);
}
+
+ if (pScreen->root == pParent) {
+ /* top-level windows with local connections can reliably get
_NET_WM_PID set by the server */
+ LocalClientCredRec *lcc;
+ if (GetLocalClientCreds(client, &lcc) != -1)
+ if (lcc->fieldsSet & LCC_PID_SET) {
+ Atom prop;
+
+ prop = MakeAtom("_NET_WM_PID", strlen("_NET_WM_PID"), TRUE);
+ dixChangeWindowProperty(client, pWin, prop,
+ XA_CARDINAL, 32, PropModeReplace,
+ 1, &lcc->pid, FALSE);
+ }
+ }
return pWin;
}
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel