Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count |
---|---|---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - |
4 | ** Contact: http://www.qt.io/licensing/ | - |
5 | ** | - |
6 | ** This file is part of the plugins of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and The Qt Company. For licensing terms | - |
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - |
15 | ** information use the contact form at http://www.qt.io/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 or version 3 as published by the Free | - |
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - |
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - |
22 | ** following information to ensure the GNU Lesser General Public License | - |
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - |
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
25 | ** | - |
26 | ** As a special exception, The Qt Company gives you certain additional | - |
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - |
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
29 | ** | - |
30 | ** $QT_END_LICENSE$ | - |
31 | ** | - |
32 | ****************************************************************************/ | - |
33 | - | |
34 | #include "qeventdispatcher_glib_p.h" | - |
35 | - | |
36 | #include "qguiapplication.h" | - |
37 | - | |
38 | #include "qplatformdefs.h" | - |
39 | - | |
40 | #include <glib.h> | - |
41 | #include "private/qguiapplication_p.h" | - |
42 | - | |
43 | #include <qdebug.h> | - |
44 | - | |
45 | QT_BEGIN_NAMESPACE | - |
46 | - | |
47 | struct GUserEventSource | - |
48 | { | - |
49 | GSource source; | - |
50 | QPAEventDispatcherGlib *q; | - |
51 | }; | - |
52 | - | |
53 | static gboolean userEventSourcePrepare(GSource *s, gint *timeout) | - |
54 | { | - |
55 | Q_UNUSED(s) | - |
56 | Q_UNUSED(timeout) | - |
57 | - | |
58 | return QWindowSystemInterface::windowSystemEventsQueued() > 0; executed 507471 times by 126 tests: return QWindowSystemInterface::windowSystemEventsQueued() > 0; Executed by:
| 507471 |
59 | } | - |
60 | - | |
61 | static gboolean userEventSourceCheck(GSource *source) | - |
62 | { | - |
63 | return userEventSourcePrepare(source, 0); executed 249873 times by 126 tests: return userEventSourcePrepare(source, 0); Executed by:
| 249873 |
64 | } | - |
65 | - | |
66 | static gboolean userEventSourceDispatch(GSource *source, GSourceFunc, gpointer) | - |
67 | { | - |
68 | GUserEventSource *userEventSource = reinterpret_cast<GUserEventSource *>(source); | - |
69 | QPAEventDispatcherGlib *dispatcher = userEventSource->q; | - |
70 | QWindowSystemInterface::sendWindowSystemEvents(dispatcher->m_flags); | - |
71 | return true; executed 7725 times by 109 tests: return true; Executed by:
| 7725 |
72 | } | - |
73 | - | |
74 | static GSourceFuncs userEventSourceFuncs = { | - |
75 | userEventSourcePrepare, | - |
76 | userEventSourceCheck, | - |
77 | userEventSourceDispatch, | - |
78 | NULL, | - |
79 | NULL, | - |
80 | NULL | - |
81 | }; | - |
82 | - | |
83 | QPAEventDispatcherGlibPrivate::QPAEventDispatcherGlibPrivate(GMainContext *context) | - |
84 | : QEventDispatcherGlibPrivate(context) | - |
85 | { | - |
86 | Q_Q(QPAEventDispatcherGlib); | - |
87 | userEventSource = reinterpret_cast<GUserEventSource *>(g_source_new(&userEventSourceFuncs, | - |
88 | sizeof(GUserEventSource))); | - |
89 | userEventSource->q = q; | - |
90 | g_source_set_can_recurse(&userEventSource->source, true); | - |
91 | g_source_attach(&userEventSource->source, mainContext); | - |
92 | } executed 129 times by 5 tests: end of block Executed by:
| 129 |
93 | - | |
94 | - | |
95 | QPAEventDispatcherGlib::QPAEventDispatcherGlib(QObject *parent) | - |
96 | : QEventDispatcherGlib(*new QPAEventDispatcherGlibPrivate, parent) | - |
97 | , m_flags(QEventLoop::AllEvents) | - |
98 | { | - |
99 | Q_D(QPAEventDispatcherGlib); | - |
100 | d->userEventSource->q = this; | - |
101 | } executed 129 times by 5 tests: end of block Executed by:
| 129 |
102 | - | |
103 | QPAEventDispatcherGlib::~QPAEventDispatcherGlib() | - |
104 | { | - |
105 | Q_D(QPAEventDispatcherGlib); | - |
106 | - | |
107 | g_source_destroy(&d->userEventSource->source); | - |
108 | g_source_unref(&d->userEventSource->source); | - |
109 | d->userEventSource = 0; | - |
110 | } executed 341 times by 220 tests: end of block Executed by:
| 341 |
111 | - | |
112 | bool QPAEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags) | - |
113 | { | - |
114 | m_flags = flags; | - |
115 | return QEventDispatcherGlib::processEvents(m_flags); executed 257375 times by 126 tests: return QEventDispatcherGlib::processEvents(m_flags); Executed by:
| 257375 |
116 | } | - |
117 | - | |
118 | QT_END_NAMESPACE | - |
Source code | Switch to Preprocessed file |