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 108664 - Unwanted 'window:activate' events occur when use SPI_KEYLISTENER_ALL_WINDOWS for catch a keyevents.
Unwanted 'window:activate' events occur when use SPI_KEYLISTENER_ALL_WINDOWS ...
Status: RESOLVED FIXED
Product: at-spi
Classification: Platform
Component: registry
1.1.x
Other Linux
: High major
: ---
Assigned To: padraig.obriain
padraig.obriain
Depends on:
Blocks: 116998 118777
 
 
Reported: 2003-03-18 11:09 UTC by ps
Modified: 2005-01-13 11:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch to workaround/fix this problem, eliminates spurious window activation/deact (7.69 KB, patch)
2003-04-24 13:29 UTC, bill.haneman
none Details | Review
Updated at-spi patch (8.73 KB, patch)
2003-05-13 12:53 UTC, padraig.obriain
none Details | Review
Modification for gnopernicus to test a new at-spi. (871 bytes, patch)
2003-05-19 08:21 UTC, ps
none Details | Review
log generated by at-spi-registryd when using mouse to navigate windows (2.81 KB, text/plain)
2003-05-29 13:12 UTC, bill.haneman
  Details
log generated by at-spi-registry when doing same window activation via keyboard (5.21 KB, text/plain)
2003-05-29 13:14 UTC, bill.haneman
  Details
new patch, same as previous but with new window-listener-test.c prog. (10.54 KB, patch)
2003-05-29 13:58 UTC, bill.haneman
none Details | Review
output of window-listener-test showing interleaved "activate" events during keynav. (444 bytes, text/plain)
2003-05-29 13:59 UTC, bill.haneman
  Details
window-listener-test.c source (2.83 KB, text/plain)
2003-05-29 14:42 UTC, bill.haneman
  Details
at-spi patch as applied. (11.45 KB, patch)
2003-06-11 11:41 UTC, bill.haneman
none Details | Review
Proposed patch for gail (10.57 KB, patch)
2003-07-02 16:00 UTC, padraig.obriain
none Details | Review
Test patch for event-listener-test.c (6.97 KB, patch)
2003-08-12 09:47 UTC, ps
none Details | Review
Proposed at-spi-registryd patch (7.59 KB, patch)
2003-08-28 15:25 UTC, padraig.obriain
none Details | Review

Description ps 2003-03-18 11:09:12 UTC
Description:
 Run gnopernicus. Set speech in general settings. Move in menu of
gnopernicus whit arrows keys. Window switching event occure when it move
between a widgets.

Gnopernicus use SPI_KEYLISTENER_ALL_WINDOWS flag which represent a global
listener. 

retval = SPI_registerAccessibleKeystrokeListener (ke_key_listener,
				      (AccessibleKeySet *) ke_key_keyset,
				      SPI_KEYMASK_UNMODIFIED,
				      (gulong) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ),
				      SPI_KEYLISTENER_ALL_WINDOWS);
    ke_print_register_return_value (retval, "(U)");

Using this flags when the registered key events occures a window switch
event signaled. 
If you use SPI_KEYLISTENER_NOSYNC | SPI_KEYLISTENER_CANCONSUME flags istead
of SPI_KEYLISTENER_ALL_WINDOWS flag, the window switching event doesn't
occure. 
Observed that if press any registered key an application lose focus and
refocused.
It is a serriosly bug in at-spi.
Comment 1 bill.haneman 2003-03-25 17:44:28 UTC
I am very doubtful that this is new behavior.  And strictly speaking,
it's not a bug.  It's an artifact of the way the X server handles
keygrabs; keygrabs produce a focus-out followed by focus-in event.

It may not be feasible to work around this in at-spi or gail, and it
may be that formerly gtk+ detected and worked around this internally,
and that the behavior has changed.  However I suspect that this may
well have been the existing behavior all along.

Comment 2 padraig.obriain 2003-03-26 10:01:15 UTC
I very much doubt that the behavior of gtk+ has changed in this area
recently.
Comment 3 bill.haneman 2003-04-10 12:31:26 UTC
I propose that we try a fix something like this:

* we listen for window event as we do currently, but 
  rather than emitting them immediately, we queue them until
  either:

   * a keygrab becomes active, in which case we discard
     the pending deactivate event; OR
   * another event enters the dispatch queue, in which case we
     emit both events; OR
   * the event times out and we emit it.

