changeset 6148:c5694f254fef

RT-35409 [Monocle] FuzzyTapTest sometimes fails
author Daniel Blaukopf <daniel.blaukopf@oracle.com>
date Sun, 19 Jan 2014 14:27:35 +0200
parents 74e5f10c9874
children e5556c1b14be
files modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/MouseInputSynthesizer.java modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchInput.java modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchLookahead.java modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchState.java
diffstat 4 files changed, 36 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/MouseInputSynthesizer.java	Sat Jan 18 21:57:22 2014 +0200
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/MouseInputSynthesizer.java	Sun Jan 19 14:27:35 2014 +0200
@@ -38,6 +38,7 @@
     }
 
     public void setState(TouchState touchState) {
+        MouseInput.getInstance().getState(mouseState);
         if (touchState.getPointCount() == 0) {
             mouseState.releaseButton(MouseEvent.BUTTON_LEFT);
         } else {
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchInput.java	Sat Jan 18 21:57:22 2014 +0200
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchInput.java	Sun Jan 19 14:27:35 2014 +0200
@@ -210,4 +210,8 @@
         return count;
     }
 
+    public int getTouchMoveSensitivity() {
+        return touchMoveSensitivity;
+    }
+
 }
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchLookahead.java	Sat Jan 18 21:57:22 2014 +0200
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchLookahead.java	Sun Jan 19 14:27:35 2014 +0200
@@ -70,29 +70,24 @@
     }
 
     public void pushState() {
+        if (!processedFirstEvent) {
+            touch.getState(previousState);
+            if (state.canBeFoldedWith(previousState, assignIDs)) {
+                processedFirstEvent = true;
+            } else {
+                touch.setState(state, true);
+            }
+        }
         if (processedFirstEvent) {
             // fold together TouchStates that have the same touch point count
             // and IDs. For Protocol A devices the touch IDs are not initialized
             // yet, which means the only differentiator will be the number of
             // points.
-            boolean fold = true;
-            if (state.getPointCount() != previousState.getPointCount()) {
-                fold = false;
-            }
-            if (!assignIDs) {
-                state.sortPointsByID();
-                for (int i = 0; fold && i < previousState.getPointCount(); i++) {
-                    if (state.getPoint(i).id != previousState.getPoint(i).id) {
-                        fold = false;
-                    }
-                }
-            }
-            if (!fold) {
+            state.sortPointsByID();
+            if (!state.canBeFoldedWith(previousState, assignIDs)) {
                 // the events are different. Send "previousState".
                 touch.setState(previousState, true);
             }
-        } else {
-            processedFirstEvent = true;
         }
         state.copyTo(previousState);
     }
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchState.java	Sat Jan 18 21:57:22 2014 +0200
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchState.java	Sun Jan 19 14:27:35 2014 +0200
@@ -208,4 +208,25 @@
         }
     }
 
+    /** Finds out whether two non-null states are identical in everything but
+     * their touch point coordinates
+     *
+     * @param ts the TouchState to compare to
+     * @param ignoreIDs if true, ignore IDs when comparing points
+     */
+    boolean canBeFoldedWith(TouchState ts, boolean ignoreIDs) {
+        if (ts.pointCount != pointCount) {
+            return false;
+        }
+        if (ignoreIDs) {
+            return true;
+        }
+        for (int i = 0; i < pointCount; i++) {
+            if (ts.points[i].id != points[i].id) {
+                return false;
+            }
+        }
+        return true;
+    }
+
 }