I wrote a better testcase and attached it to this bug report:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25165 . It shows the problem
was fixed incorrectly.  So I reopened the bug, and now this new patch
fixes it properly and removes the old fix.  I'll close the bug now.  

The problem with the old fix was that processFocusEvent (and, in fact,
processEvent) can be overridden from Component.  Doing so in a test case
showed that on the JDK these methods weren't called with FocusEvents
whose receiving Component and opposite Component were the same.  That
means it had to be tackled before it got to this stage.  That is what is
done now.

2005-11-30  Anthony Balkissoon  <[EMAIL PROTECTED]>

        Fixes bug #25165
        * java/awt/Component.java:
        (processFocusEvent): Don't check if focus opposite is the same as the
        receiving Component, this is now done in dispatchEventImpl.
        (dispatchEventImpl): Don't dispatch FocusEvents whose opposite 
        Components are the same.

On Wed, 2005-11-30 at 13:15 -0500, Anthony Balkissoon wrote:
> This patch fixes PR 25165.  If an attempt is made to give focus to a
> Component that already has it, no FOCUS_LOST and FOCUS_GAINED events
> should be processed.
> 
> 2005-11-30  Anthony Balkissoon  <[EMAIL PROTECTED]>
> 
>       * java/awt/Component.java:
>       (processFocusEvent): Don't dispatch events if the focus opposite is the
>       same as the receiving Component.
> 
> --Tony
> _______________________________________________
> Classpath-patches mailing list
> Classpath-patches@gnu.org
> http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: java/awt/Component.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/Component.java,v
retrieving revision 1.90
diff -u -r1.90 Component.java
--- java/awt/Component.java	30 Nov 2005 18:03:07 -0000	1.90
+++ java/awt/Component.java	30 Nov 2005 19:16:04 -0000
@@ -3019,11 +3019,6 @@
     if (focusListener == null)
       return;
 
-    // Don't dispatch FOCUS_GAINED or FOCUS_LOST events if the opposite
-    // Component is the same as the receiving Component.
-    if (e.getOppositeComponent() == this)
-      return;
-    
     switch (e.id)
       {
         case FocusEvent.FOCUS_GAINED:
@@ -4796,7 +4791,12 @@
   void dispatchEventImpl(AWTEvent e)
   {
     Event oldEvent = translateEvent (e);
-
+    // This boolean tells us not to process focus events when the focus
+    // opposite component is the same as the focus component.
+    boolean ignoreFocus = 
+      (e instanceof FocusEvent && 
+       ((FocusEvent)e).getComponent() == ((FocusEvent)e).getOppositeComponent());
+    
     if (oldEvent != null)
       postEvent (oldEvent);
 
@@ -4827,7 +4827,8 @@
                 break;
               }
           }
-        if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE)
+        if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE
+            && !ignoreFocus)
           processEvent(e);
       }
 
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to