This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gui][PATCH] change tracking of window focus owner
- From: Thomas Fitzsimmons <fitzsim at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Wed, 27 Oct 2004 16:03:33 -0400
- Subject: [gui][PATCH] change tracking of window focus owner
Hi,
I committed this to java-gui-branch. It fixes the tracking of window
focus owners. Instead of being set when a FOCUS_LOST event is received,
they are set when a FOCUS_GAINED event is received.
Tom
2004-10-27 Thomas Fitzsimmons <fitzsim@redhat.com>
* java/awt/DefaultKeyboardFocusManager.java (dispatchEvent):
Track Window focus owner on FOCUS_GAINED events.
Index: java/awt/DefaultKeyboardFocusManager.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/DefaultKeyboardFocusManager.java,v
retrieving revision 1.1.54.11
diff -u -r1.1.54.11 DefaultKeyboardFocusManager.java
--- java/awt/DefaultKeyboardFocusManager.java 27 Sep 2004 15:14:26 -0000 1.1.54.11
+++ java/awt/DefaultKeyboardFocusManager.java 27 Oct 2004 19:59:38 -0000
@@ -171,18 +171,15 @@
if (e.id == FocusEvent.FOCUS_GAINED)
{
- if (((FocusEvent) e).isTemporary ())
- setGlobalFocusOwner (target);
- else
- setGlobalPermanentFocusOwner (target);
- }
- else if (e.id == FocusEvent.FOCUS_LOST)
- {
- // We need to set the window's focus owner here; we can't
- // set it when the window loses focus because by that time
- // the previous focus owner has already lost focus
- // (FOCUS_LOST events are delivered before
- // WINDOW_LOST_FOCUS events).
+ if (! (target instanceof Window))
+ {
+ if (((FocusEvent) e).isTemporary ())
+ setGlobalFocusOwner (target);
+ else
+ setGlobalPermanentFocusOwner (target);
+ }
+
+ // Keep track of this window's focus owner.
// Find the target Component's top-level ancestor.
Container parent = target.getParent ();
@@ -195,9 +192,12 @@
(Window) target : (Window) parent;
Component focusOwner = getFocusOwner ();
- if (focusOwner != null)
+ if (focusOwner != null
+ && ! (focusOwner instanceof Window))
toplevel.setFocusOwner (focusOwner);
-
+ }
+ else if (e.id == FocusEvent.FOCUS_LOST)
+ {
if (((FocusEvent) e).isTemporary ())
setGlobalFocusOwner (null);
else