summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-04-28 12:19:28 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-28 19:49:26 +0200
commit485b7424df5cb3474cc802bced77770d85bdcb37 (patch)
tree2492e05e2dc114de3bcf90e626a733f8928474ce /src/platformsupport
parent2222fdf3304e921b7441932827da72a46418b649 (diff)
Avoid reentering processMouseEvents on embedded
Task-number: QTBUG-38597 Change-Id: I168c9401863bace711d0d8409bf3da30a34185bd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcursor.cpp27
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcursor_p.h19
2 files changed, 43 insertions, 3 deletions
diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
index 70e7c4e4db..e99581183e 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
@@ -69,7 +69,8 @@ QEGLPlatformCursor::QEGLPlatformCursor(QPlatformScreen *screen)
m_vertexCoordEntry(0),
m_textureCoordEntry(0),
m_textureEntry(0),
- m_deviceListener(0)
+ m_deviceListener(0),
+ m_updater(screen)
{
QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR");
if (!hideCursorVal.isEmpty())
@@ -270,12 +271,32 @@ bool QEGLPlatformCursor::setCurrentCursor(QCursor *cursor)
}
#endif
-void QEGLPlatformCursor::update(const QRegion &rgn)
+void QEGLPlatformCursorUpdater::update(const QPoint &pos, const QRegion &rgn)
{
- QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(m_cursor.pos), rgn);
+ m_active = false;
+ QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(pos), rgn);
QWindowSystemInterface::flushWindowSystemEvents();
}
+void QEGLPlatformCursorUpdater::scheduleUpdate(const QPoint &pos, const QRegion &rgn)
+{
+ if (m_active)
+ return;
+
+ m_active = true;
+
+ // Must not flush the window system events directly from here since we are likely to
+ // be a called directly from QGuiApplication's processMouseEvents. Flushing events
+ // could cause reentering by dispatching more queued mouse events.
+ QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection,
+ Q_ARG(QPoint, pos), Q_ARG(QRegion, rgn));
+}
+
+void QEGLPlatformCursor::update(const QRegion &rgn)
+{
+ m_updater.scheduleUpdate(m_cursor.pos, rgn);
+}
+
QRect QEGLPlatformCursor::cursorRect() const
{
return QRect(m_cursor.pos - m_cursor.hotSpot, m_cursor.size);
diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
index c9ff9a1198..6f4216874a 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
+++ b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
@@ -68,6 +68,24 @@ private:
int m_mouseCount;
};
+class QEGLPlatformCursorUpdater : public QObject
+{
+ Q_OBJECT
+
+public:
+ QEGLPlatformCursorUpdater(QPlatformScreen *screen)
+ : m_screen(screen), m_active(false) { }
+
+ void scheduleUpdate(const QPoint &pos, const QRegion &rgn);
+
+private slots:
+ void update(const QPoint &pos, const QRegion &rgn);
+
+private:
+ QPlatformScreen *m_screen;
+ bool m_active;
+};
+
class QEGLPlatformCursor : public QPlatformCursor
{
public:
@@ -130,6 +148,7 @@ private:
int m_textureCoordEntry;
int m_textureEntry;
QEGLPlatformCursorDeviceListener *m_deviceListener;
+ QEGLPlatformCursorUpdater m_updater;
};
QT_END_NAMESPACE