Unsure how to find widget by location

Thomas Lübking thomas.luebking at gmail.com
Fri Apr 10 07:35:06 PDT 2015


On Mittwoch, 8. April 2015 23:50:59 CEST, Mike Stewart wrote:
> 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.



Good idea.
Do XQueryTree on the root window and iterate the returned list backwards.
The first currently mapped window that covers the desired spot is your "Window" (nb. that you'll likely also have to cover the shape extension, ie. check whether the window has a mask and whether the desired spot is masked away in this window)

Then repeat that process recursively until a window has no more mapped children under the target position. That's your desired widget.

NOTICE: "modern" toolkits (Gtk+ & Qt) do usually no longer use one X drawable per UI element. The window is a plain & empty surface from the X11 pov.

Cheers,
Thomas


More information about the xorg mailing list