summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-04-27 03:53:41 +0200
committerSven Gothel <[email protected]>2012-04-27 03:53:41 +0200
commit8b0aa0e7653f74e713880e77f9afbe59caff38f0 (patch)
tree56d2224c4650a38e6ef4c7beaa5461c8d09948d2 /src
parentbe59d561fd6ab8aa659e85cd962d38fffd1acb0a (diff)
Bug 556: Newt Mouse Synthetic Drag Event: Clear state if mouse enters/leaves window.
Since we cannot guarantee to have the pressed button information when receiving the mouse move event, we synthesize the dragged event (move while mouse button pressed). To simplify the situation and have a compromise, we clear the mouse pressed states when mouse enters or leaves the window to remove the dragged events at re-entering. This seems more sensible, since dragging after re-entering the mouse shall not be expected.
Diffstat (limited to 'src')
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 3ceb5c772..004e73983 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -2025,6 +2025,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
x = Math.min(Math.max(x, 0), getWidth()-1);
y = Math.min(Math.max(y, 0), getHeight()-1);
mouseInWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED;
+ lastMousePressed=0; // clear state
+ mouseButtonPressed=0; // clear state
}
if(x<0||y<0||x>=getWidth()||y>=getHeight()) {
return; // .. invalid ..
@@ -2034,15 +2036,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+lastMousePosition);
}
long when = System.currentTimeMillis();
+ MouseEvent eEntered = null;
if(eventType == MouseEvent.EVENT_MOUSE_MOVED) {
if(!mouseInWindow) {
mouseInWindow = true;
- MouseEvent e = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, this, when,
- modifiers, x, y, lastMouseClickCount, button, 0);
- if(DEBUG_MOUSE_EVENT) {
- System.err.println("doMouseEvent: synthesized MOUSE_ENTERED event: "+e);
- }
- doEvent(enqueue, wait, e);
+ eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, this, when,
+ modifiers, x, y, lastMouseClickCount, button, 0);
+ lastMousePressed=0; // clear state
+ mouseButtonPressed=0; // clear state
} else if(lastMousePosition.getX() == x && lastMousePosition.getY()==y) {
if(DEBUG_MOUSE_EVENT) {
System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+lastMousePosition);
@@ -2102,7 +2103,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
} else {
e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, 0);
}
- doEvent(enqueue, wait, e);
+ if(null!=eEntered) {
+ if(DEBUG_MOUSE_EVENT) {
+ System.err.println("doMouseEvent: synthesized MOUSE_ENTERED event: "+eEntered);
+ }
+ doEvent(enqueue, wait, eEntered);
+ }
+ doEvent(enqueue, wait, e); // actual mouse event
if(null!=eClicked) {
if(DEBUG_MOUSE_EVENT) {
System.err.println("doMouseEvent: synthesized MOUSE_CLICKED event: "+eClicked);