Compile in evdev code to linuxfb

Make it compatible with eglfs. The behavior is the same: By default
mouse, keyboard and touch will all be initialized and, when having
libudev support, discovered automatically. The environment variables
QT_QPA_FB_DISABLE_INPUT and QT_QPA_FB_TSLIB can be used to used to
disable the built-in input handlers and to force tslib instead of
evdev, respectively.

This allows embedded systems and applications to easily fall back
from eglfs to linuxfb on devices that are not rendering via OpenGL.

Dynamic hiding/showing of the mouse cursor is to be done separately,
here we provide the necessary device discovery hooks only.

[ChangeLog][QtGui] The linuxfb platform plugin's input device handling
is now compatible with eglfs. The evdev keyboard, mouse and touch code
is compiled in by default.

Change-Id: I44bc661c53ae78c39b0f30486a475b4e639ab2d6
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@theqtcompany.com>
Reviewed-by: Gatis Paeglis <gatis.paeglis@digia.com>
This commit is contained in:
Laszlo Agocs 2014-12-09 16:27:55 +01:00
parent 8a4099a0aa
commit 13ec068ce2
4 changed files with 47 additions and 1 deletions

View File

@ -137,4 +137,9 @@ void QFbCursor::setDirty()
}
}
void QFbCursor::setMouseDeviceDiscovery(QDeviceDiscovery *dd)
{
Q_UNUSED(dd);
}
QT_END_NAMESPACE

View File

@ -50,9 +50,12 @@
QT_BEGIN_NAMESPACE
class QFbScreen;
class QDeviceDiscovery;
class QFbCursor : public QPlatformCursor
{
Q_OBJECT
public:
QFbCursor(QFbScreen *screen);
@ -71,6 +74,8 @@ public:
virtual bool isOnScreen() const { return mOnScreen; }
virtual QRect lastPainted() const { return mPrevRect; }
void setMouseDeviceDiscovery(QDeviceDiscovery *dd);
private:
void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
void setCursor(Qt::CursorShape shape);

View File

@ -46,6 +46,16 @@
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatforminputcontextfactory_p.h>
#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
#include <QtPlatformSupport/private/qevdevmousemanager_p.h>
#include <QtPlatformSupport/private/qevdevkeyboardmanager_p.h>
#include <QtPlatformSupport/private/qevdevtouch_p.h>
#endif
#if !defined(QT_NO_TSLIB) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
#include <QtPlatformSupport/private/qtslib_p.h>
#endif
QT_BEGIN_NAMESPACE
QLinuxFbIntegration::QLinuxFbIntegration(const QStringList &paramList)
@ -70,6 +80,9 @@ void QLinuxFbIntegration::initialize()
m_inputContext = QPlatformInputContextFactory::create();
m_vtHandler.reset(new QFbVtHandler);
if (!qEnvironmentVariableIntValue("QT_QPA_FB_DISABLE_INPUT"))
createInputHandlers();
}
bool QLinuxFbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
@ -113,4 +126,24 @@ QPlatformServices *QLinuxFbIntegration::services() const
return m_services.data();
}
void QLinuxFbIntegration::createInputHandlers()
{
#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString(), this);
QEvdevMouseManager *mouseMgr = new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString(), this);
Q_FOREACH (QScreen *screen, QGuiApplication::screens()) {
QFbCursor *cursor = qobject_cast<QFbCursor *>(screen->handle()->cursor());
if (cursor)
cursor->setMouseDeviceDiscovery(mouseMgr->deviceDiscovery());
}
#ifndef QT_NO_TSLIB
const bool useTslib = qEnvironmentVariableIntValue("QT_QPA_FB_TSLIB");
if (useTslib)
new QTsLibMouseHandler(QLatin1String("TsLib"), QString());
else
#endif // QT_NO_TSLIB
new QEvdevTouchScreenHandlerThread(QString(), this);
#endif
}
QT_END_NAMESPACE

View File

@ -35,6 +35,7 @@
#define QLINUXFBINTEGRATION_H
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformnativeinterface.h>
QT_BEGIN_NAMESPACE
@ -42,7 +43,7 @@ class QAbstractEventDispatcher;
class QLinuxFbScreen;
class QFbVtHandler;
class QLinuxFbIntegration : public QPlatformIntegration
class QLinuxFbIntegration : public QPlatformIntegration, public QPlatformNativeInterface
{
public:
QLinuxFbIntegration(const QStringList &paramList);
@ -63,6 +64,8 @@ public:
QList<QPlatformScreen *> screens() const;
private:
void createInputHandlers();
QLinuxFbScreen *m_primaryScreen;
QPlatformInputContext *m_inputContext;
QScopedPointer<QPlatformFontDatabase> m_fontDb;