After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 125406 - gnopernicus magnifier doesn't always follow focus
gnopernicus magnifier doesn't always follow focus
Status: RESOLVED FIXED
Product: gnopernicus
Classification: Deprecated
Component: general
unspecified
Other Linux
: Normal major
: ---
Assigned To: remus draica
remus draica
AP1
Depends on:
Blocks:
 
 
Reported: 2003-10-24 15:01 UTC by bill.haneman
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test program (14.31 KB, text/plain)
2003-10-30 15:16 UTC, Adi Dascal
  Details
Log that I obtained with the test-program inspecting gnome-cd and gnome-terminal (switching between these 2 apps) (19.41 KB, text/plain)
2003-10-30 15:19 UTC, Adi Dascal
  Details
proposed patch (1022 bytes, patch)
2003-11-13 13:47 UTC, remus draica
none Details | Review

Description bill.haneman 2003-10-24 15:01:06 UTC
gnopernicus' magnifier focus-tracking seems intermittent.  Under some
conditions it only sporadically follows the focus events sent to it by
at-spi.  At the moment I am seeing this when an 'inaccessible' application
is also resident on the desktop, but it may happen in other situations. 
The 'inaccessible' app is not expected to focus-track, of course, but focus
tracking in 'accessible' apps seems to be broken if focus moves from the
inaccessible application into the accessible one.

For instance, if one is running gnopernicus, gnome-cd, and an xterm, when
moving from the xterm to gnome-cd via Alt-TAB, sometimes focus tracking in
gnome-cd doesn't work afterwards.  At other times it does; so cycling to
gnome-cd several times via Alt-TAB will, eventually, cause the magnifier's
focus tracking to start working again in the magnifier.  (Note that I am
referring to keynav-style keyboard focus tracking, not mouse following).

To reproduce:

Run gnome-cd, gnopernicus, and xterm.  Move to gnopernicus, press arrow
keys or TAB to see the magnifier track oncsreen focus.  Press Alt-TAB to
focus xterm; as one expects the magnifier doesn't follow focus in the
xterm.  Press Alt-TAB one or more times to focus gnome-cd; press arrow keys
or TAB; note that sometimes the magnifier re-centers to show gnome-cd as
expected, and recenters when necessary as TAB or arrow keys are pressed,
but sometimes it does not.
Comment 1 remus draica 2003-10-29 13:46:39 UTC
Bill, are you sure that no part of current focused object is on
magnifier. I tried to reproduce it, but with no results.
Comment 2 Adi Dascal 2003-10-29 15:56:36 UTC
I am not able to reproduce the above scenario, please provide more
information.

I will explain how the magnifier focus tracking is NOW working in
gnopernicus:


The focus tracking is following the focus object. 
-If the bounding rectangle of the focus object are already magnified
and totally visible then the magnified area won't move.
-If the focus object is clipped to the left (so only its right part is
visible) then the magnified area will move to the left, making the
focused object to be inside the magnified area. 
-If the focus object is clipped to the right (so only its left part is
visible) then the magnified area will move to the right, making the
focused object to be inside the magnified area. 
-If the focus object is clipped on the top (so only its bottom part is
visible) then the magnified area will move up, making the focused
object to be inside the magnified area. 
-If the focus object is clipped on the bottom (so only its top part is
visible) then the magnified area will move down, making the focused
object to be inside the magnified area.
-If the focus object is out (not visible at all) then the magnified
area will move in such way that the movement will be the minimum.

The algorithm described here is similar to the "push" mode of the
"mouse tracking", so the focus-tracking won't be jerky.

