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 <gunnar.sletta@digia.com>
This commit is contained in:
Laszlo Agocs 2013-10-09 16:01:30 +02:00 committed by The Qt Project
parent c657bb7b51
commit c16dbfbdde
2 changed files with 15 additions and 2 deletions

View File

@ -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();

View File

@ -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 <QtPlatformSupport/private/qdevicediscovery_p.h>
#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<QDeviceDiscovery> dis(QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse));
hideCursor = dis->scanConnectedDevices().isEmpty();
#endif
} else {
hideCursor = hideCursorVal.toInt() != 0;
}
if (!hideCursor)
m_cursor = QEglFSHooks::hooks()->createCursor(this);
}