View Full Version : Find XWindow id for GLUT based program
I am trying to integrate an existing program (not made by me) that is based on GLUT into my Qt program. The whole thing is running on X. It is posssible to integrate X windows into other applications, but you need to have the Window ID for that window. I have tried searching the web and newsgroups archives for information on how to retreive this ID, but I came up with loads of unrelated links and nothing usefull. Does anyone here know how one can reteive the window id X uses? Any hints on where to look for this info?
11-10-2004, 03:41 AM
I've had similar problems in the past, and settled for the following code. The assumption is that you know the name of your window:
Window getWindowIdFromName(Display *dpy, Window level, char *name)
if (0 == XQueryTree(dpy, level, &dmy, &dmy, &children, &no_of_children))
for (i=0; i<no_of_children; i++)
if (XFetchName(dpy,children[i], &window_name))
if (strcmp (name, window_name))
if (id = getWindowIdFromName(dpy, children[i], name))
}The level parameter in the initial call to the function is the root window, which you can get using:
Window root = DefaultRootWindow(dpy);
I hope this helps.
11-10-2004, 05:13 AM
Thank you! That piece of code works nicely! I just did a minor modification:
unsigned int no_of_children;
This makes it compile :) Thanks again.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.