summaryrefslogtreecommitdiff
path: root/java/awt/LightweightDispatcher.java
diff options
context:
space:
mode:
authorGuilhem Lavaux <guilhem@kaffe.org>2006-06-06 20:30:07 +0000
committerGuilhem Lavaux <guilhem@kaffe.org>2006-06-06 20:30:07 +0000
commit56c5b96a2d3754736d13eebb73270fb8f925301d (patch)
tree8f13d21d9dadf9810d11284977ed98a0a5c41868 /java/awt/LightweightDispatcher.java
parent68d82e8b935385c52f40123538e6e5b0dad7dbc9 (diff)
downloadclasspath-56c5b96a2d3754736d13eebb73270fb8f925301d.tar.gz
2006-06-06 Guilhem Lavaux <guilhem@kaffe.org>
* Merged HEAD as of 2006-05-08.
Diffstat (limited to 'java/awt/LightweightDispatcher.java')
-rw-r--r--java/awt/LightweightDispatcher.java66
1 files changed, 46 insertions, 20 deletions
diff --git a/java/awt/LightweightDispatcher.java b/java/awt/LightweightDispatcher.java
index 2f254bccf..860646402 100644
--- a/java/awt/LightweightDispatcher.java
+++ b/java/awt/LightweightDispatcher.java
@@ -129,7 +129,8 @@ class LightweightDispatcher
{
Window window = (Window) ev.getSource();
Component target = window.findComponentAt(ev.getX(), ev.getY());
- if (target != null && target.isLightweight())
+ target = findTarget(target);
+ if (target == null || target.isLightweight())
{
// Dispatch additional MOUSE_EXITED and MOUSE_ENTERED if event target
// is different from the last event target.
@@ -145,13 +146,16 @@ class LightweightDispatcher
ev.getClickCount(), ev.isPopupTrigger());
lastTarget.dispatchEvent(mouseExited);
}
- Point p = AWTUtilities.convertPoint(window, ev.getX(), ev.getY(),
- target);
- MouseEvent mouseEntered =
- new MouseEvent(target, MouseEvent.MOUSE_ENTERED, ev.getWhen(),
- ev.getModifiers(), p.x, p.y, ev.getClickCount(),
- ev.isPopupTrigger());
- target.dispatchEvent(mouseEntered);
+ if (target != null)
+ {
+ Point p = AWTUtilities.convertPoint(window, ev.getX(), ev.getY(),
+ target);
+ MouseEvent mouseEntered =
+ new MouseEvent(target, MouseEvent.MOUSE_ENTERED, ev.getWhen(),
+ ev.getModifiers(), p.x, p.y, ev.getClickCount(),
+ ev.isPopupTrigger());
+ target.dispatchEvent(mouseEntered);
+ }
}
switch (ev.getID())
@@ -182,21 +186,43 @@ class LightweightDispatcher
lastTarget = target;
- Point targetCoordinates =
- AWTUtilities.convertPoint(window, ev.getX(), ev.getY(), target);
- int dx = targetCoordinates.x - ev.getX();
- int dy = targetCoordinates.y - ev.getY();
- ev.translatePoint(dx, dy);
- ev.setSource(target);
- target.dispatchEvent(ev);
-
- // We reset the event, so that the normal event dispatching is not
- // influenced by this modified event.
- ev.setSource(window);
- ev.translatePoint(-dx, -dy);
+ if (target != null)
+ {
+ Point targetCoordinates =
+ AWTUtilities.convertPoint(window, ev.getX(), ev.getY(), target);
+ int dx = targetCoordinates.x - ev.getX();
+ int dy = targetCoordinates.y - ev.getY();
+ ev.translatePoint(dx, dy);
+ ev.setSource(target);
+ target.dispatchEvent(ev);
+ // We reset the event, so that the normal event dispatching is not
+ // influenced by this modified event.
+ ev.setSource(window);
+ ev.translatePoint(-dx, -dy);
+ }
+
return true;
}
else
return false;
}
+
+ /**
+ * Finds the actual target for a mouseevent, starting at <code>c</code>.
+ * This searches upwards the component hierarchy until it finds a component
+ * that has a mouselistener attached.
+ *
+ * @param c the component to start searching from
+ *
+ * @return the actual receiver of the mouse event
+ */
+ private Component findTarget(Component c)
+ {
+ Component target = c;
+ while (target != null && target.getMouseListeners().length == 0)
+ {
+ target = target.getParent();
+ }
+ return target;
+ }
}