On Tue, 20 Sep 2011 09:46:55 +0000, boltar2003 wrote:
>>> user to click on a window which my program will then identify. I know
>>> I can used XQueryTree to get the list of windows then call
>>XGetWindowAttributes
>>> on each of them to see which one the mouse pointer is in, but what I can't
>>> figure out is how to tell if a window is occluded by another window. The
>>
>>Isn't the window in the button event?
>
> No, it just gives you the root window id. Using KDE anyway.
Which field are you looking at? It should be in event.xbutton.subwindow.
> >Have a look at the code in xkill !
>
> I can't find it. Got a URL?
Here is the "meat" of the code from xkill-1.0.3:
if (XGrabPointer (dpy, root, False, MASK, GrabModeSync, GrabModeAsync,
None, cursor, CurrentTime) != GrabSuccess) {
fprintf (stderr, "%s: unable to grab cursor\n", ProgramName);
Exit (1);
}
/* from dsimple.c in xwininfo */
while (retwin == None || pressed != 0) {
XEvent event;
XAllowEvents (dpy, SyncPointer, CurrentTime);
XWindowEvent (dpy, root, MASK, &event);
switch (event.type) {
case ButtonPress:
if (retwin == None) {
retbutton = event.xbutton.button;
retwin = ((event.xbutton.subwindow != None) ?
event.xbutton.subwindow : root);
}
pressed++;
continue;
case ButtonRelease:
if (pressed > 0) pressed--;
continue;
} /* end switch */
} /* end for */