Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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#include <QtCore/qpointer.h>
60
61#include <CoreFoundation/CoreFoundation.h>
62
64
66
67Q_DECLARE_LOGGING_CATEGORY(lcEventDispatcher);
68
69typedef struct _NSModalSession *NSModalSession;
75
78{
80 Q_DECLARE_PRIVATE(QCocoaEventDispatcher)
81
82public:
84 explicit QCocoaEventDispatcher(QObject *parent = nullptr);
86
87 bool processEvents(QEventLoop::ProcessEventsFlags flags);
88
91
92 void registerTimer(Qt::TimerId timerId, Duration interval, Qt::TimerType timerType,
93 QObject *object) final;
94 bool unregisterTimer(Qt::TimerId timerId) final;
95 bool unregisterTimers(QObject *object) final;
96 QList<TimerInfoV2> timersForObject(QObject *object) const final;
97 Duration remainingTime(Qt::TimerId timerId) const final;
98
99 void wakeUp();
100 void interrupt();
101
103
105};
106
108{
109 Q_DECLARE_PUBLIC(QCocoaEventDispatcher)
110
111public:
113
115
116 // timer handling
118 CFRunLoopTimerRef runLoopTimerRef;
119 CFRunLoopSourceRef activateTimersSourceRef;
122 static void runLoopTimerCallback(CFRunLoopTimerRef, void *info);
123 static void activateTimersSourceCallback(void *info);
124 bool processTimers();
125
126 // Set 'blockSendPostedEvents' to true if you _really_ need
127 // to make sure that qt events are not posted while calling
128 // low-level cocoa functions (like beginModalForWindow). And
129 // use a QBoolBlocker to be safe:
131 // The following variables help organizing modal sessions:
132 QStack<QCocoaModalSessionInfo> cocoaModalSessionStack;
143 bool hasModalSession() const;
145
149
151 QList<void *> queuedUserInputEvents; // NSEvent *
152 CFRunLoopSourceRef postedEventsSource;
153 CFRunLoopObserverRef waitingObserver;
157 bool propagateInterrupt = false;
158
159 static void postedEventsSourceCallback(void *info);
160 static void waitingObserverCallback(CFRunLoopObserverRef observer,
161 CFRunLoopActivity activity, void *info);
163 void processPostedEvents();
164};
165
167{
168 static QtCocoaInterruptDispatcher *instance;
169 bool cancelled;
170
173
174 public:
175 static void interruptLater();
176 static void cancelInterruptLater();
177};
178
180
181#endif // QEVENTDISPATCHER_MAC_P_H
DarwinBluetooth::LECBManagerNotifier * notifier
std::chrono::nanoseconds Duration
A {std::chrono::duration} type that is used in various API in this class.
\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
QList< TimerInfoV2 > timersForObject(QObject *object) const final
void interrupt()
Interrupts event dispatching.
void unregisterSocketNotifier(QSocketNotifier *notifier)
Unregisters notifier from the event dispatcher.
void registerSocketNotifier(QSocketNotifier *notifier)
Registers notifier with the event loop.
QCocoaEventDispatcher(QAbstractEventDispatcherPrivate &priv, QObject *parent=nullptr)
bool unregisterTimers(QObject *object) final
Unregisters all the timers associated with the given object.
void registerTimer(Qt::TimerId timerId, Duration interval, Qt::TimerType timerType, QObject *object) final
Duration remainingTime(Qt::TimerId timerId) const final
Returns the remaining time of the timer with the given timerId.
bool unregisterTimer(Qt::TimerId timerId) final
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.
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore
\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_FORWARD_DECLARE_OBJC_CLASS(classname)
#define Q_DECLARE_LOGGING_CATEGORY(name)
static const QMetaObjectPrivate * priv(const uint *data)
GLbitfield flags
#define Q_OBJECT
unsigned int uint
Definition qtypes.h:34
QHostInfo info
[0]