summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schuster <theBohemian@gmx.net>2006-05-16 22:57:25 +0000
committerRobert Schuster <theBohemian@gmx.net>2006-05-16 22:57:25 +0000
commit037742692fff60cd24134ec3805d5033c8aa01cd (patch)
treeefda244b4f876db4b25b484ca169265bb43c8cf1
parent3900dd4bad75a5319e439927136bd346d1fd9f0e (diff)
downloadclasspath-037742692fff60cd24134ec3805d5033c8aa01cd.tar.gz
2006-05-17 Robert Schuster <robertschuster@fsfe.org>
Fixes PR27626. * java/awt/LightweightDispatcher.java: (handleMouseEvent): Moved assignment into switch-block, added notes.
-rw-r--r--ChangeLog6
-rw-r--r--java/awt/LightweightDispatcher.java26
2 files changed, 25 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index fcdfca243..e9ffdf220 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-05-17 Robert Schuster <robertschuster@fsfe.org>
+
+ Fixes PR27626.
+ * java/awt/LightweightDispatcher.java:
+ (handleMouseEvent): Moved assignment into switch-block, added notes.
+
2006-05-16 Lillian Angel <langel@redhat.com>
* javax/swing/text/StyleContext.java:
diff --git a/java/awt/LightweightDispatcher.java b/java/awt/LightweightDispatcher.java
index 860646402..89a4c04cc 100644
--- a/java/awt/LightweightDispatcher.java
+++ b/java/awt/LightweightDispatcher.java
@@ -121,7 +121,7 @@ class LightweightDispatcher
/**
* Handles all mouse events that are targetted at toplevel containers
* (Window instances) and dispatches them to the correct lightweight child.
- *
+ *
* @param ev the mouse event
* @return whether or not we found a lightweight that handled the event.
*/
@@ -146,6 +146,7 @@ class LightweightDispatcher
ev.getClickCount(), ev.isPopupTrigger());
lastTarget.dispatchEvent(mouseExited);
}
+
if (target != null)
{
Point p = AWTUtilities.convertPoint(window, ev.getX(), ev.getY(),
@@ -161,12 +162,16 @@ class LightweightDispatcher
switch (ev.getID())
{
case MouseEvent.MOUSE_PRESSED:
- dragTarget = target;
+ lastTarget = dragTarget = target;
break;
case MouseEvent.MOUSE_RELEASED:
if (dragTarget != null)
- target = dragTarget;
- dragTarget = null;
+ {
+ target = dragTarget;
+ dragTarget = null;
+ }
+
+ lastTarget = target;
break;
case MouseEvent.MOUSE_CLICKED:
// When we receive a MOUSE_CLICKED, we set the target to the
@@ -174,18 +179,24 @@ class LightweightDispatcher
// This is necessary for the case when the MOUSE_RELEASED has
// caused the original target (like an internal component) go
// away.
+ // This line is the reason why it is not possible to move the
+ // 'lastTarget = target' assignment before the switch-statement.
target = lastTarget;
break;
case MouseEvent.MOUSE_DRAGGED:
+ // We consider only dragTarget for redispatching the event still
+ // we have to act in a way that the newly found target component
+ // was handled.
+ lastTarget = target;
target = dragTarget;
break;
default:
- // Do nothing in other cases.
+ // Only declare current target as the old value in all other
+ // cases.
+ lastTarget = target;
break;
}
- lastTarget = target;
-
if (target != null)
{
Point targetCoordinates =
@@ -195,6 +206,7 @@ class LightweightDispatcher
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);