this will prevent event reordering since we'll always emit deactivate
events if another event comes in before a keygrab becomes active. 
We'll need to similarly ignore window:activate events that come from
the already-active window.

So, the only case in which we'll emit the deactivate event for the
'keygrab' case is the race condition in which a second event is
emitted in between the gtk focus-out event on the window, and the
activation of the X grab.  We can do an immediate check on the X event
queue on receipt of window:deactivate to reduce the likelihood of that
race occurring, which should be nonfatal anyway, it just produces a
little "noise" in terms of very rare emission of spurious "out/in"
pairs for windows.

I don't see a way to eliminate this race totally, offhand; but the
events that might trigger it are likely to be "real" context switches
and therefore associated with valid changes of input focus.

Comment 4 bill.haneman 2003-04-24 13:29:12 UTC
Created attachment 15974 [details] [review]
patch to workaround/fix this problem, eliminates spurious window activation/deact
Comment 5 bill.haneman 2003-04-24 13:34:10 UTC
I attach a patch for this bug; it contains some diagnostic output that
should be 'shut up' before a CVS commit.

The attached patch suppresses window:deactivate/window:activate pairs
that are a result of "focus flashing" from any kind of passive
keygrab/ungrab, unless more than 100 ms elapses between the events. 
It also suppresses object:state-changed:active and
object:state-changed:focussed events that indicate loss of
focus/active status due to the same events.  However it does *not*
suppress the subsequent "object:state-changed:focussed/active" events
that indicate the return of object focus.  I recommend that at-spi
clients detect and ignore "focus' and 'object:state-changed:focussed'
and 'object:state-changed:active' events that are redundant, i.e. they
come from the most-recently-active or focussed object and thus do not
represent a state transition.  There are probably cases which result
in such duplicate focus events anyhow, so at clients should be smart
enough to ignore such redundant information.

Comment 6 ps 2003-05-06 09:10:11 UTC
Hi Bill
I tested your patch. 
I used last stack from 23 april, and the patch is applied for at-spi
version from 2_05_2003. And this version of at-spi is installed over
the stack.
The listener registration is the following in libke.c (gnopernicus)

retval = SPI_registerAccessibleKeystrokeListener (ke_key_listener,
				      (AccessibleKeySet *) ke_key_keyset,
				      SPI_KEYMASK_UNMODIFIED,
				      (gulong) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ),

				      SPI_KEYLISTENER_ALL_WINDOWS);

I printed the events which are arriveing from at-spi. This printing is
filtered that print only non "object:" events. Moving in main menu of
gnopernicus the following message are printed. You said that the
window:deactivate event is surpressed. 

AT-SPI Event:window:deactivate
AT-SPI Event:focus:
AT-SPI Event:window:switch
AT-SPI Event:focus:
AT-SPI Event:window:deactivate
AT-SPI Event:focus:
AT-SPI Event:window:switch
AT-SPI Event:focus:
AT-SPI Event:window:deactivate
AT-SPI Event:focus:
AT-SPI Event:window:switch
AT-SPI Event:focus:
AT-SPI Event:window:deactivate
AT-SPI Event:window:switch
AT-SPI Event:focus:

And the window switch event occure some times. To reproduce it you can
move fast between a options. Or move between an options and after all
move wait until gnopernicus finish the speaking. And at the next move
the gnopernicus will say again the "window switch event", and the
printed messages are the same with the above messages.

Other problem what I observed, using the numpad. Now the keyset for
numpad keys is registered with ALL_WINDOWS. When I want to change the
layer some times is the focus is losed. The caret for focus is not
displayed.
Comment 7 bill.haneman 2003-05-06 15:58:11 UTC
bumping up priority as this should be a stopper (blocks, or requires
significant workarounds from, gnopernicus)
Comment 8 padraig.obriain 2003-05-08 12:51:05 UTC
I am running gnopernicus from CVS HEAD on Solaris and I do not
understand Paul's comments.

What process is outputting the messages "AT-SPI Event:..."?
Do I need to change gnopernicus to see the problem?
Comment 9 ps 2003-05-08 13:42:35 UTC
Padraig: 
Yes you need to change gnopernicus to see this output. 
I modified my gnopernicus to test the Bill patch. I modified in 
/kbd_mouse/libke/libke.c st USE_ALL_WINDOWS defined, and I modified 
report_event funtion in SRLow to print the incommind at-spi events. 
This changes are not on CVS, and it has not a patch for this. This 
is only for my test. 
 
