Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qeventdispatcher_glib.cpp
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// Qt-Security score:significant reason:default
4
6
8
9#include "qplatformdefs.h"
10
11#include <glib.h>
12#include "private/qguiapplication_p.h"
13
15
22
23static gboolean userEventSourcePrepare(GSource *source, gint *timeout)
24{
25 Q_UNUSED(timeout);
26 GUserEventSource *userEventSource = reinterpret_cast<GUserEventSource *>(source);
27 return userEventSource->d->wakeUpCalled;
28}
29
30static gboolean userEventSourceCheck(GSource *source)
31{
32 return userEventSourcePrepare(source, nullptr);
33}
34
36{
37 GUserEventSource *userEventSource = reinterpret_cast<GUserEventSource *>(source);
38 QPAEventDispatcherGlib *dispatcher = userEventSource->q;
39 QWindowSystemInterface::sendWindowSystemEvents(dispatcher->m_flags);
40 return true;
41}
42
44 userEventSourcePrepare,
45 userEventSourceCheck,
46 userEventSourceDispatch,
47 NULL,
48 NULL,
49 NULL
50};
51
52QPAEventDispatcherGlibPrivate::QPAEventDispatcherGlibPrivate(GMainContext *context)
53 : QEventDispatcherGlibPrivate(context)
54{
55 Q_Q(QPAEventDispatcherGlib);
56
57 GSource *source = g_source_new(&userEventSourceFuncs, sizeof(GUserEventSource));
58 userEventSource = reinterpret_cast<GUserEventSource *>(source);
59 userEventSource->q = q;
60 userEventSource->d = this;
61 attachSource(source, "[Qt] GUserEventSource");
62}
63
65 = default;
66
67QPAEventDispatcherGlib::QPAEventDispatcherGlib(QObject *parent)
68 : QEventDispatcherGlib(*new QPAEventDispatcherGlibPrivate, parent)
69 , m_flags(QEventLoop::AllEvents)
70{
71 Q_D(QPAEventDispatcherGlib);
72 d->userEventSource->q = this;
73}
74
75QPAEventDispatcherGlib::~QPAEventDispatcherGlib()
76{
77 Q_D(QPAEventDispatcherGlib);
78
79 d->destroySource(&d->userEventSource->source);
80 d->userEventSource = nullptr;
81}
82
83bool QPAEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
84{
85 m_flags = flags;
86 return QEventDispatcherGlib::processEvents(m_flags);
87}
88
89QT_END_NAMESPACE
90
91#include "moc_qeventdispatcher_glib_p.cpp"
~QPAEventDispatcherGlibPrivate() override
static GSourceFuncs userEventSourceFuncs
static gboolean userEventSourcePrepare(GSource *source, gint *timeout)
static gboolean userEventSourceDispatch(GSource *source, GSourceFunc, gpointer)
static gboolean userEventSourceCheck(GSource *source)
Combined button and popup list for selecting options.
QPAEventDispatcherGlib * q
QPAEventDispatcherGlibPrivate * d