diff options
author | Sven Gothel <[email protected]> | 2013-10-17 20:03:04 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-10-17 20:03:04 +0200 |
commit | 5b96486da0bcd09d5355f89ec551140e508b567c (patch) | |
tree | a744400564c79bf717d75670975557da18eee983 /src/newt/classes | |
parent | 0eceb7df4b04a183a738474c0d7f4be41b6bcc0c (diff) |
Bug 800: Add Windows 7 Touch Event Support for NEWT
Native:
- WindowUserData tracks:
- window size
- mouse inside
- pointer touch-down count
and flags whether multiple-touch is supported.
- Suppress WM_*BUTTON* events if within TOUCH operations, e.g. fingers are pressed, or
if event is determined as TOUCH (0 != GetMessageExtraInfo())
- MOUSEMOVE issues NewtWindows_trackPointerLeave(..) directly
if no TOUCH operation is in process.
Removes need for MouseListener on Java side.
- TOUCH events are send as follows:
- PRIMARY first
- 1 MOVE 2nd (if not sent already)
- UP/DOWN (if not sent already)
We only send max. one MOVE event, since Win7 / Win8
assignes MOVE per default, even if no actual move happened.
Hence a single MOVE event shall suffice and is compatible
w/ e.g. Android (AFAIK).
- TOUCH pointer names are mapped to consecutive IDs
on the java side.
Diffstat (limited to 'src/newt/classes')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 393445db0..b2e175415 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,10 +46,12 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.VersionNumber; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; -import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.MouseEvent.PointerType; public class WindowDriver extends WindowImpl { @@ -134,16 +136,17 @@ public class WindowDriver extends WindowImpl { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } setGraphicsConfiguration(cfg); + final VersionNumber winVer = Platform.getOSVersionNumber(); final int flags = getReconfigureFlags(0, true) & ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; final long _windowHandle = CreateWindow0(DisplayDriver.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), + winVer.getMajor(), winVer.getMinor(), getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags); if ( 0 == _windowHandle ) { throw new NativeWindowException("Error creating window"); } setWindowHandle(_windowHandle); windowHandleClose = _windowHandle; - addMouseListener(mouseTracker); if(DEBUG_IMPLEMENTATION) { Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+ @@ -152,11 +155,6 @@ public class WindowDriver extends WindowImpl { e.printStackTrace(); } } - private MouseAdapter mouseTracker = new MouseAdapter() { - public void mouseEntered(MouseEvent e) { - WindowDriver.trackPointerLeave0(WindowDriver.this.getWindowHandle()); - } - }; protected void closeNativeImpl() { if(windowHandleClose != 0) { @@ -266,6 +264,33 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } + // + // PointerEvent Handling + // + /** + * Send multiple-pointer {@link MouseEvent.PointerType#TouchScreen} event to be directly consumed + * <p> + * Assumes non normal pointer names and rotation/scroll will be determined by a gesture handler. + * </p> + * <p> + * See {@link #doPointerEvent(boolean, boolean, PointerType[], short, int, int, boolean, int[], int[], int[], float[], float, float[], float)} + * for details. + * </p> + */ + public final void sendTouchScreenEvent(short eventType, int modifiers, + int pActionIdx, int[] pNames, + int[] pX, int[] pY, float[] pPressure, float maxPressure) { + final int pCount = pNames.length; + final MouseEvent.PointerType[] pTypes = new MouseEvent.PointerType[pCount]; + for(int i=pCount-1; i>=0; i--) { pTypes[i] = PointerType.TouchScreen; } + doPointerEvent(false /*enqueue*/, false /*wait*/, + pTypes, eventType, modifiers, pActionIdx, false /*normalPNames*/, pNames, + pX, pY, pPressure, maxPressure, new float[] { 0f, 0f, 0f} /*rotationXYZ*/, 1f/*rotationScale*/); + } + + // + // KeyEvent Handling + // private short repeatedKey = KeyEvent.VK_UNDEFINED; private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, int modifiers, short keyCode, short keySym, char keyChar) { @@ -326,9 +351,8 @@ public class WindowDriver extends WindowImpl { protected static native long getNewtWndProc0(); protected static native boolean initIDs0(long hInstance); - private native long CreateWindow0(long hInstance, String wndClassName, String wndName, - long parentWindowHandle, - int x, int y, int width, int height, boolean autoPosition, int flags); + private native long CreateWindow0(long hInstance, String wndClassName, String wndName, int winMajor, int winMinor, + long parentWindowHandle, int x, int y, int width, int height, boolean autoPosition, int flags); private native long MonitorFromWindow0(long windowHandle); private native void reconfigureWindow0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, int flags); @@ -338,5 +362,4 @@ public class WindowDriver extends WindowImpl { private static native boolean setPointerVisible0(long windowHandle, boolean visible); private static native boolean confinePointer0(long windowHandle, boolean grab, int l, int t, int r, int b); private static native void warpPointer0(long windowHandle, int x, int y); - private static native void trackPointerLeave0(long windowHandle); } |