Get an X window ID

Peter Hutterer mailinglists at
Wed May 23 17:06:03 PDT 2007

eberrocal at wrote:
> $ ./giveMeId
> Segment fault

Ah that one is easy. Your code is broken. If you fix it it'll go away.

Honestly, "Segmentation fault" is about as descriptive as telling your 
car mechanic that "the car doesn't work". A bit more detail would be 
appreciated. A gdb backtrace, the exact line of the segfault, etc.

In your case, it most likely means you're passing a pointer to xlib that 
doesn't have the memory initialised yet. My guess is children_return. Try

Window* children_return;
XQueryTree( ... blah ... , &children_return, &nchildren);

on another note:
RootWindow(dpy, screen) gives you the window ID, no need for XGetGeometry.


More information about the xorg mailing list