WindowSystemInterface::sendWindowSystemEvents(): Remove unused parameter.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Mon, 23 Jul 2012 14:56:11 +0000 (16:56 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 23 Jul 2012 17:57:07 +0000 (19:57 +0200)
No need to pass the dispatcher. Get rid of Windows logic to maintain
a stack of dispatcher associated with flags.

Change-Id: Ic2daad4b6762a46fac3274937effc188af436c9a
Reviewed-by: David Faure <faure@kde.org>
src/gui/kernel/qguiapplication.cpp
src/gui/kernel/qwindowsysteminterface.cpp
src/gui/kernel/qwindowsysteminterface.h
src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp
src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp
src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp
src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp
src/plugins/platforms/windows/qwindowsguieventdispatcher.h
tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp

index c028e42..be773b4 100644 (file)
@@ -877,7 +877,7 @@ void QGuiApplicationPrivate::init()
 
     is_app_running = true;
     init_plugins(pluginList);
-    QWindowSystemInterface::sendWindowSystemEvents(QCoreApplicationPrivate::eventDispatcher, QEventLoop::AllEvents);
+    QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
 }
 
 extern void qt_cleanupFontDatabase();
index 207c858..a18f6d8 100644 (file)
@@ -499,7 +499,7 @@ void QWindowSystemInterface::handleSynchronousExposeEvent(QWindow *tlw, const QR
     QGuiApplicationPrivate::processWindowSystemEvent(&e); // send event immediately.
 }
 
-bool QWindowSystemInterface::sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags)
+bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
 {
     int nevents = 0;
 
index 0382ac6..fb1717b 100644 (file)
@@ -178,7 +178,7 @@ public:
 
 
     // For event dispatcher implementations
-    static bool sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags);
+    static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
     static int windowSystemEventsQueued();
 };
 
index 14bf5f4..e2afd67 100644 (file)
@@ -71,10 +71,9 @@ static gboolean userEventSourceCheck(GSource *source)
     return userEventSourcePrepare(source, 0);
 }
 
-static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
+static gboolean userEventSourceDispatch(GSource *, GSourceFunc, gpointer)
 {
-    GUserEventSource * source = reinterpret_cast<GUserEventSource *>(s);
-    QWindowSystemInterface::sendWindowSystemEvents(source->q, QEventLoop::AllEvents);
+    QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
     return true;
 }
 
