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>
This commit is contained in:
Laszlo Agocs 2014-04-28 12:19:28 +02:00 committed by The Qt Project
parent 2222fdf330
commit 485b7424df
2 changed files with 43 additions and 3 deletions

View File

@ -69,7 +69,8 @@ QEGLPlatformCursor::QEGLPlatformCursor(QPlatformScreen *screen)
m_vertexCoordEntry(0), m_vertexCoordEntry(0),
m_textureCoordEntry(0), m_textureCoordEntry(0),
m_textureEntry(0), m_textureEntry(0),
m_deviceListener(0) m_deviceListener(0),
m_updater(screen)
{ {
QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR"); QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR");
if (!hideCursorVal.isEmpty()) if (!hideCursorVal.isEmpty())
@ -270,10 +271,30 @@ bool QEGLPlatformCursor::setCurrentCursor(QCursor *cursor)
} }
#endif #endif
void QEGLPlatformCursorUpdater::update(const QPoint &pos, const QRegion &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) void QEGLPlatformCursor::update(const QRegion &rgn)
{ {
QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(m_cursor.pos), rgn); m_updater.scheduleUpdate(m_cursor.pos, rgn);
QWindowSystemInterface::flushWindowSystemEvents();
} }
QRect QEGLPlatformCursor::cursorRect() const QRect QEGLPlatformCursor::cursorRect() const

View File

@ -68,6 +68,24 @@ private:
int m_mouseCount; 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 class QEGLPlatformCursor : public QPlatformCursor
{ {
public: public:
@ -130,6 +148,7 @@ private:
int m_textureCoordEntry; int m_textureCoordEntry;
int m_textureEntry; int m_textureEntry;
QEGLPlatformCursorDeviceListener *m_deviceListener; QEGLPlatformCursorDeviceListener *m_deviceListener;
QEGLPlatformCursorUpdater m_updater;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE