Remove handleSynchronous* functions.
authorMorten Johan Sorvig <morten.sorvig@nokia.com>
Thu, 27 Sep 2012 08:37:30 +0000 (10:37 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 10 Oct 2012 17:49:22 +0000 (19:49 +0200)
There are now two different ways to implement synchronous
event processing. The platform plugins can choose which
one to use.

1) flushWindowSystemEvents()
   Use to flush the event queue at one point, making
   preceding calls synchronous.

2) setSynchronousWindowsSystemEvents(bool enable)
   Makes all handle* functions synchronous, bypassing
   the event queue completely.

Change-Id: I020b80c731fd13f855a377d7c91d06a4e39b6a0b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
src/gui/kernel/qplatformwindow.cpp
src/gui/kernel/qwindowsysteminterface.cpp
src/gui/kernel/qwindowsysteminterface.h
src/gui/kernel/qwindowsysteminterface_p.h
src/plugins/platforms/cocoa/qcocoawindow.mm
src/plugins/platforms/cocoa/qnsview.mm
src/plugins/platforms/eglfs/qeglfscursor.cpp
src/plugins/platforms/qnx/qqnxwindow.cpp
src/plugins/platforms/windows/qwindowswindow.cpp
tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp

index cdf5c61..755fd8a 100644 (file)
@@ -139,7 +139,8 @@ void QPlatformWindow::setVisible(bool visible)
 {
     Q_UNUSED(visible);
     QRect rect(QPoint(), geometry().size());
-    QWindowSystemInterface::handleSynchronousExposeEvent(window(), rect);
+    QWindowSystemInterface::handleExposeEvent(window(), rect);
+    QWindowSystemInterface::flushWindowSystemEvents();
 }
 /*!
     Requests setting the window flags of this surface
index 5ae55d6..d05dc8c 100644 (file)
@@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE
 
 
 QElapsedTimer QWindowSystemInterfacePrivate::eventTime;
+bool QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents = false;
 
 //------------------------------------------------------------
 //
@@ -78,39 +79,33 @@ void QWindowSystemInterface::handleEnterEvent(QWindow *tlw)
 {
     if (tlw) {
         QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw);
-        QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+        QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
     }
 }
 
 void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw)
 {
     QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleWindowActivated(QWindow *tlw)
 {
     QWindowSystemInterfacePrivate::ActivatedWindowEvent *e = new QWindowSystemInterfacePrivate::ActivatedWindowEvent(tlw);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleWindowStateChanged(QWindow *tlw, Qt::WindowState newState)
 {
     QWindowSystemInterfacePrivate::WindowStateChangedEvent *e =
         new QWindowSystemInterfacePrivate::WindowStateChangedEvent(tlw, newState);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &newRect)
 {
     QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-void QWindowSystemInterface::handleSynchronousGeometryChange(QWindow *tlw, const QRect &newRect)
-{
-    handleGeometryChange(tlw, newRect);
-    QWindowSystemInterface::flushWindowSystemEvents();
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleCloseEvent(QWindow *tlw)
@@ -118,15 +113,7 @@ void QWindowSystemInterface::handleCloseEvent(QWindow *tlw)
     if (tlw) {
         QWindowSystemInterfacePrivate::CloseEvent *e =
                 new QWindowSystemInterfacePrivate::CloseEvent(tlw);
-        QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-    }
-}
-
-void QWindowSystemInterface::handleSynchronousCloseEvent(QWindow *tlw)
-{
-    if (tlw) {
-        handleCloseEvent(tlw);
-        QWindowSystemInterface::flushWindowSystemEvents();
+        QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
     }
 }
 
@@ -145,7 +132,7 @@ void QWindowSystemInterface::handleMouseEvent(QWindow *w, ulong timestamp, const
 {
     QWindowSystemInterfacePrivate::MouseEvent * e =
             new QWindowSystemInterfacePrivate::MouseEvent(w, timestamp, local, global, b, mods);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
@@ -160,17 +147,17 @@ void QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *w, ulong timest
             new QWindowSystemInterfacePrivate::MouseEvent(w, timestamp,
                                                           QWindowSystemInterfacePrivate::FrameStrutMouse,
                                                           local, global, b, mods);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
-bool QWindowSystemInterface::tryHandleSynchronousShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
+bool QWindowSystemInterface::tryHandleShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
                                                                const QString & text, bool autorep, ushort count)
 {
     unsigned long timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed();
-    return tryHandleSynchronousShortcutEvent(w, timestamp, k, mods, text, autorep, count);
+    return tryHandleShortcutEvent(w, timestamp, k, mods, text, autorep, count);
 }
 
-bool QWindowSystemInterface::tryHandleSynchronousShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
+bool QWindowSystemInterface::tryHandleShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
                                                                const QString & text, bool autorep, ushort count)
 {
 #ifndef QT_NO_SHORTCUT
@@ -191,15 +178,15 @@ bool QWindowSystemInterface::tryHandleSynchronousShortcutEvent(QWindow *w, ulong
 #endif
 }
 
-bool QWindowSystemInterface::tryHandleSynchronousExtendedShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
+bool QWindowSystemInterface::tryHandleExtendedShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
                                                                        quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
                                                                        const QString &text, bool autorep, ushort count)
 {
     unsigned long timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed();
-    return tryHandleSynchronousExtendedShortcutEvent(w, timestamp, k, mods, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
+    return tryHandleExtendedShortcutEvent(w, timestamp, k, mods, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
 }
 
-bool QWindowSystemInterface::tryHandleSynchronousExtendedShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
+bool QWindowSystemInterface::tryHandleExtendedShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
                                                                        quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
                                                                        const QString &text, bool autorep, ushort count)
 {
@@ -234,7 +221,7 @@ void QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEven
 {
     QWindowSystemInterfacePrivate::KeyEvent * e =
             new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
@@ -258,7 +245,7 @@ void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestam
     QWindowSystemInterfacePrivate::KeyEvent * e =
             new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
                 nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods) {
@@ -295,14 +282,14 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, con
     // Simple case: vertical deltas only:
     if (angleDelta.y() != 0 && angleDelta.x() == 0) {
         e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods);
-        QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+        QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
         return;
     }
 
     // Simple case: horizontal deltas only:
     if (angleDelta.y() == 0 && angleDelta.x() != 0) {
         e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods);
-        QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+        QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
         return;
     }
 
@@ -310,12 +297,12 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, con
     // The first event contains the Qt 5 pixel and angle delta as points,
     // and in addition the Qt 4 compatibility vertical angle delta.
     e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 
     // The second event contains null pixel and angle points and the
     // Qt 4 compatibility horizontal angle delta.
     e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 
@@ -337,13 +324,16 @@ QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate
     return windowSystemEventQueue.takeFirstOrReturnNull();
 }
 
-void QWindowSystemInterfacePrivate::queueWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
+void QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
 {
-    windowSystemEventQueue.append(ev);
-
-    QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher();
-    if (dispatcher)
-        dispatcher->wakeUp();
+    if (synchronousWindowsSystemEvents) {
+        QGuiApplicationPrivate::processWindowSystemEvent(ev);
+    } else {
+        windowSystemEventQueue.append(ev);
+        QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher();
+        if (dispatcher)
+            dispatcher->wakeUp();
+    }
 }
 
 void QWindowSystemInterface::registerTouchDevice(QTouchDevice *device)
@@ -414,7 +404,7 @@ void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTo
 
     QWindowSystemInterfacePrivate::TouchEvent *e =
             new QWindowSystemInterfacePrivate::TouchEvent(tlw, timestamp, type, device, touchPoints, mods);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, QTouchDevice *device,
@@ -430,60 +420,54 @@ void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, ulong timestamp,
     QWindowSystemInterfacePrivate::TouchEvent *e =
             new QWindowSystemInterfacePrivate::TouchEvent(w, timestamp, QEvent::TouchCancel, device,
                                                          QList<QTouchEvent::TouchPoint>(), mods);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation orientation)
 {
     QWindowSystemInterfacePrivate::ScreenOrientationEvent *e =
             new QWindowSystemInterfacePrivate::ScreenOrientationEvent(screen, orientation);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleScreenGeometryChange(QScreen *screen, const QRect &geometry)
 {
     QWindowSystemInterfacePrivate::ScreenGeometryEvent *e =
             new QWindowSystemInterfacePrivate::ScreenGeometryEvent(screen, geometry);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleScreenAvailableGeometryChange(QScreen *screen, const QRect &availableGeometry)
 {
     QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e =
             new QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent(screen, availableGeometry);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal dpiX, qreal dpiY)
 {
     QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e =
             new QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent(screen, dpiX, dpiY);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate)
 {
     QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e =
             new QWindowSystemInterfacePrivate::ScreenRefreshRateEvent(screen, newRefreshRate);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleThemeChange(QWindow *tlw)
 {
     QWindowSystemInterfacePrivate::ThemeChangeEvent *e = new QWindowSystemInterfacePrivate::ThemeChangeEvent(tlw);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion &region)
 {
     QWindowSystemInterfacePrivate::ExposeEvent *e = new QWindowSystemInterfacePrivate::ExposeEvent(tlw, region);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-void QWindowSystemInterface::handleSynchronousExposeEvent(QWindow *tlw, const QRegion &region)
-{
-    QWindowSystemInterface::handleExposeEvent(tlw, region);
-    QWindowSystemInterface::flushWindowSystemEvents();
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::flushWindowSystemEvents()
@@ -497,6 +481,11 @@ bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFla
     return sendWindowSystemEventsImplementation(flags);
 }
 
+void QWindowSystemInterface::setSynchronousWindowsSystemEvents(bool enable)
+{
+    QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents = enable;
+}
+
 bool QWindowSystemInterface::sendWindowSystemEventsImplementation(QEventLoop::ProcessEventsFlags flags)
 {
     int nevents = 0;
@@ -565,7 +554,7 @@ void QWindowSystemInterface::handleTabletEvent(QWindow *w, ulong timestamp, bool
     QWindowSystemInterfacePrivate::TabletEvent *e =
             new QWindowSystemInterfacePrivate::TabletEvent(w, timestamp, down, local, global, device, pointerType, pressure,
                                                            xTilt, yTilt, tangentialPressure, rotation, z, uid, modifiers);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleTabletEvent(QWindow *w, bool down, const QPointF &local, const QPointF &global,
@@ -582,7 +571,7 @@ void QWindowSystemInterface::handleTabletEnterProximityEvent(ulong timestamp, in
 {
     QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e =
             new QWindowSystemInterfacePrivate::TabletEnterProximityEvent(timestamp, device, pointerType, uid);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleTabletEnterProximityEvent(int device, int pointerType, qint64 uid)
@@ -595,7 +584,7 @@ void QWindowSystemInterface::handleTabletLeaveProximityEvent(ulong timestamp, in
 {
     QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e =
             new QWindowSystemInterfacePrivate::TabletLeaveProximityEvent(timestamp, device, pointerType, uid);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleTabletLeaveProximityEvent(int device, int pointerType, qint64 uid)
@@ -608,7 +597,7 @@ void QWindowSystemInterface::handlePlatformPanelEvent(QWindow *w)
 {
     QWindowSystemInterfacePrivate::PlatformPanelEvent *e =
             new QWindowSystemInterfacePrivate::PlatformPanelEvent(w);
-    QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier) {
index fb85600..cf5d22e 100644 (file)
@@ -80,15 +80,15 @@ public:
     static void handleFrameStrutMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier);
     static void handleFrameStrutMouseEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier);
 
-    static bool tryHandleSynchronousShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
+    static bool tryHandleShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
                                                   const QString & text = QString(), bool autorep = false, ushort count = 1);
-    static bool tryHandleSynchronousShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
+    static bool tryHandleShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
                                                   const QString & text = QString(), bool autorep = false, ushort count = 1);
 
-    static bool tryHandleSynchronousExtendedShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
+    static bool tryHandleExtendedShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
                                                           quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
                                                           const QString & text = QString(), bool autorep = false, ushort count = 1);
-    static bool tryHandleSynchronousExtendedShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
+    static bool tryHandleExtendedShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
                                                           quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
                                                           const QString & text = QString(), bool autorep = false, ushort count = 1);
 
@@ -133,16 +133,13 @@ public:
     static void handleTouchCancelEvent(QWindow *w, ulong timestamp, QTouchDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier);
 
     static void handleGeometryChange(QWindow *w, const QRect &newRect);
-    static void handleSynchronousGeometryChange(QWindow *w, const QRect &newRect);
     static void handleCloseEvent(QWindow *w);
-    static void handleSynchronousCloseEvent(QWindow *w);
     static void handleEnterEvent(QWindow *w);
     static void handleLeaveEvent(QWindow *w);
     static void handleWindowActivated(QWindow *w);
     static void handleWindowStateChanged(QWindow *w, Qt::WindowState newState);
 
     static void handleExposeEvent(QWindow *tlw, const QRegion &region);
-    static void handleSynchronousExposeEvent(QWindow *tlw, const QRegion &region);
 
 #ifndef QT_NO_DRAGANDDROP
     // Drag and drop. These events are sent immediately.
@@ -180,6 +177,7 @@ public:
 
     // For event dispatcher implementations
     static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
+    static void setSynchronousWindowsSystemEvents(bool enable);
     static void flushWindowSystemEvents();
     static int windowSystemEventsQueued();
 
index 87dbeb2..e9d2fad 100644 (file)
@@ -357,9 +357,10 @@ public:
 
     static int windowSystemEventsQueued();
     static WindowSystemEvent * getWindowSystemEvent();
-    static void queueWindowSystemEvent(WindowSystemEvent *ev);
+    static void handleWindowSystemEvent(WindowSystemEvent *ev);
 
     static QElapsedTimer eventTime;
+    static bool synchronousWindowsSystemEvents;
 
     static QList<QTouchEvent::TouchPoint> convertTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points, QEvent::Type *type);
 };
index 6e105ee..26161b1 100644 (file)
@@ -270,7 +270,8 @@ void QCocoaWindow::setVisible(bool visible)
         }
 
         // Make sure the QWindow has a frame ready before we show the NSWindow.
-        QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRect(QPoint(), geometry().size()));
+        QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()));
+        QWindowSystemInterface::flushWindowSystemEvents();
 
         if (m_nsWindow) {
             // setWindowState might have been called while the window was hidden and
@@ -536,7 +537,8 @@ void QCocoaWindow::windowWillMove()
 {
     // Close any open popups on window move
     if (m_activePopupWindow) {
-        QWindowSystemInterface::handleSynchronousCloseEvent(m_activePopupWindow);
+        QWindowSystemInterface::handleCloseEvent(m_activePopupWindow);
+        QWindowSystemInterface::flushWindowSystemEvents();
         m_activePopupWindow = 0;
     }
 }
@@ -558,7 +560,8 @@ void QCocoaWindow::windowDidResize()
 
 void QCocoaWindow::windowWillClose()
 {
-    QWindowSystemInterface::handleSynchronousCloseEvent(window());
+    QWindowSystemInterface::handleCloseEvent(window());
+    QWindowSystemInterface::flushWindowSystemEvents();
 }
 
 bool QCocoaWindow::windowIsPopupType(Qt::WindowType type) const
index fe1b26a..f23fd30 100644 (file)
@@ -143,8 +143,10 @@ static QTouchDevice *touchDevice = 0;
     m_platformWindow->QPlatformWindow::setGeometry(geo);
 
     // Send a geometry change event to Qt, if it's ready to handle events
-    if (!m_platformWindow->m_inConstructor)
-        QWindowSystemInterface::handleSynchronousGeometryChange(m_window, geo);
+    if (!m_platformWindow->m_inConstructor) {
+        QWindowSystemInterface::handleGeometryChange(m_window, geo);
+        QWindowSystemInterface::flushWindowSystemEvents();
+    }
 }
 
 - (void)windowNotification : (NSNotification *) windowNotification
@@ -355,7 +357,8 @@ static QTouchDevice *touchDevice = 0;
 - (void)mouseDown:(NSEvent *)theEvent
 {
     if (m_platformWindow->m_activePopupWindow) {
-        QWindowSystemInterface::handleSynchronousCloseEvent(m_platformWindow->m_activePopupWindow);
+        QWindowSystemInterface::handleCloseEvent(m_platformWindow->m_activePopupWindow);
+        QWindowSystemInterface::flushWindowSystemEvents();
         m_platformWindow->m_activePopupWindow = 0;
     }
     if ([self hasMarkedText]) {
@@ -691,7 +694,7 @@ static QTouchDevice *touchDevice = 0;
             text = QCFString::toQString([nsevent characters]);
 
         if (m_composingText.isEmpty())
-            m_sendKeyEvent = !QWindowSystemInterface::tryHandleSynchronousShortcutEvent(m_window, timestamp, keyCode, modifiers, text);
+            m_sendKeyEvent = !QWindowSystemInterface::tryHandleShortcutEvent(m_window, timestamp, keyCode, modifiers, text);
 
         QObject *fo = QGuiApplication::focusObject();
         if (m_sendKeyEvent && fo) {
index c07a018..85bc867 100644 (file)
@@ -224,7 +224,8 @@ bool QEglFSCursor::setCurrentCursor(QCursor *cursor)
 
 void QEglFSCursor::update(const QRegion &rgn)
 {
-    QWindowSystemInterface::handleSynchronousExposeEvent(m_screen->topLevelAt(m_cursor.pos), rgn);
+    QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(m_cursor.pos), rgn);
+    QWindowSystemInterface::flushWindowSystemEvents();
 }
 
 QRect QEglFSCursor::cursorRect() const
index c7d1787..9dd8ad7 100644 (file)
@@ -180,7 +180,8 @@ void QQnxWindow::setGeometry(const QRect &rect)
     }
 
     // Send a geometry change event to Qt (triggers resizeEvent() in QWindow/QWidget)
-    QWindowSystemInterface::handleSynchronousGeometryChange(window(), rect);
+    QWindowSystemInterface::handleGeometryChange(window(), rect);
+    QWindowSystemInterface::flushWindowSystemEvents();
 
     // Now move all children.
     if (!oldGeometry.isEmpty()) {
index eb9b364..2335870 100644 (file)
@@ -1071,10 +1071,9 @@ void QWindowsWindow::handleGeometryChange()
         return;
     m_data.geometry = geometry_sys();
     QPlatformWindow::setGeometry(m_data.geometry);
+    QWindowSystemInterface::handleGeometryChange(window(), m_data.geometry);
     if (testFlag(SynchronousGeometryChangeEvent))
-        QWindowSystemInterface::handleSynchronousGeometryChange(window(), m_data.geometry);
-    else
-        QWindowSystemInterface::handleGeometryChange(window(), m_data.geometry);
+        QWindowSystemInterface::flushWindowSystemEvents();
 
     if (QWindowsContext::verboseEvents || QWindowsContext::verboseWindows)
         qDebug() << __FUNCTION__ << this << window() << m_data.geometry;
@@ -1153,8 +1152,9 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message,
         if (testFlag(OpenGLDoubleBuffered))
             InvalidateRect(hwnd, 0, false);
         BeginPaint(hwnd, &ps);
-        QWindowSystemInterface::handleSynchronousExposeEvent(window(),
-                                                             QRegion(qrectFromRECT(ps.rcPaint)));
+        QWindowSystemInterface::handleExposeEvent(window(), QRegion(qrectFromRECT(ps.rcPaint)));
+        QWindowSystemInterface::flushWindowSystemEvents();
+
         EndPaint(hwnd, &ps);
     } else {
         BeginPaint(hwnd, &ps);
@@ -1163,7 +1163,8 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message,
         if (QWindowsContext::verboseIntegration)
             qDebug() << __FUNCTION__ << this << window() << updateRect;
 
-        QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRegion(updateRect));
+        QWindowSystemInterface::handleExposeEvent(window(), QRegion(updateRect));
+        QWindowSystemInterface::flushWindowSystemEvents();
         EndPaint(hwnd, &ps);
     }
     return true;
@@ -1324,7 +1325,8 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
             SetWindowPos(m_data.hwnd, HWND_TOP, r.left(), r.top(), r.width(), r.height(), swpf);
             if (!wasSync)
                 clearFlag(SynchronousGeometryChangeEvent);
-            QWindowSystemInterface::handleSynchronousGeometryChange(window(), r);
+            QWindowSystemInterface::handleGeometryChange(window(), r);
+            QWindowSystemInterface::flushWindowSystemEvents();
         } else if (newState != Qt::WindowMinimized) {
             // Restore saved state.
             unsigned newStyle = m_savedStyle ? m_savedStyle : style();
index 82d1b17..ccb54b5 100644 (file)
@@ -278,11 +278,11 @@ void tst_QGuiApplication::keyboardModifiers()
     QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier);
 
     // shortcut events
-    QWindowSystemInterface::tryHandleSynchronousShortcutEvent(window, Qt::Key_5, Qt::MetaModifier);
+    QWindowSystemInterface::tryHandleShortcutEvent(window, Qt::Key_5, Qt::MetaModifier);
     QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::MetaModifier);
-    QWindowSystemInterface::tryHandleSynchronousShortcutEvent(window, Qt::Key_Period, Qt::NoModifier);
+    QWindowSystemInterface::tryHandleShortcutEvent(window, Qt::Key_Period, Qt::NoModifier);
     QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier);
-    QWindowSystemInterface::tryHandleSynchronousShortcutEvent(window, Qt::Key_0, Qt::ControlModifier);
+    QWindowSystemInterface::tryHandleShortcutEvent(window, Qt::Key_0, Qt::ControlModifier);
     QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier);
 
     // key events