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#ifndef QEVENTDISPATCHER_GLIB_P_H
5#define QEVENTDISPATCHER_GLIB_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of the QLibrary class. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qabstracteventdispatcher.h"
19#include "qabstracteventdispatcher_p.h"
20
21typedef struct _GMainContext GMainContext;
22
23QT_BEGIN_NAMESPACE
24
25class QEventDispatcherGlibPrivate;
26
27class Q_CORE_EXPORT QEventDispatcherGlib : public QAbstractEventDispatcher
28{
29 Q_OBJECT
30 Q_DECLARE_PRIVATE(QEventDispatcherGlib)
31
32public:
33 explicit QEventDispatcherGlib(QObject *parent = nullptr);
34 explicit QEventDispatcherGlib(GMainContext *context, QObject *parent = nullptr);
35 ~QEventDispatcherGlib();
36
37 bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
38
39 void registerSocketNotifier(QSocketNotifier *socketNotifier) final;
40 void unregisterSocketNotifier(QSocketNotifier *socketNotifier) final;
41
42 void registerTimer(int timerId, qint64 interval, Qt::TimerType timerType, QObject *object) final;
43 bool unregisterTimer(int timerId) final;
44 bool unregisterTimers(QObject *object) final;
45 QList<TimerInfo> registeredTimers(QObject *object) const final;
46
47 int remainingTime(int timerId) final;
48
49 void wakeUp() final;
50 void interrupt() final;
51
52 static bool versionSupported();
53
54protected:
55 QEventDispatcherGlib(QEventDispatcherGlibPrivate &dd, QObject *parent);
56};
57
58struct GPostEventSource;
59struct GSocketNotifierSource;
60struct GTimerSource;
61struct GIdleTimerSource;
62
63class Q_CORE_EXPORT QEventDispatcherGlibPrivate : public QAbstractEventDispatcherPrivate
64{
65
66public:
67 QEventDispatcherGlibPrivate(GMainContext *context = nullptr);
68 GMainContext *mainContext;
69 GPostEventSource *postEventSource;
70 GSocketNotifierSource *socketNotifierSource;
71 GTimerSource *timerSource;
72 GIdleTimerSource *idleTimerSource;
73 bool wakeUpCalled = true;
74
75 void runTimersOnceWithNormalPriority();
76};
77
78QT_END_NAMESPACE
79
80#endif // QEVENTDISPATCHER_GLIB_P_H
81

source code of qtbase/src/corelib/kernel/qeventdispatcher_glib_p.h