Re: [g-a-devel] Which window is on top?



Steve,

I added some code to call some X primitives, notably XQueryPointer which
returns the window under the mouse and XQueryTree which promises to
deliver the children of a window: "The children are listed in current
stacking order, from bottommost (first) to topmost (last)."  After
reading that, I thought I had the answer to my prayers.  But alas, it
was not to be.  Here's what happens:

On my desktop I have two terminal windows and Firefox running.  Each of
these running apps has a button on the bottom (task?) panel of my
desktop.  If I click that button, the associated window becomes topmost
on my desktop.

1. In a terminal window I run my app
2. Using the mouse, I click on the Firefox button on the botton panel of
my desktop.
   - this brings the Firefox window (http://www.weather.com) to the top.
3. I hover my mouse over the "Site" radio button in 'The Weather
Channel" search box near the top of the web page
4. I click f8, which triggers a listener in my app.  The listener does
this:
5. calls XQueryPointer which says that window 0x41 is the root and
window 0x220059b is the child window under the mouse.
6. calls XGetWMName() to retrieve the name of 0x220059b, but it is null.
7. calls XQueryTree on 0x220059b to get the single child, the name of
that child matches the title of my Firefox window.
   -- so 0x220059b appears to be the Firefox window (there are multiple
Firefox children of 0x41, see below). 
8. calls XQueryTree on 0x41, which is presumably the deskop window, to
retrieve the 77 child windows
9. Notes that Window 0x220059b, is number 14 of 77, which would seem to
put it pretty low on the stacking order.
   - more towards the bottom of the stacking order than the Terminal
windows (see below).

In step 2 I put the Firefox window on top of all terminal windows on my
desktop.  Any idea why it appears to be below those windows in step 9?
Also, in step 4, if I first click on the "Site" radio button and then
hit F8, 0x220059b is still window 14/77 and is still more bottom than
the terminal windows.

-Sam

PS: Before Friday, I had never called an Xlib function in my life, so I
am probably doing many things wrong.  Just for completeness, below are
the 77 child windows of the root window.

at-spi claims that Firefox is application 18/18 of my desktop.  It has
one child.  That child has the same name as the title of my Firefox
window.  That child is a Component with dimensions: (x:288..1215,
y:67..699) (w:928, h:633), which means the upper left corner is (288,
67), the bottom right is (1215,67), the width and height are w:928,
h:633.  Note that w,h are both 10 pixels less than the w,h for 0x220059b
below:

ccount = child count
The string on the far right is the name of the window returned by
XGetWNName().
(=Err1WM_NAME= means the name was null)

1/77 0x400001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10)
"seahorse-agent"
2/77 0x800001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10)
"x-session-manager"
3/77 0xa00001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "<unknown>"
4/77 0x1000001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10)
"gnome-settings-daemon"
5/77 0x1000003 ccount: 0 (x:0..9, y:0..9) (w:10, h:10) "=Err1WM_NAME="
6/77 0x1000004 ccount: 0 (x:0..9, y:0..9) (w:10, h:10) "=Err1WM_NAME="
7/77 0x1800001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10)
"gnome-screensaver"
8/77 0x1800003 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"gnome-screensaver"
9/77 0x1600001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "gnome-panel"
10/77 0x1e00001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "File
Manager"
11/77 0x1e00022 ccount: 3 (x:0..1492, y:0..856) (w:1493, h:857)
"Desktop"
12/77 0x22166d8 ccount: 1 (x:676..1342, y:149..612) (w:667, h:464)
"=Err1WM_NAME="
13/77 0x22000ac ccount: 1 (x:167..1377, y:65..749) (w:1211, h:685)
"=Err1WM_NAME="
14/77 0x220059b ccount: 1 (x:283..1220, y:43..704) (w:938, h:662)
"=Err1WM_NAME="
15/77 0x1600003 ccount: 2 (x:0..1492, y:832..856) (w:1493, h:25) "Bottom
Expanded Edge Panel"
16/77 0x1600030 ccount: 2 (x:0..1492, y:0..24) (w:1493, h:25) "Top
Expanded Edge Panel"
17/77 0x2200001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "metacity"
18/77 0x1e00004 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10) "File
Manager"
19/77 0x2200003 ccount: 0 (x:-100..-100, y:-100..-100) (w:1, h:1)
"=Err1WM_NAME="
20/77 0x2200004 ccount: 0 (x:-100..-100, y:-100..-100) (w:1, h:1)
"=Err1WM_NAME="
21/77 0x2200005 ccount: 0 (x:-100..-100, y:-100..-100) (w:1, h:1)
"=Err1WM_NAME="
22/77 0x2200006 ccount: 0 (x:-100..-100, y:-100..-100) (w:1, h:1)
"=Err1WM_NAME="
23/77 0x220000e ccount: 0 (x:-100..-100, y:-100..-100) (w:1, h:1)
"=Err1WM_NAME="
24/77 0x220000f ccount: 1 (x:0..199, y:0..199) (w:200, h:200) "metacity"
25/77 0x2600001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "Bluetooth
Applet"
26/77 0x2a00001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10)
"update-notifier"
27/77 0x3000001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "Tracker"
28/77 0x2a00003 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"update-notifier"
29/77 0x3200001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "Power
Manager"
30/77 0x3400001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "nm-applet"
31/77 0x3600001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10)
"gnome-volume-manager"
32/77 0x3800001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10)
"evolution-alarm-notify"
31/77 0x3600001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10)
"gnome-volume-manager"
32/77 0x3800001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10)
"evolution-alarm-notify"
33/77 0x1600035 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"gnome-panel"
34/77 0x3600003 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"gnome-volume-manager"
35/77 0x2a00021 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"update-notifier"
36/77 0x3200023 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10) "Power
Manager"
37/77 0x1e000ac ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10) "File
Manager"
38/77 0x3800003 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"evolution-alarm-notify"
39/77 0x1600043 ccount: 0 (x:0..9, y:0..9) (w:10, h:10) "=Err1WM_NAME="
40/77 0x1e000ad ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10) "File
Manager"
41/77 0x4600001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "Trash
Applet"
42/77 0x4800001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "applet.py"
43/77 0x5000001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "Volume
Applet"
44/77 0x5200001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "Fast User
Switch Applet"
45/77 0x5200028 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10) "Fast
User Switch Applet"
46/77 0x16000cf ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"gnome-panel"
47/77 0x5600001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10)
"vmware-user"
48/77 0x5600003 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"vmware-user"
49/77 0x5600021 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"vmware-user"
50/77 0x5600022 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"vmware-user"
51/77 0x4e00001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "Terminal"
52/77 0x4e00076 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"Terminal"
53/77 0x4e000aa ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"Terminal"
54/77 0x6400001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10)
"notification-daemon"
55/77 0x4000001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "Firefox"
56/77 0x4000003 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"Firefox"
57/77 0x400003a ccount: 2 (x:0..199, y:0..199) (w:200, h:200)
"=NoWM_NAME="
58/77 0x40000d5 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"Firefox"
59/77 0x40000d8 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"Firefox"
60/77 0x40000d9 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"Firefox"
61/77 0x40000dc ccount: 15 (x:0..199, y:0..199) (w:200, h:200) "Firefox"
62/77 0x40000e9 ccount: 2 (x:0..199, y:0..199) (w:200, h:200) "Firefox"
63/77 0x400011b ccount: 1 (x:0..199, y:0..199) (w:200, h:200) "Firefox"
64/77 0x4000188 ccount: 1 (x:0..0, y:0..0) (w:1, h:1) "Firefox"
65/77 0x4000517 ccount: 2 (x:213..734, y:107..624) (w:522, h:518)
"Firefox"
66/77 0x40006aa ccount: 2 (x:0..199, y:0..199) (w:200, h:200) "Firefox"
67/77 0x1600d0d ccount: 2 (x:0..165, y:24..279) (w:166, h:256)
"gnome-panel"
68/77 0x2203281 ccount: 0 (x:0..1439, y:0..844) (w:1440, h:845)
"=Err1WM_NAME="
69/77 0x1600d33 ccount: 2 (x:175..337, y:24..231) (w:163, h:208)
"gnome-panel"
70/77 0x1602a01 ccount: 1 (x:-100..-100, y:-100..-100) (w:1, h:1)
"gnome-panel"
71/77 0x4e26725 ccount: 2 (x:64..229, y:378..636) (w:166, h:259)
"Terminal"
72/77 0x400cc94 ccount: 2 (x:593..815, y:91..319) (w:223, h:229)
"Firefox"
73/77 0x400ce9d ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"Firefox"
74/77 0x40147f7 ccount: 0 (x:-100..-91, y:-100..-91) (w:10, h:10)
"Firefox"
75/77 0x1608c9a ccount: 2 (x:34..193, y:667..832) (w:160, h:166)
"gnome-panel"
76/77 0x1608cdd ccount: 2 (x:565..708, y:273..438) (w:144, h:166)
"gnome-panel"
77/77 0x6000001 ccount: 1 (x:10..19, y:10..19) (w:10, h:10) "sbq"




