From 06e8682cb7c29d15a2c49fbc442a1a4509876abb Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 25 Jul 2012 12:02:23 +0300 Subject: [PATCH] Disable tty keyboard in kms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set QT_KMS_TTYKBD=1 to prevent this and keep vt switching, ctrl-c, input appearing on the tty, etc. working. Change-Id: I0071685205ae9e02536dcb71f6fef6495c48f8fb Reviewed-by: Jørgen Lind --- src/plugins/platforms/kms/kms.pro | 6 +- src/plugins/platforms/kms/qkmsintegration.cpp | 3 + src/plugins/platforms/kms/qkmsintegration.h | 2 + src/plugins/platforms/kms/qkmsvthandler.cpp | 77 +++++++++++++++++++ src/plugins/platforms/kms/qkmsvthandler.h | 64 +++++++++++++++ 5 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 src/plugins/platforms/kms/qkmsvthandler.cpp create mode 100644 src/plugins/platforms/kms/qkmsvthandler.h diff --git a/src/plugins/platforms/kms/kms.pro b/src/plugins/platforms/kms/kms.pro index 4a50569aa75..2e8af5ba9d5 100644 --- a/src/plugins/platforms/kms/kms.pro +++ b/src/plugins/platforms/kms/kms.pro @@ -21,7 +21,8 @@ SOURCES = main.cpp \ qkmsnativeinterface.cpp \ qkmsudevlistener.cpp \ qkmsudevhandler.cpp \ - qkmsudevdrmhandler.cpp + qkmsudevdrmhandler.cpp \ + qkmsvthandler.cpp HEADERS = qkmsintegration.h \ qkmsscreen.h \ qkmscontext.h \ @@ -32,7 +33,8 @@ HEADERS = qkmsintegration.h \ qkmsnativeinterface.h \ qkmsudevlistener.h \ qkmsudevhandler.h \ - qkmsudevdrmhandler.h + qkmsudevdrmhandler.h \ + qkmsvthandler.h target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/kms/qkmsintegration.cpp b/src/plugins/platforms/kms/qkmsintegration.cpp index c1e1f0d5766..5e8c28effea 100644 --- a/src/plugins/platforms/kms/qkmsintegration.cpp +++ b/src/plugins/platforms/kms/qkmsintegration.cpp @@ -48,6 +48,7 @@ #include "qkmsnativeinterface.h" #include "qkmsudevlistener.h" #include "qkmsudevdrmhandler.h" +#include "qkmsvthandler.h" #include #include @@ -66,6 +67,7 @@ QKmsIntegration::QKmsIntegration() { QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher); setenv("EGL_PLATFORM", "drm",1); + m_vtHandler = new QKmsVTHandler; m_drmHandler = new QKmsUdevDRMHandler(this); m_udevListener->addHandler(m_drmHandler); } @@ -80,6 +82,7 @@ QKmsIntegration::~QKmsIntegration() } delete m_fontDatabase; delete m_udevListener; + delete m_vtHandler; } QObject *QKmsIntegration::createDevice(const char *path) diff --git a/src/plugins/platforms/kms/qkmsintegration.h b/src/plugins/platforms/kms/qkmsintegration.h index 93b3084e9be..034fd1090f7 100644 --- a/src/plugins/platforms/kms/qkmsintegration.h +++ b/src/plugins/platforms/kms/qkmsintegration.h @@ -51,6 +51,7 @@ class QKmsScreen; class QKmsDevice; class QKmsUdevListener; class QKmsUdevDRMHandler; +class QKmsVTHandler; class QKmsIntegration : public QPlatformIntegration { @@ -82,6 +83,7 @@ private: QPlatformNativeInterface *m_nativeInterface; QKmsUdevListener *m_udevListener; QKmsUdevDRMHandler *m_drmHandler; + QKmsVTHandler *m_vtHandler; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/kms/qkmsvthandler.cpp b/src/plugins/platforms/kms/qkmsvthandler.cpp new file mode 100644 index 00000000000..88ca4bfeedc --- /dev/null +++ b/src/plugins/platforms/kms/qkmsvthandler.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +#ifdef K_OFF +#define KBD_OFF_MODE K_OFF +#else +#define KBD_OFF_MODE K_RAW +#endif + +QT_BEGIN_NAMESPACE + +QKmsVTHandler::QKmsVTHandler(QObject *parent) + : QObject(parent), m_tty(-1) +{ + 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); +} + +QKmsVTHandler::~QKmsVTHandler() +{ + if (m_tty == -1) + return; + + ioctl(m_tty, KDSKBMODE, m_oldKbdMode); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/kms/qkmsvthandler.h b/src/plugins/platforms/kms/qkmsvthandler.h new file mode 100644 index 00000000000..311ea2432ab --- /dev/null +++ b/src/plugins/platforms/kms/qkmsvthandler.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QKMSVTHANDLER_H +#define QKMSVTHANDLER_H + +#include + +QT_BEGIN_NAMESPACE + +class QKmsVTHandler : public QObject +{ + Q_OBJECT + +public: + QKmsVTHandler(QObject *parent = 0); + ~QKmsVTHandler(); + +private: + int m_tty; + int m_oldKbdMode; +}; + +QT_END_NAMESPACE + +#endif