Disable terminal keyboard on eglfs and linuxfb

Unify the behavior for eglfs, linuxfb and kms. The relevant code is
now moved from kms into fbconvenience.

From now on, on all three platforms, terminal keyboard input is turned
off by default. This feature can be disabled by setting
QT_QPA_ENABLE_TERMINAL_KEYBOARD to 1. This is similar to what the
evdev-based keyboard handler did in QWS in Qt4.

[ChangeLog][QtGui] The main Embedded Linux platform plugins (eglfs,
linuxfb, kms) are changed to behave identically with regards to
terminal keyboard input: it is turned off by default on all of these
platforms. If this feature is not desired, it can be disabled by
setting the environment variable QT_QPA_ENABLE_TERMINAL_KEYBOARD.

Task-number: QTBUG-36394

Change-Id: I69e47ed7580464dc5e703e9a0e23891c7c8b7790
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
This commit is contained in:
Laszlo Agocs 2014-01-24 13:50:26 +01:00 committed by The Qt Project
parent e02bda2105
commit a9f59f981d
10 changed files with 80 additions and 50 deletions

View File

@ -43,9 +43,11 @@
#include <QtGui/QOpenGLContext> #include <QtGui/QOpenGLContext>
#include <qpa/qwindowsysteminterface.h> #include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatforminputcontextfactory_p.h> #include <qpa/qplatforminputcontextfactory_p.h>
#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h> #include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
#include <QtPlatformSupport/private/qgenericunixservices_p.h> #include <QtPlatformSupport/private/qgenericunixservices_p.h>
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h> #include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
#include <QtPlatformSupport/private/qfbvthandler_p.h>
#include "qeglplatformintegration_p.h" #include "qeglplatformintegration_p.h"
#include "qeglplatformcontext_p.h" #include "qeglplatformcontext_p.h"
@ -82,8 +84,8 @@ QEGLPlatformIntegration::QEGLPlatformIntegration()
: m_screen(0), : m_screen(0),
m_display(EGL_NO_DISPLAY), m_display(EGL_NO_DISPLAY),
m_inputContext(0), m_inputContext(0),
mFontDb(new QGenericUnixFontDatabase), m_fontDb(new QGenericUnixFontDatabase),
mServices(new QGenericUnixServices) m_services(new QGenericUnixServices)
{ {
} }
@ -111,6 +113,8 @@ void QEGLPlatformIntegration::initialize()
screenAdded(m_screen); screenAdded(m_screen);
m_inputContext = QPlatformInputContextFactory::create(); m_inputContext = QPlatformInputContextFactory::create();
m_vtHandler.reset(new QFbVtHandler);
} }
QAbstractEventDispatcher *QEGLPlatformIntegration::createEventDispatcher() const QAbstractEventDispatcher *QEGLPlatformIntegration::createEventDispatcher() const
@ -120,12 +124,12 @@ QAbstractEventDispatcher *QEGLPlatformIntegration::createEventDispatcher() const
QPlatformServices *QEGLPlatformIntegration::services() const QPlatformServices *QEGLPlatformIntegration::services() const
{ {
return mServices.data(); return m_services.data();
} }
QPlatformFontDatabase *QEGLPlatformIntegration::fontDatabase() const QPlatformFontDatabase *QEGLPlatformIntegration::fontDatabase() const
{ {
return mFontDb.data(); return m_fontDb.data();
} }
QPlatformBackingStore *QEGLPlatformIntegration::createPlatformBackingStore(QWindow *window) const QPlatformBackingStore *QEGLPlatformIntegration::createPlatformBackingStore(QWindow *window) const

View File