index 8939a63..4b22dff 100644 (file)
@@ -67,7 +67,7 @@ QUnixEventDispatcherQPA::~QUnixEventDispatcherQPA()
 
 bool QUnixEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags)
 {
-    bool didSendEvents = QWindowSystemInterface::sendWindowSystemEvents(this, flags);
+    const bool didSendEvents = QWindowSystemInterface::sendWindowSystemEvents(flags);
 
     if (QEventDispatcherUNIX::processEvents(flags)) {
         return true;
index a00f3eb..3e527c3 100644 (file)
@@ -1032,7 +1032,7 @@ void QCocoaEventDispatcherPrivate::processPostedEvents()
     int serial = serialNumber.load();
     if (!threadData->canWait || (serial != lastSerial)) {
         lastSerial = serial;
-        QWindowSystemInterface::sendWindowSystemEvents(q_func(), QEventLoop::AllEvents);
+        QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
     }
 }
 
index 630171a..39f23c0 100644 (file)
@@ -58,7 +58,7 @@ QQnxEventDispatcherBlackberry::~QQnxEventDispatcherBlackberry()
 
 bool QQnxEventDispatcherBlackberry::processEvents(QEventLoop::ProcessEventsFlags flags)
 {
-    bool didSendEvents = QWindowSystemInterface::sendWindowSystemEvents(this, flags);
+    const bool didSendEvents = QWindowSystemInterface::sendWindowSystemEvents(flags);
 
     if (QEventDispatcherBlackberry::processEvents(flags))
         return true;
index dc8c432..2ebb3ce 100644 (file)
@@ -64,35 +64,18 @@ QT_BEGIN_NAMESPACE
     \ingroup qt-lighthouse-win
 */
 
-typedef QStack<QWindowsGuiEventDispatcher::DispatchContext> DispatchContextStack;
-
-Q_GLOBAL_STATIC(DispatchContextStack, dispatchContextStack)
-
 QWindowsGuiEventDispatcher::QWindowsGuiEventDispatcher(QObject *parent) :
-    QEventDispatcherWin32(parent)
-{
-    setObjectName(QStringLiteral("QWindowsGuiEventDispatcher_0x") + QString::number((quintptr)this, 16));
-    if (QWindowsContext::verboseEvents)
-        qDebug("%s %s", __FUNCTION__, qPrintable(objectName()));
-    dispatchContextStack()->push(DispatchContext(this, QEventLoop::AllEvents));
-}
-
-QWindowsGuiEventDispatcher::~QWindowsGuiEventDispatcher()
+    QEventDispatcherWin32(parent), m_flags(0)
 {
-    if (QWindowsContext::verboseEvents)
-        qDebug("%s %s", __FUNCTION__, qPrintable(objectName()));
-    if (!dispatchContextStack()->isEmpty())
-        dispatchContextStack()->pop();
+    setObjectName(QStringLiteral("QWindowsGuiEventDispatcher"));
 }
 
 bool QWindowsGuiEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
 {
-    DispatchContextStack &stack = *dispatchContextStack();
+    m_flags = flags;
     if (QWindowsContext::verboseEvents > 2)
-        qDebug(">%s %s %d", __FUNCTION__, qPrintable(objectName()), stack.size());
-    stack.push(DispatchContext(this, flags));
+        qDebug(">%s %s %d", __FUNCTION__, qPrintable(objectName()), int(flags));
     const bool rc = QEventDispatcherWin32::processEvents(flags);
-    stack.pop();
     if (QWindowsContext::verboseEvents > 2)
         qDebug("<%s %s returns %d", __FUNCTION__, qPrintable(objectName()), rc);
     return rc;
@@ -100,19 +83,7 @@ bool QWindowsGuiEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags fl
 
 void QWindowsGuiEventDispatcher::sendPostedEvents()
 {
-    QWindowsGuiEventDispatcher::DispatchContext context = currentDispatchContext();
-    Q_ASSERT(context.first != 0);
-    QWindowSystemInterface::sendWindowSystemEvents(context.first, context.second);
-}
-
-QWindowsGuiEventDispatcher::DispatchContext QWindowsGuiEventDispatcher::currentDispatchContext()
-{
-    const DispatchContextStack &stack = *dispatchContextStack();
-    if (stack.isEmpty()) {
-        qWarning("%s: No dispatch context", __FUNCTION__);
-        return DispatchContext(0, 0);
-    }
-    return stack.top();
+    QWindowSystemInterface::sendWindowSystemEvents(m_flags);
 }
 
 // Helpers for printing debug output for WM_* messages.
index 49c5d8b..563e613 100644 (file)
@@ -46,6 +46,7 @@
 #include "qtwindows_additional.h"
 
 #include <QtCore/QPair>
+#include <QtCore/QEventLoop>
 #include <QtCore/private/qeventdispatcher_win_p.h>
 
 QT_BEGIN_NAMESPACE
@@ -55,16 +56,14 @@ class QWindowsGuiEventDispatcher : public QEventDispatcherWin32
     Q_OBJECT
 public:
     explicit QWindowsGuiEventDispatcher(QObject *parent = 0);
-    ~QWindowsGuiEventDispatcher();
-
-    typedef QPair<QAbstractEventDispatcher *, QEventLoop::ProcessEventsFlags> DispatchContext;
-
-    static DispatchContext currentDispatchContext();
 
     static const char *windowsMessageName(UINT msg);
 
     virtual bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags);
     virtual void sendPostedEvents();
+
+private:
+    QEventLoop::ProcessEventsFlags m_flags;
 };
 
 QT_END_NAMESPACE
index dda810a..b9bf79e 100644 (file)
@@ -306,13 +306,13 @@ void tst_QGuiApplication::keyboardModifiers()
     QPoint global = window->mapToGlobal(center);
     QPoint delta(0, 1);
     QWindowSystemInterface::handleWheelEvent(window, center, global, delta, delta, Qt::NoModifier);
-    QWindowSystemInterface::sendWindowSystemEvents(app.eventDispatcher(), QEventLoop::AllEvents);
+    QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
     QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier);
     QWindowSystemInterface::handleWheelEvent(window, center, global, delta, delta, Qt::AltModifier);
-    QWindowSystemInterface::sendWindowSystemEvents(app.eventDispatcher(), QEventLoop::AllEvents);
+    QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
     QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::AltModifier);
     QWindowSystemInterface::handleWheelEvent(window, center, global, delta, delta, Qt::ControlModifier);
-    QWindowSystemInterface::sendWindowSystemEvents(app.eventDispatcher(), QEventLoop::AllEvents);
+    QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
     QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier);
 
     // touch events