From 10472dce9202e4460b2d908bdbe0cd65291f77e5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 9 Jan 2015 14:48:01 +0100 Subject: Unify input device hotplugging support for embedded On embedded the mouse cursor will now appear and reappear regardless of how the input handling code is loaded (via a generic plugin or compiled-in to the platform plugin). Instead of passing around QDeviceDiscovery instances that only works when compiling-in the code into the platform plugin, introduce a new internal central QInputDeviceManager. The single instance of this provides a place to store any future input device related signals and properties. Also introduce mouse hotplugging support to linuxfb. [ChangeLog][QtGui] The mouse cursor on Embedded Linux is now handling hotplugging correctly with eglfs and linuxfb regardless of how the input handling code is loaded (via a generic plugin or built in to the platform plugin). Change-Id: I147c1b04a193baf216598015264f2c06e1b20f84 Reviewed-by: Andy Nichols --- src/gui/kernel/kernel.pri | 7 ++- src/gui/kernel/qguiapplication.cpp | 13 ++++++ src/gui/kernel/qguiapplication_p.h | 5 +++ src/gui/kernel/qinputdevicemanager.cpp | 64 ++++++++++++++++++++++++++ src/gui/kernel/qinputdevicemanager_p.h | 77 ++++++++++++++++++++++++++++++++ src/gui/kernel/qinputdevicemanager_p_p.h | 69 ++++++++++++++++++++++++++++ 6 files changed, 233 insertions(+), 2 deletions(-) create mode 100644 src/gui/kernel/qinputdevicemanager.cpp create mode 100644 src/gui/kernel/qinputdevicemanager_p.h create mode 100644 src/gui/kernel/qinputdevicemanager_p_p.h (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 6479acd3fc..41574fa0bb 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -74,7 +74,9 @@ HEADERS += \ kernel/qpaintdevicewindow_p.h \ kernel/qrasterwindow.h \ kernel/qplatformgraphicsbuffer.h \ - kernel/qplatformgraphicsbufferhelper.h + kernel/qplatformgraphicsbufferhelper.h \ + kernel/qinputdevicemanager_p.h \ + kernel/qinputdevicemanager_p_p.h SOURCES += \ kernel/qgenericpluginfactory.cpp \ @@ -130,7 +132,8 @@ SOURCES += \ kernel/qrasterwindow.cpp \ kernel/qplatformgraphicsbuffer.cpp \ kernel/qplatformgraphicsbufferhelper.cpp \ - kernel/qplatformhardwarecompositor.cpp + kernel/qplatformhardwarecompositor.cpp \ + kernel/qinputdevicemanager.cpp contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2) { HEADERS += \ diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index a2953259ff..23deb2c4b2 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -75,6 +75,7 @@ #include "private/qwindow_p.h" #include "private/qcursor_p.h" #include "private/qopenglcontext_p.h" +#include "private/qinputdevicemanager_p.h" #include "private/qdnd_p.h" #include @@ -164,6 +165,8 @@ static QBasicMutex applicationFontMutex; QFont *QGuiApplicationPrivate::app_font = 0; bool QGuiApplicationPrivate::obey_desktop_settings = true; +QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = 0; + static qreal fontSmoothingGamma = 1.7; extern void qRegisterGuiVariant(); @@ -3470,6 +3473,16 @@ void QGuiApplicationPrivate::setMouseEventFlags(QMouseEvent *event, Qt::MouseEve event->caps |= (value & Qt::MouseEventFlagMask) << MouseFlagsShift; } +QInputDeviceManager *QGuiApplicationPrivate::inputDeviceManager() +{ + Q_ASSERT(QGuiApplication::instance()); + + if (!m_inputDeviceManager) + m_inputDeviceManager = new QInputDeviceManager(QGuiApplication::instance()); + + return m_inputDeviceManager; +} + #include "moc_qguiapplication.cpp" QT_END_NAMESPACE diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 8b444e1d34..471316d7ed 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -66,6 +66,7 @@ struct QDrawHelperGammaTables; #ifndef QT_NO_DRAGANDDROP class QDrag; #endif // QT_NO_DRAGANDDROP +class QInputDeviceManager; class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate { @@ -272,6 +273,8 @@ public: static Qt::MouseEventSource wheelEventSource(const QWheelEvent *event); + static QInputDeviceManager *inputDeviceManager(); + const QDrawHelperGammaTables *gammaTables(); // hook reimplemented in QApplication to apply the QStyle function on the QIcon @@ -301,6 +304,8 @@ private: QAtomicPointer m_gammaTables; bool ownGlobalShareContext; + + static QInputDeviceManager *m_inputDeviceManager; }; Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k); diff --git a/src/gui/kernel/qinputdevicemanager.cpp b/src/gui/kernel/qinputdevicemanager.cpp new file mode 100644 index 0000000000..925a89c85b --- /dev/null +++ b/src/gui/kernel/qinputdevicemanager.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qinputdevicemanager_p.h" +#include "qinputdevicemanager_p_p.h" + +QT_BEGIN_NAMESPACE + +QInputDeviceManager::QInputDeviceManager(QObject *parent) + : QObject(*new QInputDeviceManagerPrivate, parent) +{ +} + +int QInputDeviceManager::deviceCount(DeviceType type) const +{ + Q_D(const QInputDeviceManager); + return d->deviceCount(type); +} + +int QInputDeviceManagerPrivate::deviceCount(QInputDeviceManager::DeviceType type) const +{ + return m_deviceCount.value(type); +} + +void QInputDeviceManagerPrivate::setDeviceCount(QInputDeviceManager::DeviceType type, int count) +{ + Q_Q(QInputDeviceManager); + if (m_deviceCount.value(type) != count) { + m_deviceCount[type] = count; + emit q->deviceListChanged(type); + } +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h new file mode 100644 index 0000000000..ca334e4645 --- /dev/null +++ b/src/gui/kernel/qinputdevicemanager_p.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QINPUTDEVICEMANAGER_P_H +#define QINPUTDEVICEMANAGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QInputDeviceManagerPrivate; + +class Q_GUI_EXPORT QInputDeviceManager : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QInputDeviceManager) + +public: + enum DeviceType { + DeviceTypeUnknown, + DeviceTypePointer, + DeviceTypeKeyboard, + DeviceTypeTouch + }; + + QInputDeviceManager(QObject *parent = 0); + + int deviceCount(DeviceType type) const; + +signals: + void deviceListChanged(DeviceType type); +}; + +QT_END_NAMESPACE + +#endif // QINPUTDEVICEMANAGER_P_H diff --git a/src/gui/kernel/qinputdevicemanager_p_p.h b/src/gui/kernel/qinputdevicemanager_p_p.h new file mode 100644 index 0000000000..7583fbe030 --- /dev/null +++ b/src/gui/kernel/qinputdevicemanager_p_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QINPUTDEVICEMANAGER_P_P_H +#define QINPUTDEVICEMANAGER_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include "qinputdevicemanager_p.h" + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QInputDeviceManagerPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QInputDeviceManager) + +public: + static QInputDeviceManagerPrivate *get(QInputDeviceManager *mgr) { return mgr->d_func(); } + + int deviceCount(QInputDeviceManager::DeviceType type) const; + void setDeviceCount(QInputDeviceManager::DeviceType type, int count); + + QMap m_deviceCount; +}; + +QT_END_NAMESPACE + +#endif // QINPUTDEVICEMANAGER_P_P_H -- cgit v1.2.3