[Xcb] Proting xrestop to XCB
Vincent Torri
Vincent.Torri at iecn.u-nancy.fr
Mon Jun 26 14:47:41 PDT 2006
>
> then first question :
> is there a way of getting the pid of the process owning a defined window
> through XCB ?
>
> xrestop use :
> <code>
> Atom type;
> unsigned long bytes_after, n_items;
> long *data =3D NULL;
> pid_t result =3D -1;
> int format;
>
> if (XGetWindowProperty (app->connection, win,
> "_NET_WM_PID",
> 0, 2L,
> 0, XA_CARDINAL,
> &type, &format, &n_items,
> &bytes_after, (unsigned char **)&data) =3D=3D SUCCESS ....
> </code>
>
> Micha=EBl
>
XGetWindowProperty is not easy. What you need is XCBGetProperty :
XCBInternAtomCookie cookie_atom
XCBGetPropertyCookie cookie_prop;
XCBInternAtomRep *r_atom
XCBGetPropertyRep *r_prop;
cookie_atom =3D XCBInternAtom (c, 0, "_NET_WM_PID", strlen ("_NET_WM_PID");
r_atom =3D XCBInternAtomReply (c, cookie_atom, NULL);
if (!r_atom) return; /* or something else */
cookie_rep =3D XCBGetProperty (c, delete, window,
r_atom->atom, CARDINAL, 0, 2L);
r_prop =3D XCBGetPropertyReply (c, cookie_prop, 0);
if (!r_prop) {
free (r_atom);
return;
}
my_pid =3D *(pid_t *)XCBGetPropertyValue (r_prop);
free (r_atom);
free (r_prop);
hth
Vincent
More information about the Xcb
mailing list