@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE
class QEGLPlatformScreen; class QEGLPlatformScreen;
class QEGLPlatformWindow; class QEGLPlatformWindow;
class QFbVtHandler;
class QEGLPlatformIntegration : public QPlatformIntegration, public QPlatformNativeInterface class QEGLPlatformIntegration : public QPlatformIntegration, public QPlatformNativeInterface
{ {
@ -88,8 +89,9 @@ private:
QEGLPlatformScreen *m_screen; QEGLPlatformScreen *m_screen;
EGLDisplay m_display; EGLDisplay m_display;
QPlatformInputContext *m_inputContext; QPlatformInputContext *m_inputContext;
QScopedPointer<QPlatformFontDatabase> mFontDb; QScopedPointer<QPlatformFontDatabase> m_fontDb;
QScopedPointer<QPlatformServices> mServices; QScopedPointer<QPlatformServices> m_services;
QScopedPointer<QFbVtHandler> m_vtHandler;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -1,10 +1,11 @@
SOURCES += $$PWD/qfbscreen.cpp \ SOURCES += $$PWD/qfbscreen.cpp \
$$PWD/qfbbackingstore.cpp \ $$PWD/qfbbackingstore.cpp \
$$PWD/qfbwindow.cpp \ $$PWD/qfbwindow.cpp \
$$PWD/qfbcursor.cpp $$PWD/qfbcursor.cpp \
$$PWD/qfbvthandler.cpp
HEADERS += $$PWD/qfbscreen_p.h \ HEADERS += $$PWD/qfbscreen_p.h \
$$PWD/qfbbackingstore_p.h \ $$PWD/qfbbackingstore_p.h \
$$PWD/qfbwindow_p.h \ $$PWD/qfbwindow_p.h \
$$PWD/qfbcursor_p.h $$PWD/qfbcursor_p.h \
$$PWD/qfbvthandler_p.h

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of the plugins of the Qt Toolkit. ** This file is part of the plugins of the Qt Toolkit.
@ -39,11 +39,17 @@
** **
****************************************************************************/ ****************************************************************************/
#include <qkmsvthandler.h> #include "qfbvthandler_p.h"
#include <QtCore/private/qcrashhandler_p.h> #include <QtCore/private/qcrashhandler_p.h>
#include <QtGui/private/qguiapplication_p.h> #include <QtGui/private/qguiapplication_p.h>
#if defined(Q_OS_LINUX) && !defined(QT_NO_EVDEV)
#define HAS_VT
#endif
#ifdef HAS_VT
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <linux/vt.h>
#include <linux/kd.h> #include <linux/kd.h>
#ifdef K_OFF #ifdef K_OFF
@ -52,46 +58,51 @@
#define KBD_OFF_MODE K_RAW #define KBD_OFF_MODE K_RAW
#endif #endif
#endif // HAS_VT
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
QKmsVTHandler *QKmsVTHandler::self = 0; QFbVtHandler *QFbVtHandler::self = 0;
QKmsVTHandler::QKmsVTHandler(QObject *parent) QFbVtHandler::QFbVtHandler(QObject *parent)
: QObject(parent), m_tty(-1) : QObject(parent), m_tty(-1)
{ {
Q_ASSERT(!self); Q_ASSERT(!self);
self = this; self = this;
#ifdef HAS_VT
if (!isatty(0)) if (!isatty(0))
return; return;
m_tty = 0; m_tty = 0;
::ioctl(m_tty, KDGKBMODE, &m_oldKbdMode);
ioctl(m_tty, KDGKBMODE, &m_oldKbdMode); if (!qgetenv("QT_QPA_ENABLE_TERMINAL_KEYBOARD").toInt()) {
if (!qgetenv("QT_KMS_TTYKBD").toInt()) { ::ioctl(m_tty, KDSKBMODE, KBD_OFF_MODE);
ioctl(m_tty, KDSKBMODE, KBD_OFF_MODE);
QGuiApplicationPrivate *appd = QGuiApplicationPrivate::instance(); QGuiApplicationPrivate *appd = QGuiApplicationPrivate::instance();
Q_ASSERT(appd); Q_ASSERT(appd);
QSegfaultHandler::initialize(appd->argv, appd->argc); QSegfaultHandler::initialize(appd->argv, appd->argc);
QSegfaultHandler::installCrashHandler(crashHandler); QSegfaultHandler::installCrashHandler(crashHandler);
} }
#endif
} }
QKmsVTHandler::~QKmsVTHandler() QFbVtHandler::~QFbVtHandler()
{ {
self->cleanup(); self->cleanup();
self = 0; self = 0;
} }
void QKmsVTHandler::cleanup() void QFbVtHandler::cleanup()
{ {
if (m_tty == -1) if (m_tty == -1)
return; return;
ioctl(m_tty, KDSKBMODE, m_oldKbdMode); #ifdef HAS_VT
::ioctl(m_tty, KDSKBMODE, m_oldKbdMode);
#endif
} }
void QKmsVTHandler::crashHandler() void QFbVtHandler::crashHandler()
{ {
Q_ASSERT(self); Q_ASSERT(self);
self->cleanup(); self->cleanup();

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal ** Contact: http://www.qt-project.org/legal
** **
** This file is part of the plugins of the Qt Toolkit. ** This file is part of the plugins of the Qt Toolkit.
@ -39,26 +39,26 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef QKMSVTHANDLER_H #ifndef QFBVTHANDLER_H
#define QKMSVTHANDLER_H #define QFBVTHANDLER_H
#include <QObject> #include <QObject>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QKmsVTHandler : public QObject class QFbVtHandler : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
QKmsVTHandler(QObject *parent = 0); QFbVtHandler(QObject *parent = 0);
~QKmsVTHandler(); ~QFbVtHandler();
private: private:
void cleanup(); void cleanup();
static void crashHandler(); static void crashHandler();
static QKmsVTHandler *self; static QFbVtHandler *self;
int m_tty; int m_tty;
int m_oldKbdMode; int m_oldKbdMode;
}; };

View File

@ -21,8 +21,8 @@ SOURCES = main.cpp \
qkmscursor.cpp \ qkmscursor.cpp \
qkmsdevice.cpp \ qkmsdevice.cpp \
qkmsbackingstore.cpp \ qkmsbackingstore.cpp \
qkmsnativeinterface.cpp \ qkmsnativeinterface.cpp
qkmsvthandler.cpp
HEADERS = qkmsintegration.h \ HEADERS = qkmsintegration.h \
qkmsscreen.h \ qkmsscreen.h \
qkmscontext.h \ qkmscontext.h \
@ -30,8 +30,7 @@ HEADERS = qkmsintegration.h \
qkmscursor.h \ qkmscursor.h \
qkmsdevice.h \ qkmsdevice.h \
qkmsbackingstore.h \ qkmsbackingstore.h \
qkmsnativeinterface.h \ qkmsnativeinterface.h
qkmsvthandler.h
OTHER_FILES += \ OTHER_FILES += \
kms.json kms.json

View File

@ -46,7 +46,6 @@
#include "qkmsbackingstore.h" #include "qkmsbackingstore.h"
#include "qkmscontext.h" #include "qkmscontext.h"
#include "qkmsnativeinterface.h" #include "qkmsnativeinterface.h"
#include "qkmsvthandler.h"
#if !defined(QT_NO_EVDEV) #if !defined(QT_NO_EVDEV)
#include <QtPlatformSupport/private/qevdevmousemanager_p.h> #include <QtPlatformSupport/private/qevdevmousemanager_p.h>
@ -56,6 +55,8 @@
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h> #include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h> #include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
#include <QtPlatformSupport/private/qfbvthandler_p.h>
#include <QtGui/private/qguiapplication_p.h> #include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QOpenGLContext> #include <QtGui/QOpenGLContext>
#include <QtGui/QScreen> #include <QtGui/QScreen>
@ -68,7 +69,7 @@ QKmsIntegration::QKmsIntegration()
m_nativeInterface(new QKmsNativeInterface) m_nativeInterface(new QKmsNativeInterface)
{ {
setenv("EGL_PLATFORM", "drm",1); setenv("EGL_PLATFORM", "drm",1);
m_vtHandler = new QKmsVTHandler; m_vtHandler = new QFbVtHandler;
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_DRM | QDeviceDiscovery::Device_DRM_PrimaryGPU, 0); m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_DRM | QDeviceDiscovery::Device_DRM_PrimaryGPU, 0);
if (m_deviceDiscovery) { if (m_deviceDiscovery) {

View File

@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
class QKmsScreen; class QKmsScreen;
class QKmsDevice; class QKmsDevice;
class QKmsVTHandler; class QFbVtHandler;
class QKmsIntegration : public QObject, public QPlatformIntegration class QKmsIntegration : public QObject, public QPlatformIntegration
{ {
@ -85,7 +85,7 @@ private:
QList<QKmsDevice *> m_devices; QList<QKmsDevice *> m_devices;
QPlatformFontDatabase *m_fontDatabase; QPlatformFontDatabase *m_fontDatabase;
QPlatformNativeInterface *m_nativeInterface; QPlatformNativeInterface *m_nativeInterface;
QKmsVTHandler *m_vtHandler; QFbVtHandler *m_vtHandler;
QDeviceDiscovery *m_deviceDiscovery; QDeviceDiscovery *m_deviceDiscovery;
}; };

View File

@ -43,18 +43,22 @@
#include "qlinuxfbscreen.h" #include "qlinuxfbscreen.h"
#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h> #include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
#include <QtPlatformSupport/private/qgenericunixservices_p.h>
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h> #include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
#include <QtPlatformSupport/private/qfbvthandler_p.h>
#include <QtPlatformSupport/private/qfbbackingstore_p.h> #include <QtPlatformSupport/private/qfbbackingstore_p.h>
#include <QtPlatformSupport/private/qfbwindow_p.h> #include <QtPlatformSupport/private/qfbwindow_p.h>
#include <QtPlatformSupport/private/qfbcursor_p.h> #include <QtPlatformSupport/private/qfbcursor_p.h>
#include <QtGui/private/qguiapplication_p.h> #include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qpixmap_raster_p.h> #include <qpa/qplatforminputcontextfactory_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
QLinuxFbIntegration::QLinuxFbIntegration(const QStringList &paramList) QLinuxFbIntegration::QLinuxFbIntegration(const QStringList &paramList)
: m_fontDb(new QGenericUnixFontDatabase()) : m_fontDb(new QGenericUnixFontDatabase),
m_services(new QGenericUnixServices)
{ {
m_primaryScreen = new QLinuxFbScreen(paramList); m_primaryScreen = new QLinuxFbScreen(paramList);
} }
@ -70,6 +74,10 @@ void QLinuxFbIntegration::initialize()
screenAdded(m_primaryScreen); screenAdded(m_primaryScreen);
else else
qWarning("linuxfb: Failed to initialize screen"); qWarning("linuxfb: Failed to initialize screen");
m_inputContext = QPlatformInputContextFactory::create();
m_vtHandler.reset(new QFbVtHandler);
} }
bool QLinuxFbIntegration::hasCapability(QPlatformIntegration::Capability cap) const bool QLinuxFbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
@ -80,11 +88,6 @@ bool QLinuxFbIntegration::hasCapability(QPlatformIntegration::Capability cap) co
} }
} }
QPlatformPixmap *QLinuxFbIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
{
return new QRasterPlatformPixmap(type);
}
QPlatformBackingStore *QLinuxFbIntegration::createPlatformBackingStore(QWindow *window) const QPlatformBackingStore *QLinuxFbIntegration::createPlatformBackingStore(QWindow *window) const
{ {
return new QFbBackingStore(window); return new QFbBackingStore(window);
@ -109,7 +112,12 @@ QList<QPlatformScreen *> QLinuxFbIntegration::screens() const
QPlatformFontDatabase *QLinuxFbIntegration::fontDatabase() const QPlatformFontDatabase *QLinuxFbIntegration::fontDatabase() const
{ {
return m_fontDb; return m_fontDb.data();
}
QPlatformServices *QLinuxFbIntegration::services() const
{
return m_services.data();
} }
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -46,9 +46,9 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QLinuxFbIntegrationPrivate;
class QAbstractEventDispatcher; class QAbstractEventDispatcher;
class QLinuxFbScreen; class QLinuxFbScreen;
class QFbVtHandler;
class QLinuxFbIntegration : public QPlatformIntegration class QLinuxFbIntegration : public QPlatformIntegration
{ {
@ -59,21 +59,25 @@ public:
void initialize() Q_DECL_OVERRIDE; void initialize() Q_DECL_OVERRIDE;
bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE; bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const Q_DECL_OVERRIDE;
QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE; QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE; QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE; QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
QPlatformServices *services() const Q_DECL_OVERRIDE;
QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE { return m_inputContext; }
QList<QPlatformScreen *> screens() const; QList<QPlatformScreen *> screens() const;
private: private:
QLinuxFbScreen *m_primaryScreen; QLinuxFbScreen *m_primaryScreen;
QPlatformFontDatabase *m_fontDb; QPlatformInputContext *m_inputContext;
QScopedPointer<QPlatformFontDatabase> m_fontDb;
QScopedPointer<QPlatformServices> m_services;
QScopedPointer<QFbVtHandler> m_vtHandler;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QLINUXFBINTEGRATION_H #endif // QLINUXFBINTEGRATION_H