Comment 10 padraig.obriain 2003-05-09 08:28:23 UTC
When I try to run gnopernicus srcore exits. Do I need to fix that
before I can investigate this bug?

How do you move in main window of gnopernicus? Do you press some keys
on the keyboard?

anymachine:/export/home/padraigo/HEAD/gnopernicus/gnopi 118 %
./gnopernicus
Bonobo accessibility support initialized
GTK Accessibility Module initialized
Atk Accessibilty bridge initialized

**********************
* SCREEN READER CORE *
**********************

Bonobo accessibility support initialized
GTK Accessibility Module initialized
Atk Accessibilty bridge initialized

(srcore:4409): gnopernicus-WARNING **: Exception "Unknown CORBA
exception id: 'IDL:omg.org/CORBA/COMM_FAILURE:1.0'" occured at line
374.

(srcore:4409): gnopernicus-WARNING **: Exception "Unknown CORBA
exception id: 'IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0'" occured at
line 429.

(gnopernicus:4396): gnopernicus-WARNING **: srcore exited.
Comment 11 ps 2003-05-09 10:59:46 UTC
Padraig: 
My word usage was wrong. Navigating in main menu option, not a 
moving in main menu.  
Do you have installed  festival or FreeTTS speech drivers on your 
system? 
 
Comment 12 padraig.obriain 2003-05-09 11:05:57 UTC
I have not installed either. Do I need them for this bug?
Comment 13 ps 2003-05-09 11:21:35 UTC
Probabaly the problem is that the stack cointains a servers for 
these drivers. Please check ? (/opt/gnome-2.2/lib/bonobo/servers). 
Leave only the GNOME_Speech_Synthesiser_...ViaVoice.server. Delete 
all speech servers which are not installed on your system. 
Comment 14 bill.haneman 2003-05-09 11:48:35 UTC
Hmm, if you have no working speech drivers, and this causes
gnopernicus to die, then there's a gnopernicus bug IMO.
Comment 15 bill.haneman 2003-05-09 11:51:14 UTC
Padraig definitely doesn't have ViaVoice.  Probably he has no TTS at all.
Comment 16 padraig.obriain 2003-05-09 12:55:50 UTC
Correction: I am using Clifton's GNOME 2.2 build for Solaris which 
has a FreeTTS speech driver.
Comment 17 padraig.obriain 2003-05-13 12:53:25 UTC
Created attachment 16493 [details] [review]
Updated at-spi patch
Comment 18 padraig.obriain 2003-05-13 12:54:21 UTC
Paul,

Please try the updated at-spi patch. If this does not give you the
results you require please send me the changes you made to gnopernicus
for testing.
Comment 19 ps 2003-05-14 15:52:39 UTC
Padraig: I will test the patch. 
Comment 20 bill.haneman 2003-05-15 13:36:34 UTC
fix is in registryd, so changing component to "registry".
Comment 21 bill.haneman 2003-05-16 18:33:59 UTC
padraig, this version of the patch seems not to be correct.  It is
consuming window:activate events that occur due to metacity keyboard
navigation (at least on my system).

To test: Alt-TAB (releasing in between TAB presses, to make sure that
the activate signal is emitted).  You will see (if you either turn on
SPI_EVENT_DEBUG or run a client that listens for window events) that
the activate events don't generally get emitted, though the deactivate
events (oddly) do.

Comment 22 bill.haneman 2003-05-16 19:15:44 UTC
please let me know if you see this; maybe it's just my system that's
broken for some reason!
Comment 23 ps 2003-05-19 08:19:50 UTC
Hi: 
It seem to be not correct results. I tasted it whit gnopernicus and 
I noticed for example when I navigated between an options the 
windows switching event occure. I will attach the patch for 
gnopernicus, whit I tested the new at-spi patch, if you has speech, 
you will hear that the "windows switch" events.  
Comment 24 ps 2003-05-19 08:21:17 UTC
Created attachment 16623 [details] [review]
Modification for gnopernicus to test a new at-spi.
Comment 25 padraig.obriain 2003-05-19 11:43:24 UTC
Bill,

I do not see the problem you describe. Does your use of the word
generally mean that it sometimes works correctly?

Paul,

I have applied your gnopernicus patch. I am seing the following
message being output by at-spi-registryd:

