Need help finding a window ID for a widget based on coordinates

Mike Stewart mstewart at altroninc.com
Thu Apr 9 09:42:58 PDT 2015


a bit of warning before I begin: I'm not very familiar with X11 and only
recently got asked to do some display work, so if anything seems naive or
ill-informed, it is because I am.

I need to write something that can find the lowest level visible widget at
the location and return the window ID, but find I'm having a wee bit of
trouble. Given I know what display the widget is on 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; I then repeating to the bottom
child. The problem I've run into is when 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 exposed.

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've been playing with (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 hidden by 'buttonA'. 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
703-263-7306

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/20150409/22ffe5ff/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testApp2.cc
Type: application/octet-stream
Size: 3629 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20150409/22ffe5ff/attachment.obj>


More information about the xorg mailing list