summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/platformsupport/eglconvenience/eglconvenience.pri3
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcursor.cpp52
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcursor_p.h23
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformintegration.cpp22
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformintegration_p.h2
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h2
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp18
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.h2
8 files changed, 98 insertions, 26 deletions
diff --git a/src/platformsupport/eglconvenience/eglconvenience.pri b/src/platformsupport/eglconvenience/eglconvenience.pri
index 4af0df58c7..6da0ea4fd1 100644
--- a/src/platformsupport/eglconvenience/eglconvenience.pri
+++ b/src/platformsupport/eglconvenience/eglconvenience.pri
@@ -27,6 +27,9 @@ contains(QT_CONFIG,egl) {
$$PWD/qeglplatformintegration.cpp
}
+ # Avoid X11 header collision
+ DEFINES += MESA_EGL_NO_X11_HEADERS
+
contains(QT_CONFIG,xlib) {
HEADERS += \
$$PWD/qxlibeglintegration_p.h
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 <qpa/qwindowsysteminterface.h>
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLShaderProgram>
@@ -50,6 +49,9 @@
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
+#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<QDeviceDiscovery> 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()
diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
index 52359b84cd..d1402d1457 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
+++ b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
@@ -48,6 +48,25 @@
QT_BEGIN_NAMESPACE
class QOpenGLShaderProgram;
+class QDeviceDiscovery;
+class QEGLPlatformCursor;
+
+class QEGLPlatformCursorDeviceListener : public QObject
+{
+ Q_OBJECT
+
+public:
+ QEGLPlatformCursorDeviceListener(QDeviceDiscovery *dd, QEGLPlatformCursor *cursor);
+ bool hasMouse() const;
+
+private slots:
+ void onDeviceAdded();
+ void onDeviceRemoved();
+
+private:
+ QEGLPlatformCursor *m_cursor;
+ int m_mouseCount;
+};
class QEGLPlatformCursor : public QPlatformCursor
{
@@ -66,6 +85,9 @@ public:
void paintOnScreen();
void resetResources();
+ void setMouseDeviceDiscovery(QDeviceDiscovery *dd);
+ void updateMouseStatus();
+
private:
#ifndef QT_NO_CURSOR
bool setCurrentCursor(QCursor *cursor);
@@ -107,6 +129,7 @@ private:
int m_vertexCoordEntry;
int m_textureCoordEntry;
int m_textureEntry;
+ QEGLPlatformCursorDeviceListener *m_deviceListener;
};
QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp
index 343375a14a..5fc1721f6c 100644
--- a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp
@@ -41,6 +41,7 @@
#include <QtGui/QWindow>
#include <QtGui/QOpenGLContext>
+#include <QtGui/QGuiApplication>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatforminputcontextfactory_p.h>
@@ -49,11 +50,18 @@
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
#include <QtPlatformSupport/private/qfbvthandler_p.h>
+#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
+#include <QtPlatformSupport/private/qevdevmousemanager_p.h>
+#include <QtPlatformSupport/private/qevdevkeyboardmanager_p.h>
+#include <QtPlatformSupport/private/qevdevtouch_p.h>
+#endif
+
#include "qeglplatformintegration_p.h"
#include "qeglplatformcontext_p.h"
#include "qeglplatformwindow_p.h"
#include "qeglplatformbackingstore_p.h"
#include "qeglplatformscreen_p.h"
+#include "qeglplatformcursor_p.h"
QT_BEGIN_NAMESPACE
@@ -256,4 +264,18 @@ QPlatformNativeInterface::NativeResourceForContextFunction QEGLPlatformIntegrati
return 0;
}
+void QEGLPlatformIntegration::createInputHandlers()
+{
+#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
+ new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this);
+ QEvdevMouseManager *mouseMgr = new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this);
+ Q_FOREACH (QScreen *screen, QGuiApplication::screens()) {
+ QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(screen->handle()->cursor());
+ if (cursor)
+ cursor->setMouseDeviceDiscovery(mouseMgr->deviceDiscovery());
+ }
+ new QEvdevTouchScreenHandlerThread(QString() /* spec */, this);
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration_p.h b/src/platformsupport/eglconvenience/qeglplatformintegration_p.h
index a5b131ced6..d3c3f07aff 100644
--- a/src/platformsupport/eglconvenience/qeglplatformintegration_p.h
+++ b/src/platformsupport/eglconvenience/qeglplatformintegration_p.h
@@ -85,6 +85,8 @@ protected:
virtual QEGLPlatformWindow *createWindow(QWindow *window) const = 0;
virtual EGLNativeDisplayType nativeDisplay() const { return EGL_DEFAULT_DISPLAY; }
+ void createInputHandlers();
+
private:
QEGLPlatformScreen *m_screen;
EGLDisplay m_display;
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h
index 6abe933371..d52a16ea75 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h
+++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h
@@ -59,6 +59,8 @@ 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, Qt::MouseButtons buttons);
void handleWheelEvent(int delta, Qt::Orientation orientation);
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
index dfe240a888..472e58cc72 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
@@ -43,6 +43,7 @@
#include "qeglfswindow.h"
#include "qeglfshooks.h"
+#include "qeglfscontext.h"
#include <QtGui/private/qguiapplication_p.h>
@@ -50,12 +51,6 @@
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
#include <QtPlatformSupport/private/qeglpbuffer_p.h>
-#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
-#include <QtPlatformSupport/private/qevdevmousemanager_p.h>
-#include <QtPlatformSupport/private/qevdevkeyboardmanager_p.h>
-#include <QtPlatformSupport/private/qevdevtouch_p.h>
-#endif
-
#include <qpa/qplatformwindow.h>
#include <QtGui/QSurfaceFormat>
#include <QtGui/QOpenGLContext>
@@ -63,8 +58,6 @@
#include <QtGui/QOffscreenSurface>
#include <qpa/qplatformcursor.h>
-#include "qeglfscontext.h"
-
#include <EGL/egl.h>
static void initResources()
@@ -167,13 +160,4 @@ EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceForm
return chooser.chooseConfig();
}
-void QEglFSIntegration::createInputHandlers()
-{
-#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
- new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this);
- new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this);
- new QEvdevTouchScreenHandlerThread(QString() /* spec */, this);
-#endif
-}
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h
index 581b523c76..9ff5bd6f3b 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.h
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.h
@@ -70,8 +70,6 @@ protected:
EGLNativeDisplayType nativeDisplay() const Q_DECL_OVERRIDE;
private:
- void createInputHandlers();
-
bool mDisableInputHandlers;
};