*** Message: Could not complete key grab: grab already in use.

I need to determine what is causing this.
Comment 26 bill.haneman 2003-05-19 11:54:19 UTC
Padraig: the message "grab already in use" means that paul is
registering for some keyevent combination which we can't honor. 
Probably either an ALLKEYS, or for a modifier/key combination that's
already bound by some other grab client such as metacity.

We cannot support ALL_WINDOWS listeners for such key combinations;
clients must detect this condition and use a different key combination.
Comment 27 bill.haneman 2003-05-19 11:55:37 UTC
Padraig: I take it you are referring to an email from me about the
window events?  I can reproduce the problem 100% 
of the time on my system; I never (with your patch) get
deactivate/activate pairs when switching windows with Alt-TAB.
Comment 28 padraig.obriain 2003-05-19 12:30:29 UTC
Paul,

What do you use to navigate between the options? Is it the arrow keys?
Comment 29 ps 2003-05-19 12:41:24 UTC
Padraig: 
Yes, I use a arrow keys to navigate. 
Comment 30 padraig.obriain 2003-05-19 13:52:26 UTC
Paul,

I do not see the problem you have reported. Can you send me the outpit
from gnopernicus. Also please run at-spi-registryd in a terminal so
you can get its putput also.
Comment 31 padraig.obriain 2003-05-19 13:59:08 UTC
The message grab already in use comes from attempting to grab a
keycode of 0. This happens on Solaris because XK_Alt_R and
XK_Control_R do not have keycodes. I will update
deviceeventcontroller.c to not atttmpt to grab a keycode with value of
0.
Comment 32 padraig.obriain 2003-05-19 13:59:57 UTC
Bill,

I cannot reproduce the problem you describe. Can run at-spi-registryd
in a terminal window so I can see what output it is generating.
Comment 33 bill.haneman 2003-05-19 14:09:43 UTC
hi padraig: could you log an Xserver bug about this?  All keys should
have (non-zero) keycodes.
Comment 34 bill.haneman 2003-05-29 13:12:58 UTC
Created attachment 16949 [details]
log generated by at-spi-registryd when using mouse to navigate windows
Comment 35 bill.haneman 2003-05-29 13:14:02 UTC
Created attachment 16950 [details]
log generated by at-spi-registry when doing same window activation via keyboard
Comment 36 bill.haneman 2003-05-29 13:17:24 UTC
about the previous attachments:

(1) your patch was applied, but I removed one of the two "push" and
"pop" fprintfs in each case

(2) nav was between three windows:
(a) - gedit
(b) - gnome-terminal
(c) - xterm (where at-spi-registryd was invoked - inaccessible)

Navigation sequence was (starting state: xterm focussed)

a, b, a, c.

Expected window:events would then be