Note that there is an RFE (bug #124641) and gnopernicus will implement
a centered-focus-tracking mode, too.
Comment 3 bill.haneman 2003-10-29 19:24:09 UTC
I understand the various tracking algorithms; however the case I am
referring to is where gnopernicus does not include the
currently-focussed component anywhere in the magnifier window.
 
As I said the problem is intermittent but reproducible on my system; I
can now reproduce this with ONLY gnome-cd and gnopernicus on the
screen (aside from the panel of course).  I have not yet seen it
without gnome-cd running, so possibly there is an influence from the
too-frequent window-title-changed messages from gnome-cd.  

I am using default gnopernicus magnification settings, i.e. 2x by 2x,
vertical half-screen magnification. I am using GNOME default font size
(11 point I think).

To reproduce: launch gnopernicus (with brlmonitor and speech, and
magnification as above).  Launch gnome-cd.

Place gnopernicus and gnome-cd windows in full view on the left side
of the screen, as far from one another as practical. Move focus in
each application to a button (for instance gnopernicus '4 - minimize'
and gnome-cd 'preferences') Switch focus via Alt-TAB; magnifier will
correctly re-center so that the focussed button is on-screen for each
application as you switch back and forth..

Repeat several times; it doesn't have to be _too_ fast, but I find
that the problem is more likely to happen if you hold the Alt key down
for a long-ish time (1 second?), then press and release TAB very
quickly once, releasing Alt at almost the same time.  The thing that
seems to make the problem more likely is a very short time between the
release of TAB and the release of Alt.  After 5 or 6 times switching
back and forth, eventually things will get out of sync and the
magnifier will stay focussed on the wrong item until another another
focus event occurs due to user action.

Screen resolution is 1024x768 on my system but I doubt this is of any
consequence for this bug.
Comment 4 Adi Dascal 2003-10-30 15:14:25 UTC
I was able to reproduce the bug with gnome-cd and gnome-terminal
applications, inspected by simple-at program.
Event flow proves that sometimes the focused object for gnome-cd and
another accessible application is not well reported.

For instance this is the log in case of making an ALT-TAB to the
Terminal. An event from gnome-cd is reported afterwards even if the
focus (graphically displayed) is on the terminal.

object:visible-data-changed event received
object:visible-data-changed event received
object:visible-data-changed event received
object:visible-data-changed event received
focus: event from Terminal
focus: event from Track editor
object:visible-data-changed event received
object:visible-data-changed event received
object:visible-data-changed event received


Attached to this bug is the test-program that I used and the log that
I obtained.

So IMHO, this is a problem in the way focus events are reported by
at-spi to gnopernicus.

Comment 5 Adi Dascal 2003-10-30 15:16:03 UTC
Created attachment 21059 [details]
Test program
Comment 6 Adi Dascal 2003-10-30 15:19:01 UTC
Created attachment 21060 [details]
Log that I obtained with the test-program inspecting gnome-cd and gnome-terminal (switching between these 2 apps)
Comment 7 bill.haneman 2003-10-30 16:03:21 UTC
OK, so we now know that the root cause of the problem is event
reordering/ordering.

However we know for certain that since these events are coming from
different processes, we cannot fix that issue.

Therefore I think we should look into how we might work around this
bug in gnopernicus (and/or at-spi?).  For instance, if we detect
"skew" between focus events and currently-active window, we could take
appropriate action.  Similarly, in the case you specifically mention
above, it may be that the focus event from the cdplayer is
inappropriate and can be detected and discarded either in gnopernicus
or at-spi.

Another possibility might be that gnopernicus could have an idle
handler or timeout-handler which did a sanity check on last-focussed
object versus FOCUSSED state, and correct any inconsistencies.



Comment 8 korn 2003-10-30 17:24:15 UTC
Would event timestamps solve this problem?  If so, can we introduce 
such a timestamp without making an API change (I don't expect so, but 
I have to ask...)?
Comment 9 bill.haneman 2003-10-30 18:58:36 UTC
I seriously doubt that timestamps would help here.  The timing/order
uncertainty is not just in the delivery, it's in the initiation of
notification by the application/toolkit itself.  Therefore the events
might well have timestamps that correspond to the order Adi reports,
i.e. timestamps would also be reversed.
Comment 10 Adi Dascal 2003-11-07 12:33:23 UTC
Event ordering is to be done in at-spi (at-spi has to provide a good
event flow). Gnopernicus' job is to filter events.

Bill said: "Therefore I think we should look into how we might work
around this bug in gnopernicus (and/or at-spi?).  For instance, if we
detect "skew" between focus events and currently-active window, we
could take appropriate action.  Similarly, in the case you
specifically mention above, it may be that the focus event from the
cdplayer is inappropriate and can be detected and discarded either in
gnopernicus or at-spi"
Why should gnopernicus workaround?? The "skew" could be detected in
at-spi, too, as Bill says at the end of the phrase.

In my opinion this is an at-spi bug.
Comment 11 bill.haneman 2003-11-10 20:54:36 UTC
I do not actually believe that this is something we should fix in
at-spi; it's in the final analysis not fixable there.

at-spi cannot reorder the events without causing latency problems. 
Likwise, at-spi cannot suppress the events without breaking clients
who expect to get the events (without depending on the order).

We have always said that at-spi cannot guarantee the order of event
delivery.  So your assertion that at-spi must do event ordering isn't
correct.
Comment 12 bill.haneman 2003-11-10 20:56:37 UTC
changing summary back since it describes the symptom we wish to
address.  We know that the underlying cause is in the event ordering,
but the event ordering issue cannot be solved in the general case. 
Therefore we must focus on symptomatic relief.
Comment 13 remus draica 2003-11-13 13:47:07 UTC
Created attachment 21408 [details] [review]
proposed patch
Comment 14 remus draica 2003-11-13 13:49:00 UTC
Bill, can you check if the patch above solves problem described by you?
Comment 15 bill.haneman 2003-11-13 15:39:45 UTC
Hi Remus:

This patch appears to fix the problem, glad it was so simple.  However
if the problem appears again we should reopen the bug (since it's a
race condition there's a possibility that the fix won't work in all
situations).  It definitely seems to help however.  Thanks!
Comment 16 bill.haneman 2003-11-14 12:58:32 UTC
Remus, if you apply the patch I suggest that we close this bug.  If
the problem re-occurs we can reopen it.  Thanks for the patch.
Comment 17 bill.haneman 2003-11-17 17:02:27 UTC
Please apply this patch and close this bug, unless there is some
reason you are aware of for not applying the patch.  Thanks!
Comment 18 remus draica 2003-11-18 12:49:55 UTC
Patch committed to CVS head and gnome-2-4 branch.
Comment 19 remus draica 2003-11-19 09:08:00 UTC
The patch has a serious side effect. Because many objects have no
FOCUSED state when focus event is emmitted, gnopernicus behaviour is
very bad. A lot of focus events are now rejected.

I see 2 solutions here:
 1. revert the patch, but in some cases gnopernicus will report a
wrong focused object.
 2. all objects should contain FOCUSED state when focus event is emmitted.

Any ideeas?
Comment 20 bill.haneman 2003-11-19 14:24:30 UTC
all objects should have FOCUSSED state when focus is emitted.  Please
file bugs for cases where they do not have this state.

Comment 21 bill.haneman 2003-11-19 14:26:27 UTC
can you list some known cases where objects emitting 'focus' are not
FOCUSSED ?

thanks
Comment 22 remus draica 2003-11-19 15:43:08 UTC
I opened the bug 127400, so I close this bug.