Make the CoreFoundation event dispatcher depend on QtCore only
In anticipation of moving it to QtCore. The call to QWindowSystemInterface::sendWindowSystemEvents() has been moved to QIOSEventDispatcher by making processPostedEvents() virtual. Change-Id: I9e03be4153a9f5f34e9a0ac942cdff572a44c318 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
This commit is contained in:
parent
967e4f258c
commit
b63c3d4d9a
@ -41,8 +41,6 @@
|
||||
#include <QtCore/private/qcore_mac_p.h>
|
||||
#include <QtCore/private/qthread_p.h>
|
||||
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include <UIKit/UIApplication.h>
|
||||
@ -169,6 +167,7 @@ static const CFTimeInterval kCFTimeIntervalDistantFuture = std::numeric_limits<C
|
||||
|
||||
QEventDispatcherCoreFoundation::QEventDispatcherCoreFoundation(QObject *parent)
|
||||
: QAbstractEventDispatcher(parent)
|
||||
, m_processEvents(QEventLoop::EventLoopExec)
|
||||
, m_postedEventsRunLoopSource(this, &QEventDispatcherCoreFoundation::processPostedEvents)
|
||||
, m_runLoopActivityObserver(this, &QEventDispatcherCoreFoundation::handleRunLoopActivity,
|
||||
#if DEBUG_EVENT_DISPATCHER
|
||||
@ -181,7 +180,6 @@ QEventDispatcherCoreFoundation::QEventDispatcherCoreFoundation(QObject *parent)
|
||||
, m_runLoopTimer(0)
|
||||
, m_blockedRunLoopTimer(0)
|
||||
, m_overdueTimerScheduled(false)
|
||||
, m_processEvents(QEventLoop::EventLoopExec)
|
||||
{
|
||||
m_cfSocketNotifier.setHostEventDispatcher(this);
|
||||
|
||||
@ -371,11 +369,11 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
|
||||
return eventsProcessed;
|
||||
}
|
||||
|
||||
void QEventDispatcherCoreFoundation::processPostedEvents()
|
||||
bool QEventDispatcherCoreFoundation::processPostedEvents()
|
||||
{
|
||||
if (m_processEvents.processedPostedEvents && !(m_processEvents.flags & QEventLoop::EventLoopExec)) {
|
||||
qEventDispatcherDebug() << "Already processed events this pass";
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_processEvents.processedPostedEvents = true;
|
||||
@ -384,9 +382,7 @@ void QEventDispatcherCoreFoundation::processPostedEvents()
|
||||
QCoreApplication::sendPostedEvents();
|
||||
qUnIndent();
|
||||
|
||||
qEventDispatcherDebug() << "Sending window system events for " << m_processEvents.flags; qIndent();
|
||||
QWindowSystemInterface::sendWindowSystemEvents(m_processEvents.flags);
|
||||
qUnIndent();
|
||||
return true;
|
||||
}
|
||||
|
||||
void QEventDispatcherCoreFoundation::processTimers(CFRunLoopTimerRef timer)
|
||||
|
@ -101,7 +101,7 @@ template <class T = QEventDispatcherCoreFoundation>
|
||||
class RunLoopSource
|
||||
{
|
||||
public:
|
||||
typedef void (T::*CallbackFunction) ();
|
||||
typedef bool (T::*CallbackFunction)();
|
||||
|
||||
enum { kHighestPriority = 0 } RunLoopSourcePriority;
|
||||
|
||||
@ -221,18 +221,8 @@ public:
|
||||
void interrupt();
|
||||
void flush();
|
||||
|
||||
private:
|
||||
RunLoopSource<> m_postedEventsRunLoopSource;
|
||||
RunLoopObserver<> m_runLoopActivityObserver;
|
||||
|
||||
RunLoopModeTracker *m_runLoopModeTracker;
|
||||
|
||||
QTimerInfoList m_timerInfoList;
|
||||
CFRunLoopTimerRef m_runLoopTimer;
|
||||
CFRunLoopTimerRef m_blockedRunLoopTimer;
|
||||
bool m_overdueTimerScheduled;
|
||||
|
||||
QCFSocketNotifier m_cfSocketNotifier;
|
||||
protected:
|
||||
virtual bool processPostedEvents();
|
||||
|
||||
struct ProcessEventsState
|
||||
{
|
||||
@ -251,7 +241,19 @@ private:
|
||||
|
||||
ProcessEventsState m_processEvents;
|
||||
|
||||
void processPostedEvents();
|
||||
private:
|
||||
RunLoopSource<> m_postedEventsRunLoopSource;
|
||||
RunLoopObserver<> m_runLoopActivityObserver;
|
||||
|
||||
RunLoopModeTracker *m_runLoopModeTracker;
|
||||
|
||||
QTimerInfoList m_timerInfoList;
|
||||
CFRunLoopTimerRef m_runLoopTimer;
|
||||
CFRunLoopTimerRef m_blockedRunLoopTimer;
|
||||
bool m_overdueTimerScheduled;
|
||||
|
||||
QCFSocketNotifier m_cfSocketNotifier;
|
||||
|
||||
void processTimers(CFRunLoopTimerRef);
|
||||
|
||||
void handleRunLoopActivity(CFRunLoopActivity activity);
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
explicit QIOSEventDispatcher(QObject *parent = 0);
|
||||
|
||||
bool processEvents(QEventLoop::ProcessEventsFlags flags) Q_DECL_OVERRIDE;
|
||||
bool processPostedEvents() Q_DECL_OVERRIDE;
|
||||
|
||||
void handleRunLoopExit(CFRunLoopActivity activity);
|
||||
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include <QtCore/private/qcoreapplication_p.h>
|
||||
#include <QtCore/private/qthread_p.h>
|
||||
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
@ -461,6 +463,25 @@ bool __attribute__((returns_twice)) QIOSEventDispatcher::processEvents(QEventLoo
|
||||
return processedEvents;
|
||||
}
|
||||
|
||||
/*!
|
||||
Override of the CoreFoundation posted events runloop source callback
|
||||
so that we can send window system (QPA) events in addition to sending
|
||||
normal Qt events.
|
||||
*/
|
||||
bool QIOSEventDispatcher::processPostedEvents()
|
||||
{
|
||||
// Don't send window system events if the base CF dispatcher has determined
|
||||
// that events should not be sent for this pass of the runloop source.
|
||||
if (!QEventDispatcherCoreFoundation::processPostedEvents())
|
||||
return false;
|
||||
|
||||
qEventDispatcherDebug() << "Sending window system events for " << m_processEvents.flags; qIndent();
|
||||
QWindowSystemInterface::sendWindowSystemEvents(m_processEvents.flags);
|
||||
qUnIndent();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QIOSEventDispatcher::handleRunLoopExit(CFRunLoopActivity activity)
|
||||
{
|
||||
Q_UNUSED(activity);
|
||||
|
Loading…
x
Reference in New Issue
Block a user