window:activate [gedit]
window:deactivate [gedit]
window:activate [gnome-terminal]
window:deactivate [gnome-terminal]
window:activate [gedit]
window:deactivate [gedit]
(no activate for xterm since it's inaccessible)

- Bill
Comment 37 bill.haneman 2003-05-29 13:58:11 UTC
Created attachment 16953 [details] [review]
new patch, same as previous but with new window-listener-test.c prog.
Comment 38 bill.haneman 2003-05-29 13:59:07 UTC
Created attachment 16954 [details]
output of window-listener-test showing interleaved "activate" events during keynav.
Comment 39 bill.haneman 2003-05-29 14:03:57 UTC
Hi Padraig:

We may have a metacity problem here, or perhaps gail.. hard to say.
I attach a new patch which includes a new window-listener-test.c and
Makefile.am entry.  This new program shows a problem, visible in the
output log I attached after the patch (above)

When doing keynav, the activate/deactivate pairs from window _from
which we are navigating_ seem to get deferred, and then delivered
after the Alt key is released.  Unfortunately this means that they get
delivered AFTER we've gotten the (current, correct) activate event
from the newly-focussed window, thus:

window:deactivate "old window" [window that was focussed before Alt-]
window:activate "new window" [window focussed by keynav action]
window:activate "old window" [deferred event is sent when Alt is released]
window:deactivate "old window" [and deferred "retraction" of above event]

Ending state, then, appears to the AT that no window is focussed at all.

Comment 40 bill.haneman 2003-05-29 14:42:14 UTC
Created attachment 16955 [details]
window-listener-test.c source
Comment 41 padraig.obriain 2003-05-29 16:16:36 UTC
Bill,

I see what you mean now.

gail could be changed to emit the activate signal on a timer in case
there is a deactivate signal about to come in which case neither
signal is emitted.

I would also have to check what happens with Java applications.

Comment 42 bill.haneman 2003-05-29 16:34:23 UTC
I'm sure you'll agree that avoiding the timer would be better, if
possible - fewer race conditions and latencies.

I'd like to figure out why the events are coming in this order first -
perhaps we can fix the root cause, which would be preferred.
Comment 43 padraig.obriain 2003-05-30 13:07:47 UTC
We can do much about the order in which the events arrive at the
registry daemon as they are coming from different processes. 

However the registry daemon could handle them:

if event is activate and previous activate/deactivate was activate
  cache the event
if event is deactivate
   if have cached activate
      if cached activate and deactivate match 
         discard events
      else
         emit deactivate
         emit cached activate

Comment 44 padraig.obriain 2003-06-04 15:22:33 UTC
I have logged bug 114037 against metacity for the extra focus-in and
focus-out of old focus window when Alt+Tab is used to mode focus.
Comment 45 bill.haneman 2003-06-11 11:41:19 UTC
Created attachment 17442 [details] [review]
at-spi patch as applied.
Comment 46 bill.haneman 2003-06-26 12:55:40 UTC
we discussed this an saw that the current issue is that if the
activate/deactivate pair brackets a context switch such as a focus
event, the events are sent on to the client.

workaround is for the client not to register for ALL_WINDOWS key
notification for 'informational' notifications that cause context
switches, for instance the arrow keys.

I have also put in a minor change to the patch so that focus: events
can be deferred until either a timeout or the receipt of a
window:activate event, this should solve the issue with arrow keys.

Downgrading priority on that basis.

Comment 47 bill.haneman 2003-06-26 23:11:58 UTC
A suggested more general fix, which I think would indeed be a good idea:
* don't emit window:activate/deactivate events from the gtk+ window
  signals anymore, 
* instead listen to the _WM_ACTIVE property which
  metacity sets on the root window; this is what the window switcher
  applet does now in libwnck.
* then we need to use the XWID window ID to associate the _WM_ACTIVE
  notification with a toplevel GtkWindow's accessible.

I think this code would probably need to live in the bridge(s), but
it's conceivable that it could be in registry.c instead.  Putting it
in registry could be a problem for Java apps - likewise Java apps
probably would need to retain the current implementation rather than
listening to _WM properties in the JavaBridge.

The end result of this fix would be that the active window would
always match the on-screen visuals since metacity, libwnck, and at-spi
would be using the same logic/information source for the
window:activate/deactivate state.
Comment 48 bill.haneman 2003-06-30 16:35:50 UTC
lowering severity based on recent tweak since we no longer get fooled
by interleaved focus: events.
Comment 49 padraig.obriain 2003-07-02 16:00:02 UTC
Created attachment 17986 [details] [review]
Proposed patch for gail
Comment 50 padraig.obriain 2003-07-02 16:03:33 UTC
The proposed patch attempts to emit window:deactivate and
window:activate events when _NET_ACTIVE_WINDOW property is changed.

A problem with this patch is  that there is no guarantee that the
registry will receive the deactivate event before the activate event
when switching from window to window.
Comment 51 padraig.obriain 2003-07-03 08:50:24 UTC
A problem with the proposed patch is that notification of focus for
objects within the window mwill occur before the notification of the
active window.
Comment 52 ps 2003-07-08 15:43:17 UTC
I tested the at-spi with the patch for gail. The
window:activate/deactivate events are comming.
Comment 53 padraig.obriain 2003-07-08 15:50:17 UTC
Paul,

What exactly is the test case where you see activate/deactivate
events?
Comment 54 Calum Benson 2003-08-07 16:07:27 UTC
Apologies for spam... marking as GNOMEVER2.3 so it appears on the official GNOME
bug list :)
Comment 55 ps 2003-08-12 09:44:57 UTC
Hi Padraig.
I made a new test with a new stack from 05.08.2003 and whit at-spi
from 10.08.2003 (from CVS Head).
The patch will send. This patch need to applied for event-listener-test.c
The patch will put the code part from keypad-test.c to have a 1 output
for events.

