Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Xlib question

12 views
Skip to first unread message

bolta...@boltar.world

unread,
Sep 20, 2011, 4:57:23 AM9/20/11
to
Hello

I need to implement similar functionality to xkill in that I need the
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
map_state field in XWindowAttributes doesn't seem to be much use for this so
does anyone know an easy way to find out what the upper most window at a
given screen location is?

Thanks for any help

B2003

Julian Bradfield

unread,
Sep 20, 2011, 5:01:05 AM9/20/11
to
On 2011-09-20, bolta...@boltar.world <bolta...@boltar.world> 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?

Have a look at the code in xkill !

bolta...@boltar.world

unread,
Sep 20, 2011, 5:46:55 AM9/20/11
to
No, it just gives you the root window id. Using KDE anyway.

>Have a look at the code in xkill !

I can't find it. Got a URL?

Cheers

B2003


Julian Bradfield

unread,
Sep 20, 2011, 6:01:42 AM9/20/11
to
On 2011-09-20, bolta...@boltar.world <bolta...@boltar.world> wrote:
>>Have a look at the code in xkill !
>
> I can't find it. Got a URL?

Google xkill source
and take the first hit.

Single Stage to Orbit

unread,
Sep 20, 2011, 6:03:04 AM9/20/11
to

Look for xkill:
http://xorg.freedesktop.org/
--
Tactical Nuclear Kittens

Nobody

unread,
Sep 20, 2011, 9:35:33 AM9/20/11
to
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 */

William Ahern

unread,
Sep 20, 2011, 6:00:42 PM9/20/11
to
0 new messages