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

View File

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

View File

@ -1,10 +1,11 @@
SOURCES += $$PWD/qfbscreen.cpp \
$$PWD/qfbbackingstore.cpp \
$$PWD/qfbwindow.cpp \
$$PWD/qfbcursor.cpp
$$PWD/qfbcursor.cpp \
$$PWD/qfbvthandler.cpp
HEADERS += $$PWD/qfbscreen_p.h \
$$PWD/qfbbackingstore_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
**
** 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 <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 <linux/vt.h>
#include <linux/kd.h>
#ifdef K_OFF
@ -52,46 +58,51 @@
#define KBD_OFF_MODE K_RAW
#endif
#endif // HAS_VT
QT_BEGIN_NAMESPACE
QKmsVTHandler *QKmsVTHandler::self = 0;
QFbVtHandler *QFbVtHandler::self = 0;
QKmsVTHandler::QKmsVTHandler(QObject *parent)
QFbVtHandler::QFbVtHandler(QObject *parent)
: QObject(parent), m_tty(-1)
{
Q_ASSERT(!self);
self = this;
#ifdef HAS_VT
if (!isatty(0))
return;
m_tty = 0;
ioctl(m_tty, KDGKBMODE, &m_oldKbdMode);
if (!qgetenv("QT_KMS_TTYKBD").toInt()) {
ioctl(m_tty, KDSKBMODE, KBD_OFF_MODE);
::ioctl(m_tty, KDGKBMODE, &m_oldKbdMode);
if (!qgetenv("QT_QPA_ENABLE_TERMINAL_KEYBOARD").toInt()) {
::ioctl(m_tty, KDSKBMODE, KBD_OFF_MODE);
QGuiApplicationPrivate *appd = QGuiApplicationPrivate::instance();
Q_ASSERT(appd);
QSegfaultHandler::initialize(appd->argv, appd->argc);
QSegfaultHandler::installCrashHandler(crashHandler);
}
#endif
}
QKmsVTHandler::~QKmsVTHandler()
QFbVtHandler::~QFbVtHandler()
{
self->cleanup();
self = 0;
}
void QKmsVTHandler::cleanup()
void QFbVtHandler::cleanup()
{
if (m_tty == -1)
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);
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
**
** This file is part of the plugins of the Qt Toolkit.
@ -39,26 +39,26 @@
**
****************************************************************************/
#ifndef QKMSVTHANDLER_H
#define QKMSVTHANDLER_H
#ifndef QFBVTHANDLER_H
#define QFBVTHANDLER_H
#include <QObject>
QT_BEGIN_NAMESPACE
class QKmsVTHandler : public QObject
class QFbVtHandler : public QObject
{
Q_OBJECT
public:
QKmsVTHandler(QObject *parent = 0);
~QKmsVTHandler();
QFbVtHandler(QObject *parent = 0);
~QFbVtHandler();
private:
void cleanup();
static void crashHandler();
static QKmsVTHandler *self;
static QFbVtHandler *self;
int m_tty;
int m_oldKbdMode;
};

View File

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

View File

@ -46,7 +46,6 @@
#include "qkmsbackingstore.h"
#include "qkmscontext.h"
#include "qkmsnativeinterface.h"
#include "qkmsvthandler.h"
#if !defined(QT_NO_EVDEV)
#include <QtPlatformSupport/private/qevdevmousemanager_p.h>
@ -56,6 +55,8 @@
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
#include <QtPlatformSupport/private/qfbvthandler_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QOpenGLContext>
#include <QtGui/QScreen>
@ -68,7 +69,7 @@ QKmsIntegration::QKmsIntegration()
m_nativeInterface(new QKmsNativeInterface)
{
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);
if (m_deviceDiscovery) {

View File

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

View File

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

View File

@ -46,9 +46,9 @@
QT_BEGIN_NAMESPACE
class QLinuxFbIntegrationPrivate;
class QAbstractEventDispatcher;
class QLinuxFbScreen;
class QFbVtHandler;
class QLinuxFbIntegration : public QPlatformIntegration
{
@ -59,21 +59,25 @@ public:
void initialize() 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;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
QAbstractEventDispatcher *createEventDispatcher() 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;
private:
QLinuxFbScreen *m_primaryScreen;
QPlatformFontDatabase *m_fontDb;
QPlatformInputContext *m_inputContext;
QScopedPointer<QPlatformFontDatabase> m_fontDb;
QScopedPointer<QPlatformServices> m_services;
QScopedPointer<QFbVtHandler> m_vtHandler;
};
QT_END_NAMESPACE
#endif // QLINUXFBINTEGRATION_H