The window activate events are still.
Steps to reproduce:
1. Run gtk-demo/button-boxes
2. run event-listener-test
3. Press NumLock to be active
4. Press Numpads keys
5. Press for more time whitout to release the key e.g. numpad_1 for
few seconds. (4-5 seconds)

I opbtained the following output:
"
keypad KeyEvent ± [keysym 0xffb1] (keycode 87); string=1; time=f54e8f91
(detail) window:deactivate Button Boxes 0 0
context string Button Boxes
object:state-changed:focused Help
object:state-changed:active Button Boxes
(detail) window:activate Button Boxes 0 0
context string Button Boxes
object:state-changed:focused Help
object:state-changed:active Button Boxes

keypad KeyEvent ± [keysym 0xffb1] (keycode 87); string=1; time=f54e8fb3
(detail) window:deactivate Button Boxes 0 0
context string Button Boxes
object:state-changed:focused Help
object:state-changed:active Button Boxes
(detail) window:activate Button Boxes 0 0
context string Button Boxes
object:state-changed:focused Help
"
You can see that the window:active
Comment 56 ps 2003-08-12 09:47:29 UTC
Created attachment 19144 [details] [review]
Test patch for event-listener-test.c
Comment 57 padraig.obriain 2003-08-12 15:15:57 UTC
Paul,

What window has focus when key in number pad is pressed?
Comment 58 ps 2003-08-13 13:18:07 UTC
Padraig

From gtk-demo the button boxes window had a focus.
Comment 59 padraig.obriain 2003-08-13 15:02:45 UTC
Here is the output I see when I press NumLock followed by numpad_1
twice. I do not see the window switch events you see. Are you using
at-spi from CVS HEAD? 

(detail) keyboard:modifiers main 0 16416

keypad KeyEvent Þ [keysym 0xffde] (keycode 93); string=; time=fbcef03e
object:state-changed:focused OK
object:state-changed:active Button Boxes

keypad KeyEvent Þ [keysym 0xffde] (keycode 93); string=; time=fbcf3ebd
object:state-changed:focused OK
object:state-changed:active Button Boxes
Comment 60 padraig.obriain 2003-08-13 15:11:12 UTC
When I ran gtk-demo in a debugger and put a breakpoint in
atk_object_notify_state_change I saw a deactivate event. I will
investigate further.
Comment 61 padraig.obriain 2003-08-13 15:43:01 UTC
Does increasing the value of exit notify timneout help. See line 875
of at-spi/registryd/registry.c?

  registry->exit_notify_timeout = 100;
Comment 62 ps 2003-08-14 06:22:03 UTC
Padraig:   
I need some explanation. "Window switch" event are generated by   
gnopernicus from at-spi "window:activate" event. This event will 
show that the window is losed the focus.   
The title of this bug is not a good. I will change it to "Unwanted  
'window:activate' events occur when use  
SPI_KEYLISTENER_ALL_WINDOWS for catch a keyevents."  
Comment 63 padraig.obriain 2003-08-14 07:38:57 UTC
If a window:activate event for a window occurs within 100 milliseconds
of a window:deactivate event the code in at-spi in registry.c discards 
both the events and does not report them. That is why I asked you to
try increasing the value of 100, to say, 400.
Comment 64 ps 2003-08-15 09:09:19 UTC
For gnopernicus need to not came the window:activate and focus 
events in case when the numpad keys is pressed. These event could do 
gnopernicus tor eport a wrong event or wrong object. 
We tested to changed your proposal, I noticed that if you still 
press the numpad keys the activate events are comming. Other 
observation if not still press the key an activate event aren't 
comming but the focus event does. 
Comment 65 padraig.obriain 2003-08-18 09:12:49 UTC
Paul,

In your comment on August 12, I do not understand step 5. When I press
a key and do not release it for a few seconds I see many KeyPress
events reported.
Comment 66 ps 2003-08-18 09:59:21 UTC
Yesm you have right, and this is what I wanted, because if I hold 
press the key, the appearance of window:activate and focus event is 
greater. If I hold press the event evry time the window activate and 
focus events came.
Comment 67 padraig.obriain 2003-08-18 10:04:48 UTC
Paul,

I do not understand why you see the window:activate events and I do
not. Are you using at-spi from CVS HEAD?
Comment 68 ps 2003-08-18 10:40:32 UTC
Padraig

