This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix to java.awt.Container$LightweightDispatcher


Here is a patch that fixes a couple things in the helper class
LightweightDispatcher in java.awt.Container.  It adds an extra check to
avoid dispatching a MOUSE_ENTERED event twice, and it translates the
mouse event's (x,y) location for the event target.

-David Jee


2004-01-19  David Jee  <djee@redhat.com>

        * java/awt/Container.java
        (LightweightDispatcher.handleEvent): Add an extra check to avoid
        dispatching MOUSE_ENTERED event twice. Translate the point for
        the mouse event target before dispatching the event.


Index: java/awt/Container.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/Container.java,v
retrieving revision 1.30
diff -u -r1.30 Container.java
--- java/awt/Container.java	17 Jan 2004 00:01:59 -0000	1.30
+++ java/awt/Container.java	19 Jan 2004 18:35:54 -0000
@@ -1633,8 +1633,18 @@
         MouseEvent me = (MouseEvent) e;
         acquireComponentForMouseEvent (me);
 
-        if (mouseEventTarget != null)
+        // Avoid dispatching a ENTERED or EXITED event twice
+        if (mouseEventTarget != null
+            && e.getID() != MouseEvent.MOUSE_ENTERED)
           {
+            // Calculate point translation for the event target.
+            // We use absolute location on screen rather than relative
+            // location because the event target might be a nested child.
+            Point parentLocation = nativeContainer.getLocationOnScreen();
+            Point childLocation = mouseEventTarget.getLocationOnScreen();
+            me.translatePoint(parentLocation.x - childLocation.x,
+                              parentLocation.y - childLocation.y);
+
             Component oldSource = (Component) me.getSource ();
             me.setSource (mouseEventTarget);
             mouseEventTarget.dispatchEvent (me);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]