changeset 6527:a0a619f9f425

RT-34982 - IMX6 - cursor image is seen even though a mouse is not plugged in. Adjust cursor logic to properly show/hide the cursor depending on whether or not a pointing device is connected. Reviewed by Rafi Tayar. Tested with HelloCursors.
author Lisa.Selle@oracle.com
date Thu, 20 Mar 2014 14:49:25 -0400
parents 5852ce9869cd
children f005f3f08277
files modules/graphics/src/main/native-glass/lens/lensport/imx6Cursor.c
diffstat 1 files changed, 20 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-glass/lens/lensport/imx6Cursor.c	Thu Mar 20 11:35:04 2014 +0200
+++ b/modules/graphics/src/main/native-glass/lens/lensport/imx6Cursor.c	Thu Mar 20 14:49:25 2014 -0400
@@ -124,6 +124,16 @@
     int cursorSize = cursor.width * cursor.height * bpp;
     int xShift = cursor.xShift;
     int yShift = cursor.yShift;
+
+    if (!cursor.isVisible) {
+        return;
+    }
+
+    if (lseek(cursor.fd, 0, SEEK_SET) == -1) {
+        GLASS_LOG_SEVERE("Cannot rewrite cursor image");
+        return;
+     }
+
     GLASS_LOG_FINEST("Cursor shift = (%i, %i) at (%i, %i)\n",
                      xShift, yShift, cursor.x, cursor.y);
     if (xShift == 0 && yShift == 0) {
@@ -389,16 +399,11 @@
             }
         }
 
-        cursor.isVisible = 1;
         cursor.currentCursor = nativeCursorHandle;
 
         fbImx6AdjustShift();
-        if (lseek(cursor.fd, 0, SEEK_SET) == -1) {
-                GLASS_LOG_SEVERE("Cannot rewrite cursor image");
-        } else {
-            fbImx6WriteCursor(cursor.fd, cursorImage->buffer, use32bit ? 4 : 2);
-        }
-    }
+        fbImx6WriteCursor(cursor.fd, cursorImage->buffer, use32bit ? 4 : 2);
+    } 
 }
 
 
@@ -430,13 +435,9 @@
         y -= cursor.yShift;
         if (xShift != cursor.xShift || yShift != cursor.yShift) {
             GLASS_LOG_FINEST("Calling lseek to rewind cursor fd");
-            if (lseek(cursor.fd, 0, SEEK_SET) == -1) {
-                GLASS_LOG_SEVERE("Cannot rewrite cursor image");
-            } else {
-                Imx6CursorImage *fbCursorImage = (Imx6CursorImage *)
-                    jlong_to_ptr(cursor.currentCursor);
-                fbImx6WriteCursor(cursor.fd, fbCursorImage->buffer, use32bit ? 4 : 2);
-            }
+            Imx6CursorImage *fbCursorImage = (Imx6CursorImage *)
+                jlong_to_ptr(cursor.currentCursor);
+            fbImx6WriteCursor(cursor.fd, fbCursorImage->buffer, use32bit ? 4 : 2);
         }
 
         struct mxcfb_pos cpos = {x, y};
@@ -448,8 +449,8 @@
 
 
 void fbImx6CursorClose() {
-
     if (cursor.fd >= 0) {
+        fbImx6BlankCursor();
         close(cursor.fd);
         cursor.fd = -1;
         cursor.isVisible = 0;
@@ -462,7 +463,10 @@
 static void fbImx6SetVisible(jboolean isVisible) {
     if (isVisible) {
         if (!cursor.isVisible && cursor.currentCursor != 0) {
-            fbImx6SetNativeCursor(cursor.currentCursor);
+            cursor.isVisible = 1;
+            Imx6CursorImage *fbCursorImage = (Imx6CursorImage *)
+                  jlong_to_ptr(cursor.currentCursor);
+            fbImx6WriteCursor(cursor.fd, fbCursorImage->buffer, use32bit ? 4 : 2);
         }
     } else {
         if (cursor.isVisible) {