-----Original Message-----
From: Steve Lee [mailto:steve fullmeasure co uk] 
Sent: Friday, January 02, 2009 11:23 AM
To: David Bolter
Cc: Quiring, Sam; gnome-accessibility-devel gnome org
Subject: Re: [g-a-devel] Which window is on top?

Thanks David. I knew there was a library we used in Python for accessing
WM features that had a strange name. Yep, that's the one.

Steve

2009/1/2 David Bolter <dtb gnome org>:
> Hi Sam (and hi Steve)
>
> You might find libwnck useful:
>
> http://library.gnome.org/devel/libwnck/stable/WnckWindow.html#wnck-win
> dow-is-above
> (and wnck_window_is_below)
>
> Note you could use libwnck API... or find out how it is implemented 
> under the hood :)
>
> cheers,
> David
>
> Quiring, Sam wrote:
>> Steve, thanks for your reply.
>>
>> I called gtk_init(null, null) and then tried using
>> gdk_display_get_window_at_pointer() and gdk_window_at_pointer(), both

>> returned null, which I'm interpretting as "that window belongs to a 
>> different application -- you do not have access".
>>
>> I decided to drop down to XWindows.  I have been able to find the 
>> XWindow under the mouse and match its geometry (x, y, width, height) 
>> with the Accessible *window obtained from ap-spi, so this might work.
>> Of course if there happened to be multiple identical windows at the 
>> same spot, I would not be able to distinguish them.
>>
>> This brings up two questions:
>>
>> 1. Is there a way to map from an at-spi Accessible *value to its
>>    associated XWindow window?
>> 2. Is there a better alternative than XWindows for doing this?
>>
>> Thanks.
>>
>> -Sam
>>
>> -----Original Message-----
>> From: Steve Lee [mailto:steve fullmeasure co uk]
>> Sent: Friday, January 02, 2009 1:52 AM
>> To: Quiring, Sam
>> Cc: gnome-accessibility-devel gnome org
>> Subject: Re: [g-a-devel] Which window is on top?
>>
>> 2008/12/31 Quiring, Sam <Sam Quiring windriver com>:
>>
>>> I cannot find a way to figure out what window is on top nor the 
>>> zorder
>>>
>>
>>
>>> relationship of the windows.
>>>
>>
>> Sam, this is something where you may need to look outside the a11y
API.
>> e.g the windows manager
>>
>> Happy new year
>> --
>> Steve Lee
>> Open Source Assistive Technology Software and Accessibility 
>> fullmeasure.co.uk _______________________________________________
>> Gnome-accessibility-devel mailing list 
>> Gnome-accessibility-devel gnome org
>> http://mail.gnome.org/mailman/listinfo/gnome-accessibility-devel
>>
>
>



--
Steve Lee
Open Source Assistive Technology Software and Accessibility
fullmeasure.co.uk


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]