blob: b52389f3907cf1c131d68417466b635290eaa085 (
plain)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 | // Copyright (C) 2016 The Qt Company Ltd.// Copyright (c) 2007-2008, Apple, Inc.// SPDX-License-Identifier: BSD-3-Clause#ifndef QEVENTDISPATCHER_MAC_P_H#define QEVENTDISPATCHER_MAC_P_H//// W A R N I N G// -------------//// This file is not part of the Qt API. It exists purely as an// implementation detail. This header file may change from version to// version without notice, or even be removed.//// We mean it.//#include <QtCore/qabstracteventdispatcher.h>#include <QtCore/qstack.h>#include <QtGui/qwindowdefs.h>#include <QtCore/private/qabstracteventdispatcher_p.h>#include <QtCore/private/qcfsocketnotifier_p.h>#include <QtCore/private/qtimerinfo_unix_p.h>#include <QtCore/qloggingcategory.h>#include <QtCore/qpointer.h>#include <CoreFoundation/CoreFoundation.h>Q_FORWARD_DECLARE_OBJC_CLASS(NSWindow); QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcEventDispatcher);typedefstruct _NSModalSession *NSModalSession;typedefstruct _QCocoaModalSessionInfo { QPointer<QWindow> window; NSModalSession session; NSWindow *nswindow;} QCocoaModalSessionInfo;class QCocoaEventDispatcherPrivate;class QCocoaEventDispatcher :public QAbstractEventDispatcherV2 { Q_OBJECT Q_DECLARE_PRIVATE(QCocoaEventDispatcher)public:QCocoaEventDispatcher(QAbstractEventDispatcherPrivate &priv, QObject *parent =nullptr);explicitQCocoaEventDispatcher(QObject *parent =nullptr);~QCocoaEventDispatcher() override;boolprocessEvents(QEventLoop::ProcessEventsFlags flags) override;voidregisterSocketNotifier(QSocketNotifier *notifier) override;voidunregisterSocketNotifier(QSocketNotifier *notifier) override;voidregisterTimer(Qt::TimerId timerId, Duration interval,Qt::TimerType timerType, QObject *object) final;boolunregisterTimer(Qt::TimerId timerId) final;boolunregisterTimers(QObject *object) final; QList<TimerInfoV2>timersForObject(QObject *object)const final; Duration remainingTime(Qt::TimerId timerId)const final;voidwakeUp() override;voidinterrupt() override;static voidclearCurrentThreadCocoaEventDispatcherInterruptFlag();friendvoidqt_mac_maybeCancelWaitForMoreEventsForwarder(QAbstractEventDispatcher *eventDispatcher);};class QCocoaEventDispatcherPrivate :public QAbstractEventDispatcherPrivate {Q_DECLARE_PUBLIC(QCocoaEventDispatcher)public:QCocoaEventDispatcherPrivate();~QCocoaEventDispatcherPrivate() override; uint processEventsFlags;// timer handling QTimerInfoList timerInfoList; CFRunLoopTimerRef runLoopTimerRef; CFRunLoopSourceRef activateTimersSourceRef;voidmaybeStartCFRunLoopTimer();voidmaybeStopCFRunLoopTimer();static voidrunLoopTimerCallback(CFRunLoopTimerRef,void*info);static voidactivateTimersSourceCallback(void*info);boolprocessTimers();// Set 'blockSendPostedEvents' to true if you _really_ need// to make sure that qt events are not posted while calling// low-level cocoa functions (like beginModalForWindow). And// use a QScopedValueRollback to be safe:bool blockSendPostedEvents;// The following variables help organizing modal sessions: QStack<QCocoaModalSessionInfo> cocoaModalSessionStack;bool currentExecIsNSAppRun;bool nsAppRunCalledByQt;bool initializingNSApplication =false;bool cleanupModalSessionsNeeded; uint processEventsCalled; NSModalSession currentModalSessionCached; NSModalSession currentModalSession();voidtemporarilyStopAllModalSessions();voidbeginModalSession(QWindow *widget);voidendModalSession(QWindow *widget);boolhasModalSession()const;voidcleanupModalSessions();voidcancelWaitForMoreEvents();voidmaybeCancelWaitForMoreEvents();voidensureNSAppInitialized(); QCFSocketNotifier cfSocketNotifier; QList<void*> queuedUserInputEvents;// NSEvent * CFRunLoopSourceRef postedEventsSource; CFRunLoopObserverRef waitingObserver; QAtomicInt serialNumber;int lastSerial;bool interrupt;bool propagateInterrupt =false;static voidpostedEventsSourceCallback(void*info);static voidwaitingObserverCallback(CFRunLoopObserverRef observer, CFRunLoopActivity activity,void*info);boolsendQueuedUserInputEvents();voidprocessPostedEvents();};class QtCocoaInterruptDispatcher :public QObject {static QtCocoaInterruptDispatcher *instance;bool cancelled;QtCocoaInterruptDispatcher();~QtCocoaInterruptDispatcher();public:static voidinterruptLater();static voidcancelInterruptLater();}; QT_END_NAMESPACE #endif// QEVENTDISPATCHER_MAC_P_H
|