From c16dbfbdded43de3536695938e0ccb1c8376a80d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 9 Oct 2013 16:01:30 +0200 Subject: eglfs: Show the mouse cursor when a mouse is connected Currently the mouse cursor is shown by default and it can be turned off by setting QT_QPA_EGLFS_HIDECURSOR to a non-zero value. This is now enhanced with an automatic detection step via QDeviceDiscovery (the helper the input code use anyway). From now on if QT_QPA_EGLFS_HIDECURSOR is not set, the cursor is shown only if a mouse device is present in the system. This could later be enhanced further by showing and hiding the cursor dynamically during runtime although that will not be of much use for embedded platforms without libudev. Change-Id: I7e4b85ea8807200871c88fc42b11ab2adac90d32 Reviewed-by: Gunnar Sletta --- src/platformsupport/devicediscovery/qdevicediscovery_p.h | 2 +- src/plugins/platforms/eglfs/qeglfsscreen.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_p.h index d9bd9a78e4..5485b73fd7 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_p.h +++ b/src/platformsupport/devicediscovery/qdevicediscovery_p.h @@ -79,7 +79,7 @@ public: }; Q_DECLARE_FLAGS(QDeviceTypes, QDeviceType) - static QDeviceDiscovery *create(QDeviceTypes type, QObject *parent); + static QDeviceDiscovery *create(QDeviceTypes type, QObject *parent = 0); ~QDeviceDiscovery(); QStringList scanConnectedDevices(); diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index bd3601bf06..3f92d60aa2 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -44,6 +44,10 @@ #include "qeglfswindow.h" #include "qeglfshooks.h" +#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)) +#include +#endif + QT_BEGIN_NAMESPACE QEglFSScreen::QEglFSScreen(EGLDisplay dpy) @@ -56,7 +60,16 @@ QEglFSScreen::QEglFSScreen(EGLDisplay dpy) qWarning("QEglScreen %p\n", this); #endif - static int hideCursor = qgetenv("QT_QPA_EGLFS_HIDECURSOR").toInt(); + QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR"); + bool hideCursor = false; + if (hideCursorVal.isEmpty()) { +#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)) + QScopedPointer dis(QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse)); + hideCursor = dis->scanConnectedDevices().isEmpty(); +#endif + } else { + hideCursor = hideCursorVal.toInt() != 0; + } if (!hideCursor) m_cursor = QEglFSHooks::hooks()->createCursor(this); } -- cgit v1.2.3