Committing to hopper and tiger.
Reassigning to Russia.
Name: rpR10076 Date: 11/16/2001
commit to hopper and tiger
Name: dmR10075 Date: 02/13/2002
On Solaris, when user presses Alt-Tab key combination WM may switch
focus to another window. When it performs the switch it usually sends
the following sequence of events:
- FocusOut NotifyGrab, FocusOut NofityWhileGrabbed to the currently
- FocusIn NotifyWhileGrabbed, FocusIn NotifyUngrab to the new acive
In native code, in awt_MToolkit.c:processOneEvent and
awt_TopLevel.c:shellEH we skip all such events and doens't dispatch
them to Java. Therefor when user presses Alt-tab no event is generated
To fix this we at first should add code which will process these
However, it was found that some other user actions may generate this
kind of event (not NotifyNormal) when user doesn't expect any events
would be generated to Java. These cases are: selecting menu item in
main menu, popping up/down of popup menu, selecting the item in
choice's list, clicking on menu bar on the space where there is no
items. All such a cases generate
NotifyWhileGrabbed/NotifyGrab/NotifyUngrab event in different
sequences so we should filter them and distinguish the source of such
event - was they generated as the result of Alt-tab switching or not.
Two approaches can used to implement this.
1. Try to detect the opposite window of every native focus
When user switches by Alt-tab the opposite window is either another
Frame/Window or none if it is the transfer outside of Java
application. If he presses menu, popup menu, choice it is either
GrabShell or MenuShell. So, by this we can guaranteely detect the case
of user actions and distinguish them.
However, the actual implementation looks very complicated and so it
was decided to not use this if another approach will work as good as
2. Mark the moment when the menu/popup menu/choice pops up/down and
skip the following events according to this mark.
We install the callbacks for popup/popdown events of the appropriate
shells and set some flags in native code. When the events arrive we
check the flags and decide whether or not to allow it to be processed.
Implementation of this approach looks more simple and safe so it was
decided to use it.
Verified using SwingSet2 demo with Hopper b14.