Unsure how to find widget by location

Mike Stewart mstewart at altroninc.com
Wed Apr 8 14:50:59 PDT 2015

So fair warning, I've recently been asked to do some display work and I'm
not extremely familiar with it.

I am currently in the midst of trying to write something that can identify
the lowest level visible widget at the location and return the window ID,
but find I'm having a wee bit of trouble. Using the known display and the
default root window of that display, I was attempting to find the window ID
of a button widget by recursively calling XQueryTree. I am calling
XQueryTree,  then use XGetWindowAttributes to check the child windows for
visibility and if the given x,y pairing are inside of them, and then
repeating to the bottom child. The problem I've run into is I have a
situation where two buttons are stacked on top of each other. I have no
idea how to tell the difference between an exposed window and one that is
covered up. Both end up having identical attributes returned from
XGetWindowAttributes, so I have no idea how to tell which one is actually

Clearly there is some way to do this, but I do not understand it. I can get
to the correct window if I instead depend on XQueryPointer and recursively
call it with the subwindow of the previous XQueryPointer's results, however
I'm trying to do this without moving the mouse.

Attached is the source for a small test app I'm trying this in, case my
description wasn't particularly clear. When I run this test app and mouse
over buttonA stacked on top of buttonB, the XQueryTree ends up returning
the window id of buttonB regardless of if its the exposed button, or if
buttonA is the exposed button. the XQueryPointer always gets the right
window however. Clearly checking for the dimensions and visibility isn't
enough to pick the correct, exposed window.

Mike Stewart
mstewart at altroninc.com

This electronic mail transmission, including any attachments, may contain
certain information (technical data, proprietary information, etc.) whose
dissemination is controlled by US export laws and regulations, DOD
Distribution D statements, or non-disclosure agreements.  Unauthorized
review, use, disclosure, or distribution is prohibited.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg/attachments/20150408/e9d6aaa9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testApp2.cc
Type: text/x-c++src
Size: 3629 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20150408/e9d6aaa9/attachment.cc>

More information about the xorg mailing list