From 6953f3a501dfee5064a12558a2e2515b69b35189 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 27 Jan 2014 13:40:42 +0100 Subject: eglfs: Mouse hotplugging support On Embedded Linux with libudev support hotplugging was already working, except that the mouse cursor was not shown and hidden. This is now corrected so that the cursor disappears when all mice become disconnected and reappears if a mouse gets plugged in later on. [ChangeLog][QtGui] Mouse hotplugging is now fully supported in eglfs when running on Embedded Linux systems with libudev support enabled. Task-number: QTBUG-36374 Change-Id: Iec7c1557ba6085e3958dd357460cc032896fb174 Reviewed-by: Andy Nichols --- .../eglconvenience/qeglplatformcursor.cpp | 52 +++++++++++++++++++--- 1 file changed, 45 insertions(+), 7 deletions(-) (limited to 'src/platformsupport/eglconvenience/qeglplatformcursor.cpp') diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp index 55590dbc9e..1c87e1d27d 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include "qeglplatformcursor_p.h" #include #include #include @@ -50,6 +49,9 @@ #include +#include "qeglplatformcursor_p.h" +#include "qeglplatformintegration_p.h" + QT_BEGIN_NAMESPACE /*! @@ -66,15 +68,12 @@ QEGLPlatformCursor::QEGLPlatformCursor(QPlatformScreen *screen) m_program(0), m_vertexCoordEntry(0), m_textureCoordEntry(0), - m_textureEntry(0) + m_textureEntry(0), + m_deviceListener(0) { QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR"); - if (hideCursorVal.isEmpty()) { - QScopedPointer dis(QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse)); - m_visible = !dis->scanConnectedDevices().isEmpty(); - } else { + if (!hideCursorVal.isEmpty()) m_visible = hideCursorVal.toInt() == 0; - } if (!m_visible) return; @@ -92,6 +91,45 @@ QEGLPlatformCursor::QEGLPlatformCursor(QPlatformScreen *screen) QEGLPlatformCursor::~QEGLPlatformCursor() { resetResources(); + 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(); +} + +void QEGLPlatformCursorDeviceListener::onDeviceRemoved() +{ + --m_mouseCount; + m_cursor->updateMouseStatus(); } void QEGLPlatformCursor::resetResources() -- cgit v1.2.3