Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qcocoaeventdispatcher.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4/****************************************************************************
5**
6** Copyright (c) 2007-2008, Apple, Inc.
7**
8** All rights reserved.
9**
10** Redistribution and use in source and binary forms, with or without
11** modification, are permitted provided that the following conditions are met:
12**
13** * Redistributions of source code must retain the above copyright notice,
14** this list of conditions and the following disclaimer.
15**
16** * Redistributions in binary form must reproduce the above copyright notice,
17** this list of conditions and the following disclaimer in the documentation
18** and/or other materials provided with the distribution.
19**
20** * Neither the name of Apple, Inc. nor the names of its contributors
21** may be used to endorse or promote products derived from this software
22** without specific prior written permission.
23**
24** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35**
36****************************************************************************/
37
38#ifndef QEVENTDISPATCHER_MAC_P_H
39#define QEVENTDISPATCHER_MAC_P_H
40
41//
42// W A R N I N G
43// -------------
44//
45// This file is not part of the Qt API. It exists purely as an
46// implementation detail. This header file may change from version to
47// version without notice, or even be removed.
48//
49// We mean it.
50//
51
52#include <QtCore/qabstracteventdispatcher.h>
53#include <QtCore/qstack.h>
54#include <QtGui/qwindowdefs.h>
55#include <QtCore/private/qabstracteventdispatcher_p.h>
56#include <QtCore/private/qcfsocketnotifier_p.h>
57#include <QtCore/private/qtimerinfo_unix_p.h>
58#include <QtCore/qloggingcategory.h>
59
60#include <CoreFoundation/CoreFoundation.h>
61
63
64Q_DECLARE_LOGGING_CATEGORY(lcEventDispatcher);
65
66typedef struct _NSModalSession *NSModalSession;
70 void *nswindow;
72
75{
77 Q_DECLARE_PRIVATE(QCocoaEventDispatcher)
78
79public:
81 explicit QCocoaEventDispatcher(QObject *parent = nullptr);
83
84 bool processEvents(QEventLoop::ProcessEventsFlags flags);
85
88
89 void registerTimer(int timerId, qint64 interval, Qt::TimerType timerType, QObject *object);
90 bool unregisterTimer(int timerId);
91 bool unregisterTimers(QObject *object);
93
94 int remainingTime(int timerId);
95
96 void wakeUp();
97 void interrupt();
98
100
102};
103
105{
106 Q_DECLARE_PUBLIC(QCocoaEventDispatcher)
107
108public:
110
112
113 // timer handling
115 CFRunLoopTimerRef runLoopTimerRef;
116 CFRunLoopSourceRef activateTimersSourceRef;
119 static void runLoopTimerCallback(CFRunLoopTimerRef, void *info);
120 static void activateTimersSourceCallback(void *info);
121 bool processTimers();
122
123 // Set 'blockSendPostedEvents' to true if you _really_ need
124 // to make sure that qt events are not posted while calling
125 // low-level cocoa functions (like beginModalForWindow). And
126 // use a QBoolBlocker to be safe:
128 // The following variables help organizing modal sessions:
140 bool hasModalSession() const;
142
146
149 CFRunLoopSourceRef postedEventsSource;
150 CFRunLoopObserverRef waitingObserver;
154 bool propagateInterrupt = false;
155
156 static void postedEventsSourceCallback(void *info);
157 static void waitingObserverCallback(CFRunLoopObserverRef observer,
158 CFRunLoopActivity activity, void *info);
160 void processPostedEvents();
161};
162
164{
165 static QtCocoaInterruptDispatcher *instance;
166 bool cancelled;
167
170
171 public:
172 static void interruptLater();
173 static void cancelInterruptLater();
174};
175
177
178#endif // QEVENTDISPATCHER_MAC_P_H
DarwinBluetooth::LECBManagerNotifier * notifier
\inmodule QtCore
Definition qatomic.h:112
void beginModalSession(QWindow *widget)
static void postedEventsSourceCallback(void *info)
static void runLoopTimerCallback(CFRunLoopTimerRef, void *info)
static void activateTimersSourceCallback(void *info)
static void waitingObserverCallback(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info)
QStack< QCocoaModalSessionInfo > cocoaModalSessionStack
void registerTimer(int timerId, qint64 interval, Qt::TimerType timerType, QObject *object)
Register a timer with the specified timerId, interval, and timerType for the given object.
void interrupt()
Interrupts event dispatching.
void unregisterSocketNotifier(QSocketNotifier *notifier)
Unregisters notifier from the event dispatcher.
bool unregisterTimer(int timerId)
Unregisters the timer with the given timerId.
int remainingTime(int timerId)
Returns the remaining time in milliseconds with the given timerId.
void registerSocketNotifier(QSocketNotifier *notifier)
Registers notifier with the event loop.
QList< TimerInfo > registeredTimers(QObject *object) const
Returns a list of registered timers for object.
QCocoaEventDispatcher(QAbstractEventDispatcherPrivate &priv, QObject *parent=nullptr)
bool unregisterTimers(QObject *object)
Unregisters all the timers associated with the given object.
friend void qt_mac_maybeCancelWaitForMoreEventsForwarder(QAbstractEventDispatcher *eventDispatcher)
static void clearCurrentThreadCocoaEventDispatcherInterruptFlag()
bool processEvents(QEventLoop::ProcessEventsFlags flags)
Processes pending events that match flags until there are no more events to process.
Definition qlist.h:74
\inmodule QtCore
Definition qobject.h:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
\inmodule QtCore
Definition qpointer.h:18
\inmodule QtCore
\inmodule QtCore
Definition qstack.h:13
\inmodule QtGui
Definition qwindow.h:63
QOpenGLWidget * widget
[1]
Combined button and popup list for selecting options.
TimerType
struct _QCocoaModalSessionInfo QCocoaModalSessionInfo
struct _NSModalSession * NSModalSession
#define Q_DECLARE_LOGGING_CATEGORY(name)
static const QMetaObjectPrivate * priv(const uint *data)
GLbitfield flags
#define Q_OBJECT
unsigned int uint
Definition qtypes.h:29
long long qint64
Definition qtypes.h:55
QFileInfo info(fileName)
[8]