Hi, > >I tried your example because I don't know the _NET_WM_PID property > >and was interested in it. Unfortunately the call to XGetWindowProperty() > >never filled the &prop data. Your code is checking against the return > >code of XGetWindowProperty() which is fine but prop equals to (nil) in > >all my tests. I was using metacity as suggested windowmanger. > > > >Do you have any idea why it fails ? > > > >The window Id which is required of course is obtained from a > >"xwininfo" call. I passed the information from this command to > > Using this (removed the uid stuff) works here: > > [EMAIL PROTECTED] fer]$ gcc test.c -L/usr/X11R6/lib/ -I/usr/X11R6/include/ -lX11 -o > test > [EMAIL PROTECTED] fer]$ xwininfo > > xwininfo: Please select the window about which you > would like information by clicking the > mouse in that window. > > xwininfo: Window id: 0x1e00012 "[EMAIL PROTECTED]:~" > [...] > [EMAIL PROTECTED] fer]$ ./a.out 0x1e00012 > pid of window 0x1e00012 = 24109
Hmm, yes I see, I did it the same way but it doesn't work for me. The code I use is as follows: ----snip---- #include <X11/Xlib.h> #include <X11/Xos.h> #include <X11/Xfuncs.h> #include <X11/Xutil.h> #include <stdio.h> #include <ctype.h> #include <X11/Xatom.h> #include <X11/Xmu/WinUtil.h> int main (int argc, char*argv[]) { Atom atom,actual_type; Display *dpy; int screen; char *atom_name; int actual_format; unsigned long nitems; unsigned long bytes_after; unsigned char *prop; int status; int pid; Window w=0; dpy = XOpenDisplay((char*)getenv("DISPLAY")); screen = DefaultScreen(dpy); if (argc!=2) { printf("Usage %s window-id\n",argv[0]); exit(-1); } sscanf(argv[1],"0x%x",(unsigned int*)(&w)); atom = XInternAtom(dpy, "_NET_WM_PID", True); atom_name = XGetAtomName (dpy,atom); status = XGetWindowProperty( dpy, w, atom, 0, 1024, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &prop ); if (status!=0) { printf("Cannot get _NET_WM_PID"); exit(-2); } if (! prop) { printf ("No properties\n"); exit (-3); } pid = prop[1] * 256; pid += prop[0]; printf("pid of window 0x%x = %d\n",(unsigned int)w,pid); return 0; } ----snap--- gcc id.c -L/usr/X11R6/lib/ -I/usr/X11R6/include/ -lX11 -o bla I'm running XFree86 Version 4.3.99.902 (4.4.0 RC 2) on kernel 2.6.4-6-default. any ideas ? Regards Marcus -- Public Key available ---------------------------------------------------- Marcus Schäfer (Res. & Dev.) SUSE LINUX AG Tel: 0911-740 53 0 Maxfeldstrasse 5 FAX: 0911-741 77 55 D-90409 Nürnberg http://www.suse.de Germany ---------------------------------------------------- _______________________________________________ Devel mailing list [EMAIL PROTECTED] http://XFree86.Org/mailman/listinfo/devel