From 2e6e295f6193f696171f9c375e985fd2c56236ac Mon Sep 17 00:00:00 2001
From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Date: Wed, 15 May 2013 12:54:46 +0200
Subject: [PATCH] Never show EGLFS mouse cursor in Qt for Android platform
 plugin
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The hack to use the environment variable for turning off the
mouse cursor is broken when running against Ministro, because
Ministro does not pass the environment on.

A better solution is to make it possible to turn the cursor
in the EGLFS plugin off in the hooks instead.

Task-number: QTBUG-30553
Change-Id: Id09b48c350d2c95de9bb174f7480cf0cd2bf8145
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
---
 .../org/qtproject/qt5/android/bindings/QtActivity.java    | 1 -
 .../platforms/android/src/opengl/qeglfshooks_android.cpp  | 7 +++++++
 src/plugins/platforms/eglfs/qeglfshooks_stub.cpp          | 4 ++--
 src/plugins/platforms/eglfs/qeglfsscreen.cpp              | 8 ++------
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
index 6fedd6ac2ee..fd0c6b14e37 100644
--- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
+++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
@@ -478,7 +478,6 @@ public class QtActivity extends Activity
                 }
                 loaderParams.putStringArrayList(NATIVE_LIBRARIES_KEY, libraryList);
                 loaderParams.putString(ENVIRONMENT_VARIABLES_KEY, ENVIRONMENT_VARIABLES
-                                                                  + "QT_QPA_EGLFS_HIDECURSOR=1"
                                                                   + "\tQML2_IMPORT_PATH=" + localPrefix + "/qml"
                                                                   + "\tQML_IMPORT_PATH=" + localPrefix + "/imports"
                                                                   + "\tQT_PLUGIN_PATH=" + localPrefix + "/plugins");
diff --git a/src/plugins/platforms/android/src/opengl/qeglfshooks_android.cpp b/src/plugins/platforms/android/src/opengl/qeglfshooks_android.cpp
index 005758d83dd..5a353101113 100644
--- a/src/plugins/platforms/android/src/opengl/qeglfshooks_android.cpp
+++ b/src/plugins/platforms/android/src/opengl/qeglfshooks_android.cpp
@@ -62,6 +62,7 @@ public:
     EGLNativeWindowType createNativeWindow(const QSize &size, const QSurfaceFormat &format);
     void destroyNativeWindow(EGLNativeWindowType window);
     bool hasCapability(QPlatformIntegration::Capability cap) const;
+    QEglFSCursor *createCursor(QEglFSScreen *screen) const;
 };
 
 void QEglFSAndroidHooks::platformInit()
@@ -134,6 +135,12 @@ QSurfaceFormat QEglFSAndroidHooks::surfaceFormatFor(const QSurfaceFormat &inputF
     return ret;
 }
 
+QEglFSCursor *QEglFSAndroidHooks::createCursor(QEglFSScreen *screen) const
+{
+    Q_UNUSED(screen);
+    return 0;
+}
+
 static QEglFSAndroidHooks eglFSAndroidHooks;
 QEglFSHooks *platformHooks = &eglFSAndroidHooks;
 
diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
index 5c264834b39..91a97ff977f 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
+++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
@@ -40,6 +40,7 @@
 ****************************************************************************/
 
 #include "qeglfshooks.h"
+#include "qeglfscursor.h"
 
 #include <fcntl.h>
 #include <unistd.h>
@@ -249,8 +250,7 @@ bool QEglFSHooks::hasCapability(QPlatformIntegration::Capability cap) const
 
 QEglFSCursor *QEglFSHooks::createCursor(QEglFSScreen *screen) const
 {
-    Q_UNUSED(screen);
-    return 0;
+    return new QEglFSCursor(screen);
 }
 
 void QEglFSHooks::waitForVSync() const
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
index e104bd7f2b2..6cb1f88c664 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
@@ -55,12 +55,8 @@ QEglFSScreen::QEglFSScreen(EGLDisplay dpy)
 #endif
 
     static int hideCursor = qgetenv("QT_QPA_EGLFS_HIDECURSOR").toInt();
-    if (!hideCursor) {
-        if (QEglFSCursor *customCursor = QEglFSHooks::hooks()->createCursor(this))
-            m_cursor = customCursor;
-        else
-            m_cursor = new QEglFSCursor(this);
-    }
+    if (!hideCursor)
+        m_cursor = QEglFSHooks::hooks()->createCursor(this);
 }
 
 QEglFSScreen::~QEglFSScreen()
-- 
GitLab