I use the at-spi from CVS HEAD.
Comment 69 padraig.obriain 2003-08-18 10:52:46 UTC
Please recompile registry.c with SPI_QUEUE_DEBUG defined; see line 28
of registry.c.

Run at-spi-registryd in a terminal by killing at-spi-registryd process
and running

/opt/gnome-2.4/lib/at-spi-registryd
--oaf-activate-iid=OAFIID:Accessibility_Registry:1.0 --oaf-ior-fd=33

Please send me at-spi-registryd output when you get window:activate
events when pressing keys in numpad.
Comment 70 ps 2003-08-19 10:06:56 UTC
Padraig
I have some problem with your description.

I checked out the at-spi from CVS Head. I modified the state of flag
in registry.c I compiled it and I installed in /opt/gnome-2.4.

The specified path( /opt/gnome-2.4/lib) where are the
at-spi-regsitryd, has a at-spi-registryd but it is old. The new
at-spi-registryd  is installed in /opt/gnome-2.4/libexec. I copied
this version in /opt/gnome-2.4/lib.
I put in registry-main the debug message for look if it can to restart
the at-spi-registryd.
I tried to stop the actual at-spi-registryd but I could not do it. I
tried to restart simple whit a command but I looked that the
at-spi-registry still running. What happenening? What I made wrong?

I restarted my systems, but no output show by at-spi. I tried to run
event-listener-test test application but it crashed my sysmtem. 
Can you help me where I made fault?
Comment 71 bill.haneman 2003-08-26 17:07:57 UTC
We need info on this bug in order to proceed further, since we cannot
reproduce it and need your feedback.

Paul, if accessibility is "on" on the desktop, you will find it hard
to kill at-spi-registryd and restart a new one.  Try using xterm, and
typing

ps -elf | grep at-spi-registryd

then for instance if you see at-spi-registryd is process 25433,

type

kill -9 25433; /opt/gnome-2.4/libexec/at-spi-registryd


that way the kill and the restart happen on the same line and,
usually, close enough together in time that a new at-spi-registryd
doesn't get started by some other client first!  Also please pass the
parameters Padraig requested to the at-spi-registryd command above
when you try it.  I hope this helps

- Bill
Comment 72 ps 2003-08-27 06:59:49 UTC
Bill: 
Thanks for help. I could to stop and restart the at-spi-registryd. I 
used the konsole which is not accessible.  
Comment 73 padraig.obriain 2003-08-27 10:15:08 UTC
I have worked with Paul on this and what I see is that most of the
time the window:deactivate, window:activate events arrive in the
at-spi-registryd withinn about .025 seconds. In that case the
window:deactivate and window:activate events are discarded. However, a
lot of events are generated the time difference between the arrival of
the window:deactivate and window:activate events are greater. I have
seen differences of about .5 seconds.

It seems that no matter what value is set for the timeout value for
the registry to wait for a window:activate event after receiving a
window:deactivate event there will always be a chance that the
activate event will not arrive in time.

Is this something we can live with?
Comment 74 bill.haneman 2003-08-27 11:53:33 UTC
If this problem only happens under "high stress", i.e. when a key is
pressed and held for a long time, then in my opinion it is a bug we
can tolerate.  I don't see a good alternative, if we cannot get the
WM_ACTIVE solution to work (due to the fact that WM_ACTIVE messages
may not be sent until after 'focus:' events).

One alternative would be to revive the WM_ACTIVE fix, and in add some
logic which also emits activate/deactivate events in conjunction with
'focus:' if they haven't already been sent, i.e.

* if a focus event is about to be sent, 

* check to see if the widget's toplevel state is active (probably
would need to be a private bitflag of some kind stored in the
GailWidget, for efficiency reasons)

* if the toplevel isn't already active, emit window:activate for it
and set ACTIVE state before emitting the "focus:" event.

That's certainly extra work but it might be possible to produce a
reliable fix that way.  Opinion?

(BTW I don't suggest doing the above new logic for 2.4.0, but we could
try it for 2.4.1).

Paul, I think that the Solaris/number-pad issues with non-ALL_WINDOWS
keylisteners are serious enough that we should change the listeners to
ALL_WINDOWS even if this bug is still occasionally noticeable - at
least, if the bug can be made less common by not using key-repeat.

thanks

