summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/eglconvenience
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-01-09 14:48:01 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-01-21 12:32:04 +0100
commit10472dce9202e4460b2d908bdbe0cd65291f77e5 (patch)
tree4a0d970fcedb4e7b0b01c3f65cd9c7886473dfe0 /src/platformsupport/eglconvenience
parentf93c04e44a5bd08fea76a1147b1aa51953bce925 (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/eglconvenience')
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcursor.cpp37
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcursor_p.h11
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformintegration.cpp7
3 files changed, 15 insertions, 40 deletions
diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
index cf41bd2f1b..b07f8cd470 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
@@ -39,7 +39,7 @@
#include <QtCore/QJsonObject>
#include <QtDebug>
-#include <QtPlatformSupport/private/qdevicediscovery_p.h>
+#include <QtGui/private/qguiapplication_p.h>
#include "qeglplatformcursor_p.h"
#include "qeglplatformintegration_p.h"
@@ -79,6 +79,11 @@ QEGLPlatformCursor::QEGLPlatformCursor(QPlatformScreen *screen)
QCursor cursor(Qt::ArrowCursor);
setCurrentCursor(&cursor);
#endif
+
+ m_deviceListener = new QEGLPlatformCursorDeviceListener(this);
+ connect(QGuiApplicationPrivate::inputDeviceManager(), &QInputDeviceManager::deviceListChanged,
+ m_deviceListener, &QEGLPlatformCursorDeviceListener::onDeviceListChanged);
+ updateMouseStatus();
}
QEGLPlatformCursor::~QEGLPlatformCursor()
@@ -87,42 +92,20 @@ QEGLPlatformCursor::~QEGLPlatformCursor()
delete m_deviceListener;
}
-void QEGLPlatformCursor::setMouseDeviceDiscovery(QDeviceDiscovery *dd)
-{
- if (m_visible && dd) {
- m_deviceListener = new QEGLPlatformCursorDeviceListener(dd, this);
- updateMouseStatus();
- }
-}
-
void QEGLPlatformCursor::updateMouseStatus()
{
m_visible = m_deviceListener->hasMouse();
}
-QEGLPlatformCursorDeviceListener::QEGLPlatformCursorDeviceListener(QDeviceDiscovery *dd, QEGLPlatformCursor *cursor)
- : m_cursor(cursor)
-{
- m_mouseCount = dd->scanConnectedDevices().count();
- connect(dd, SIGNAL(deviceDetected(QString)), SLOT(onDeviceAdded()));
- connect(dd, SIGNAL(deviceRemoved(QString)), SLOT(onDeviceRemoved()));
-}
-
bool QEGLPlatformCursorDeviceListener::hasMouse() const
{
- return m_mouseCount > 0;
-}
-
-void QEGLPlatformCursorDeviceListener::onDeviceAdded()
-{
- ++m_mouseCount;
- m_cursor->updateMouseStatus();
+ return QGuiApplicationPrivate::inputDeviceManager()->deviceCount(QInputDeviceManager::DeviceTypePointer) > 0;
}
-void QEGLPlatformCursorDeviceListener::onDeviceRemoved()
+void QEGLPlatformCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::DeviceType type)
{
- --m_mouseCount;
- m_cursor->updateMouseStatus();
+ if (type == QInputDeviceManager::DeviceTypePointer)
+ m_cursor->updateMouseStatus();
}
void QEGLPlatformCursor::resetResources()
diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
index bf2aeef378..8d111e26ed 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
+++ b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
@@ -48,11 +48,11 @@
#include <qpa/qplatformcursor.h>
#include <qpa/qplatformscreen.h>
#include <QtGui/QOpenGLFunctions>
+#include <QtGui/private/qinputdevicemanager_p.h>
QT_BEGIN_NAMESPACE
class QOpenGLShaderProgram;
-class QDeviceDiscovery;
class QEGLPlatformCursor;
class QEGLPlatformCursorDeviceListener : public QObject
@@ -60,16 +60,14 @@ class QEGLPlatformCursorDeviceListener : public QObject
Q_OBJECT
public:
- QEGLPlatformCursorDeviceListener(QDeviceDiscovery *dd, QEGLPlatformCursor *cursor);
+ QEGLPlatformCursorDeviceListener(QEGLPlatformCursor *cursor) : m_cursor(cursor) { }
bool hasMouse() const;
-private slots:
- void onDeviceAdded();
- void onDeviceRemoved();
+public slots:
+ void onDeviceListChanged(QInputDeviceManager::DeviceType type);
private:
QEGLPlatformCursor *m_cursor;
- int m_mouseCount;
};
class QEGLPlatformCursorUpdater : public QObject
@@ -108,7 +106,6 @@ public:
void paintOnScreen();
void resetResources();
- void setMouseDeviceDiscovery(QDeviceDiscovery *dd);
void updateMouseStatus();
private:
diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp
index e2a215d35f..ef794f0e1b 100644
--- a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp
@@ -352,12 +352,7 @@ void QEGLPlatformIntegration::createInputHandlers()
{
#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
m_kbdMgr = new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this);
- QEvdevMouseManager *mouseMgr = new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this);
- Q_FOREACH (QScreen *screen, QGuiApplication::screens()) {
- QEGLPlatformCursor *cursor = qobject_cast<QEGLPlatformCursor *>(screen->handle()->cursor());
- if (cursor)
- cursor->setMouseDeviceDiscovery(mouseMgr->deviceDiscovery());
- }
+ new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this);
#ifndef QT_NO_TSLIB
const bool useTslib = qEnvironmentVariableIntValue("QT_QPA_EGLFS_TSLIB");
if (useTslib)