diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-01-09 14:48:01 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-01-21 12:32:04 +0100 |
commit | 10472dce9202e4460b2d908bdbe0cd65291f77e5 (patch) | |
tree | 4a0d970fcedb4e7b0b01c3f65cd9c7886473dfe0 /src/platformsupport/input | |
parent | f93c04e44a5bd08fea76a1147b1aa51953bce925 (diff) |
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 <andy.nichols@theqtcompany.com>
Diffstat (limited to 'src/platformsupport/input')
5 files changed, 59 insertions, 8 deletions
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp index 4614fbd499..8853da8371 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp @@ -37,6 +37,9 @@ #include <QCoreApplication> #include <QLoggingCategory> +#include <private/qguiapplication_p.h> +#include <private/qinputdevicemanager_p_p.h> + QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(qLcEvdevKey) @@ -97,10 +100,13 @@ void QEvdevKeyboardManager::addKeyboard(const QString &deviceNode) qCDebug(qLcEvdevKey) << "Adding keyboard at" << deviceNode; QEvdevKeyboardHandler *keyboard; keyboard = QEvdevKeyboardHandler::create(deviceNode, m_spec, m_defaultKeymapFile); - if (keyboard) + if (keyboard) { m_keyboards.insert(deviceNode, keyboard); - else + QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount( + QInputDeviceManager::DeviceTypeKeyboard, m_keyboards.count()); + } else { qWarning("Failed to open keyboard device %s", qPrintable(deviceNode)); + } } void QEvdevKeyboardManager::removeKeyboard(const QString &deviceNode) @@ -109,6 +115,8 @@ void QEvdevKeyboardManager::removeKeyboard(const QString &deviceNode) qCDebug(qLcEvdevKey) << "Removing keyboard at" << deviceNode; QEvdevKeyboardHandler *keyboard = m_keyboards.value(deviceNode); m_keyboards.remove(deviceNode); + QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount( + QInputDeviceManager::DeviceTypeKeyboard, m_keyboards.count()); delete keyboard; } } diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp index a0c9c9f34d..17e6b0cafa 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp @@ -38,6 +38,9 @@ #include <QScreen> #include <QLoggingCategory> #include <qpa/qwindowsysteminterface.h> +#include <QtPlatformSupport/private/qdevicediscovery_p.h> +#include <private/qguiapplication_p.h> +#include <private/qinputdevicemanager_p_p.h> QT_BEGIN_NAMESPACE @@ -141,6 +144,8 @@ void QEvdevMouseManager::addMouse(const QString &deviceNode) connect(handler, SIGNAL(handleMouseEvent(int,int,bool,Qt::MouseButtons)), this, SLOT(handleMouseEvent(int,int,bool,Qt::MouseButtons))); connect(handler, SIGNAL(handleWheelEvent(int,Qt::Orientation)), this, SLOT(handleWheelEvent(int,Qt::Orientation))); m_mice.insert(deviceNode, handler); + QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount( + QInputDeviceManager::DeviceTypePointer, m_mice.count()); } else { qWarning("evdevmouse: Failed to open mouse device %s", qPrintable(deviceNode)); } @@ -152,6 +157,8 @@ void QEvdevMouseManager::removeMouse(const QString &deviceNode) qCDebug(qLcEvdevMouse) << "Removing mouse at" << deviceNode; QEvdevMouseHandler *handler = m_mice.value(deviceNode); m_mice.remove(deviceNode); + QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount( + QInputDeviceManager::DeviceTypePointer, m_mice.count()); delete handler; } } diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h index 14aa6a8fd2..d30a2b337f 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h @@ -47,14 +47,14 @@ #include "qevdevmousehandler_p.h" -#include <QtPlatformSupport/private/qdevicediscovery_p.h> - #include <QObject> #include <QHash> #include <QSocketNotifier> QT_BEGIN_NAMESPACE +class QDeviceDiscovery; + class QEvdevMouseManager : public QObject { Q_OBJECT @@ -62,8 +62,6 @@ public: QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent = 0); ~QEvdevMouseManager(); - QDeviceDiscovery *deviceDiscovery() { return m_deviceDiscovery; } - public slots: void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons); void handleWheelEvent(int delta, Qt::Orientation orientation); diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp index cab4527d0a..0ed605019c 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler.cpp +++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp @@ -41,6 +41,8 @@ #include <QtCore/QLoggingCategory> #include <QtCore/QSocketNotifier> #include <QtCore/private/qcore_unix_p.h> +#include <private/qguiapplication_p.h> +#include <private/qinputdevicemanager_p_p.h> QT_BEGIN_NAMESPACE @@ -146,8 +148,25 @@ void QLibInputHandler::processEvent(libinput_event *ev) const char *sysname = libinput_device_get_sysname(dev); // node name without path const char *name = libinput_device_get_name(dev); emit deviceAdded(QString::fromUtf8(sysname), QString::fromUtf8(name)); - if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) + + QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get( + QGuiApplicationPrivate::inputDeviceManager()); + if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) { m_touch->registerDevice(dev); + int &count(m_devCount[QInputDeviceManager::DeviceTypeTouch]); + ++count; + inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeTouch, count); + } + if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_POINTER)) { + int &count(m_devCount[QInputDeviceManager::DeviceTypePointer]); + ++count; + inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypePointer, count); + } + if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) { + int &count(m_devCount[QInputDeviceManager::DeviceTypeKeyboard]); + ++count; + inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeKeyboard, count); + } break; } case LIBINPUT_EVENT_DEVICE_REMOVED: @@ -155,8 +174,25 @@ void QLibInputHandler::processEvent(libinput_event *ev) const char *sysname = libinput_device_get_sysname(dev); const char *name = libinput_device_get_name(dev); emit deviceRemoved(QString::fromUtf8(sysname), QString::fromUtf8(name)); - if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) + + QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get( + QGuiApplicationPrivate::inputDeviceManager()); + if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) { m_touch->unregisterDevice(dev); + int &count(m_devCount[QInputDeviceManager::DeviceTypeTouch]); + --count; + inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeTouch, count); + } + if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_POINTER)) { + int &count(m_devCount[QInputDeviceManager::DeviceTypePointer]); + --count; + inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypePointer, count); + } + if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) { + int &count(m_devCount[QInputDeviceManager::DeviceTypeKeyboard]); + --count; + inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeKeyboard, count); + } break; } case LIBINPUT_EVENT_POINTER_BUTTON: diff --git a/src/platformsupport/input/libinput/qlibinputhandler_p.h b/src/platformsupport/input/libinput/qlibinputhandler_p.h index a1cfaca3ce..6d376c4ca3 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler_p.h +++ b/src/platformsupport/input/libinput/qlibinputhandler_p.h @@ -36,6 +36,7 @@ #include <QtCore/QObject> #include <QtCore/QScopedPointer> +#include <QtCore/QMap> // // W A R N I N G @@ -84,6 +85,7 @@ private: QScopedPointer<QLibInputPointer> m_pointer; QScopedPointer<QLibInputKeyboard> m_keyboard; QScopedPointer<QLibInputTouch> m_touch; + QMap<int, int> m_devCount; }; QT_END_NAMESPACE |