Bill
Comment 75 ps 2003-08-27 12:22:50 UTC
Bill, 
The problem not happen only when is under stress. If it use 
ALL_WINDOW flags and the callback function return a TRUE (to eat the 
key), the side effect is arraving. I don't think it is good to use 
ALL_WINDOW flag now. We need to work on this. 
Comment 76 bill.haneman 2003-08-27 16:58:01 UTC
Paul: I think I understand what you mean about "press and hold" the
key.  The key grab from X isn't released until the key-release event
happens, I think, which means that (I think) for consumed ALL_WINDOWS
events, at-spi won't get the focus-in event on the toplevel window
until you release the key.  In most cases this will be too late to
avoid emitting the window:deactivate event from the timer.

Padraig, does this shed some light on the issue?

Comment 77 padraig.obriain 2003-08-28 15:25:45 UTC
Created attachment 19587 [details] [review]
Proposed at-spi-registryd patch
Comment 78 padraig.obriain 2003-08-28 15:27:01 UTC
Paul,

Can you check that the propsoed patch suppresses the unwanted focus
event when window:deactivate and window:activate events are discarded.

Bill,

Can you check the patch for suitability for committal.
Comment 79 ps 2003-08-29 07:44:45 UTC
Hi Padraig
The patch is working. The focus events are not comming. Thank you.

I have a little observation about this keyboard grabbing.
The user if press the numpad keys  under stress or to fast the
activate event are comming sometimes, and the focus is losed
sometimes. I think for this version it is acceptable. It need to fix
these problems too in the future to have a good product.

Other observation:
I don't when it is changed, but I observed the followings.
When we want to made a dnd when the mouse left is still pressed the
numpad events are not cameing. How to reproduce this and more detail I
will send in the mail.
Comment 80 bill.haneman 2003-08-29 13:19:40 UTC
Padraig:

Patch looks good (if a bit fragile; it depends on our getting
state-changed:focus==false events from the currently-focussed widget
in the deactivated window prior to the 'focus:' event's receipt).  

I think we should request permission to apply.

Comment 81 padraig.obriain 2003-09-05 15:14:41 UTC
Patch to at-spi-registryd applied to CVS HEAD.
Comment 82 ps 2003-10-08 08:02:06 UTC
I don't think that this bug had to close, because the patches in
at-spi it solve partially the bug, under stress the bug still yet. It
seems that the gnopernicus users are using the gnopernicus
screen-review and any other command feature under stress, and report
to us that they lose the focus (for e.g. in screen review mode) when
it navigate in windows, and  use a command (numpads). 
I rememberd that Bill said that the correct solving are not in at-spi,
it is in gail and gtk  libreries. Have I right?
I want to leave open this bug until this issue is not fixed totally.
Comment 83 padraig.obriain 2003-10-08 08:37:35 UTC
I would much prefer if a new bug was opened for this problem rather
than reopening a very long bug.
Comment 84 bill.haneman 2003-10-08 11:12:47 UTC
yes.  This bug is closed unless a proven regression from the existing,
admittedly imperfect, fix is demonstrated.

Given that we have a fix when XEvIE is available and as good a
workaround as can be achieved when XEvIE is not available, the bug is
fixed and will remain closed.
Comment 85 bill.haneman 2003-10-08 11:23:18 UTC
Paul: 

To respond to your question, Padraig and I did not find the alternate
solution involving gail and the WM_ACTIVE state workable; in other
words that solution does not appear to be feasible.  We believe that
the current workaround is the best that is achievable with GNOME/gtk+
and X, without an additional X server extension like XEvIE.  Therefore
those aspects of this bug are "NOTGNOME".  We could open a new bug
which only refers to the fact that focus events occur intermittently
under stress, but I do not think it would serve a purpose as that bug
would be unfixable without XEvIE.  Since we have now integrated XEvIE
support (where available) into at-spi, I think we have a complete fix
under those conditions.

If somehow this fix or behavior regresses, that is gets noticeably and
consistently worse due to changes in GNOME, then we should reopen this
bug so that we can fix our workaround.  But I believe that any
remaining problems with our workaround are outside of GNOME's control.
Comment 86 remus draica 2005-01-13 11:03:22 UTC
Reopening because of bug #163755.
Comment 87 remus draica 2005-01-13 11:03:53 UTC
*** Bug 163755 has been marked as a duplicate of this bug. ***
Comment 88 bill.haneman 2005-01-13 11:42:25 UTC
I don't think we should reopen this old bug, see comment #84.