From bcb5e564ff302517156d881e57577f77bdc30f6e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 23 Jul 2012 16:56:11 +0200 Subject: [PATCH] WindowSystemInterface::sendWindowSystemEvents(): Remove unused parameter. 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 --- src/gui/kernel/qguiapplication.cpp | 2 +- src/gui/kernel/qwindowsysteminterface.cpp | 2 +- src/gui/kernel/qwindowsysteminterface.h | 2 +- .../qeventdispatcher_glib.cpp | 5 +-- .../eventdispatchers/qunixeventdispatcher.cpp | 2 +- .../platforms/cocoa/qcocoaeventdispatcher.mm | 2 +- .../qnx/qqnxeventdispatcher_blackberry.cpp | 2 +- .../windows/qwindowsguieventdispatcher.cpp | 39 +++---------------- .../windows/qwindowsguieventdispatcher.h | 9 ++--- .../qguiapplication/tst_qguiapplication.cpp | 6 +-- 10 files changed, 20 insertions(+), 51 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index c028e42e2c..be773b410d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -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(); diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 207c858a76..a18f6d8f17 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -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; diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 0382ac6dbf..fb1717b628 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -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(); }; diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp index 14bf5f4f3f..e2afd67a07 100644 --- a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp +++ b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp @@ -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(s); - QWindowSystemInterface::sendWindowSystemEvents(source->q, QEventLoop::AllEvents); + QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents); return true; } diff --git a/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp b/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp index 8939a63268..4b22dff749 100644 --- a/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp +++ b/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp @@ -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; diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index a00f3eb076..3e527c3b7c 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -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); } } diff --git a/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp b/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp index 630171a4ea..39f23c0d6e 100644 --- a/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp +++ b/src/plugins/platforms/qnx/qqnxeventdispatcher_blackberry.cpp @@ -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; diff --git a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp b/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp index dc8c432f27..2ebb3cefbd 100644 --- a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp +++ b/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp @@ -64,35 +64,18 @@ QT_BEGIN_NAMESPACE \ingroup qt-lighthouse-win */ -typedef QStack DispatchContextStack; - -Q_GLOBAL_STATIC(DispatchContextStack, dispatchContextStack) - QWindowsGuiEventDispatcher::QWindowsGuiEventDispatcher(QObject *parent) : - QEventDispatcherWin32(parent) + QEventDispatcherWin32(parent), m_flags(0) { - 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() -{ - 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. diff --git a/src/plugins/platforms/windows/qwindowsguieventdispatcher.h b/src/plugins/platforms/windows/qwindowsguieventdispatcher.h index 49c5d8b490..563e613a0e 100644 --- a/src/plugins/platforms/windows/qwindowsguieventdispatcher.h +++ b/src/plugins/platforms/windows/qwindowsguieventdispatcher.h @@ -46,6 +46,7 @@ #include "qtwindows_additional.h" #include +#include #include QT_BEGIN_NAMESPACE @@ -55,16 +56,14 @@ class QWindowsGuiEventDispatcher : public QEventDispatcherWin32 Q_OBJECT public: explicit QWindowsGuiEventDispatcher(QObject *parent = 0); - ~QWindowsGuiEventDispatcher(); - - typedef QPair 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 diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index dda810ab41..b9bf79ee65 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -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