From 2ebf1bf35928e35ded6e38df64dee7aa578ae3c7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 18 Oct 2013 02:27:33 +0200 Subject: MouseEvent: Clarify button-number and pointer-ID relation incl. case 'no button/pointer', i.e. button == 0, pointer-ID == -1 doPointerEvent: - allow id==-1 -> button==0 for no button, i.e. mouse move doMouseEvent: - keep button 0 value, i.e. map to pointer-ID -1 --- src/newt/classes/jogamp/newt/WindowImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/newt/classes/jogamp') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 3f59da553..a35d89408 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2381,8 +2381,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int x, int y, short button, final float[] rotationXYZ, float rotationScale) { if( 0 > button || button > MouseEvent.BUTTON_COUNT ) { throw new NativeWindowException("Invalid mouse button number" + button); - } else if( 0 == button ) { - button = 1; } doPointerEvent(enqueue, wait, constMousePointerTypes, eventType, modifiers, 0 /*actionIdx*/, new short[] { (short)(button-1) }, @@ -2467,7 +2465,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param eventType * @param modifiers * @param pActionIdx index of multiple-pointer arrays representing the pointer which triggered the event - * @param pID Pointer ID for each pointer (multiple pointer). We assume consecutive pointerIDs starting w/ 0. + * @param pID Pointer ID for each pointer (multiple pointer). We assume consecutive pointerIDs starting w/ 0. + * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. * @param pX X-axis for each pointer (multiple pointer) * @param pY Y-axis for each pointer (multiple pointer) * @param pPressure Pressure for each pointer (multiple pointer) @@ -2513,7 +2512,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final short button; { final int b = id + 1; - if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { + if( 0 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { // we allow id==-1 -> button==0 for no button, i.e. mouse move button = (short)b; } else { button = com.jogamp.newt.event.MouseEvent.BUTTON1; @@ -2580,7 +2579,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); } - modifiers |= InputEvent.getButtonMask(button); // Always add current button to modifier mask (Bug 571) + final int buttonMask = InputEvent.getButtonMask(button); + modifiers |= buttonMask; // Always add current button to modifier mask (Bug 571) modifiers |= pState1.buttonPressedMask; // Always add currently pressed mouse buttons to modifier mask if( isPointerConfined() ) { @@ -2609,7 +2609,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( 0 >= pPressure[0] ) { pPressure[0] = maxPressure; } - pState1.buttonPressedMask |= InputEvent.getButtonMask(button); + pState1.buttonPressedMask |= buttonMask; if( 1 == pCount ) { if( when - pState1.lastButtonPressTime < MouseEvent.getClickTimeout() ) { pState1.lastButtonClickCount++; @@ -2638,7 +2638,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); } - pState1.buttonPressedMask &= ~InputEvent.getButtonMask(button); + pState1.buttonPressedMask &= ~buttonMask; if( null != movePositionP0 ) { movePositionP0.set(0, 0); } -- cgit v1.2.3