changeset 5698:0388eab441c0

[RT-34190] Lens: mouse pointer not always follows the finger when using touch Summary: Internal Lens mouse coordinated didn't track correctly the touch events Fixed by: 1) update mouse location with the primary point, instead from the first touch event 2) draw cursor after tap, which isn't done by default through button press Tested with: HelloSanity, LinuxInputTest, FXML-LoginDemo Reviewed by: ddhill
author Assaf Yavani
date Tue, 12 Nov 2013 12:54:44 +0200
parents 2329121f5179
children c246cf7b0844
files modules/graphics/src/main/native-glass/lens/input/udev/udevInput.c modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.c
diffstat 2 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-glass/lens/input/udev/udevInput.c	Tue Nov 12 11:48:34 2013 +0400
+++ b/modules/graphics/src/main/native-glass/lens/input/udev/udevInput.c	Tue Nov 12 12:54:44 2013 +0200
@@ -1637,15 +1637,6 @@
                                  mappedIndex);
             }
         }
-        mousePosX = mouseState->pendingTouchXs[0];
-        mousePosY = mouseState->pendingTouchYs[0];
-        GLASS_LOG_FINEST("Update mouse position from touchPoint[0] with id %d (%d %d)",
-                         mouseState->pendingTouchIDs[0],
-                         mousePosX,
-                         mousePosY);
-    } else {
-        mousePosX = newMousePosX;
-        mousePosY = newMousePosY;
     }
 
     //process touch points states and prepare data structures for notification
@@ -1873,6 +1864,13 @@
                 }
             }//!gUseMultiTouch
 
+            //update the mouse position for future calculations
+            if (primaryPointIndex > -1) {
+                //update mouse location
+                mousePosX = mouseState->pendingTouchXs[primaryPointIndex];
+                mousePosY = mouseState->pendingTouchYs[primaryPointIndex];
+            }
+
             GLASS_IF_LOG_FINEST {
                 GLASS_LOG_FINEST("lens_wm_notifyMultiTouchEvent() with:");
                 for (i = 0; i < count; i++) {
@@ -1897,13 +1895,16 @@
         GLASS_LOG_FINEST("no touch points");
     }
 
-    //at these point we processed all touch events
-    //now process mouse events and synthesize mouse events from touch point
-
-    GLASS_LOG_FINEST("device %p x %d y %d reportMove %d keyEventIndex: %d\n",
+    if (!device->isTouch) {
+        //handle mouse events
+
+        //update mouse location
+        mousePosX = newMousePosX;
+        mousePosY = newMousePosY;
+
+        GLASS_LOG_FINEST("device %p x %d y %d reportMove %d keyEventIndex: %d\n",
                      device, mousePosX, mousePosY, reportMouseMove, keyEventIndex);
 
-    if (!device->isTouch) {
         if (keyEventIndex >= 0) {
              lens_input_pointerEvents_handleKeyEvent(device,
                                                      &mouseState->pendingInputEvents[keyEventIndex]);
--- a/modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.c	Tue Nov 12 11:48:34 2013 +0400
+++ b/modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.c	Tue Nov 12 12:54:44 2013 +0200
@@ -1185,12 +1185,15 @@
             case com_sun_glass_events_TouchEvent_TOUCH_PRESSED:
                 //send button pressed
                 GLASS_LOG_FINEST("touch -> mouse - pressed");
+
                 lens_wm_notifyButtonEvent(env,
                                           JNI_TRUE, //preseed
                                           com_sun_glass_events_MouseEvent_BUTTON_LEFT,
                                           absX,
                                           absY);
 
+                //explicitly update the cursor as lens_wm_notifyButtonEvent doesn't
+                fbCursorSetPosition(absX, absY);
                 break;
             case com_sun_glass_events_TouchEvent_TOUCH_MOVED:
                 GLASS_LOG_FINEST("touch -> mouse - move");