Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qguiapplication.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 QtGui module 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 "qguiapplication.h" | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | #include "private/qguiapplication_p.h" | - | ||||||||||||||||||
37 | #include <qpa/qplatformintegrationfactory_p.h> | - | ||||||||||||||||||
38 | #include "private/qevent_p.h" | - | ||||||||||||||||||
39 | #include "qfont.h" | - | ||||||||||||||||||
40 | #include <qpa/qplatformfontdatabase.h> | - | ||||||||||||||||||
41 | #include <qpa/qplatformwindow.h> | - | ||||||||||||||||||
42 | #include <qpa/qplatformnativeinterface.h> | - | ||||||||||||||||||
43 | #include <qpa/qplatformtheme.h> | - | ||||||||||||||||||
44 | #include <qpa/qplatformintegration.h> | - | ||||||||||||||||||
45 | #include <qpa/qplatformdrag.h> | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | #include <QtCore/QAbstractEventDispatcher> | - | ||||||||||||||||||
48 | #include <QtCore/QVariant> | - | ||||||||||||||||||
49 | #include <QtCore/private/qcoreapplication_p.h> | - | ||||||||||||||||||
50 | #include <QtCore/private/qabstracteventdispatcher_p.h> | - | ||||||||||||||||||
51 | #include <QtCore/qmutex.h> | - | ||||||||||||||||||
52 | #include <QtCore/private/qthread_p.h> | - | ||||||||||||||||||
53 | #include <QtCore/qdir.h> | - | ||||||||||||||||||
54 | #include <QtCore/qlibraryinfo.h> | - | ||||||||||||||||||
55 | #include <QtCore/qnumeric.h> | - | ||||||||||||||||||
56 | #include <QtDebug> | - | ||||||||||||||||||
57 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
58 | #include "qaccessible.h" | - | ||||||||||||||||||
59 | #endif | - | ||||||||||||||||||
60 | #include <qpalette.h> | - | ||||||||||||||||||
61 | #include <qscreen.h> | - | ||||||||||||||||||
62 | #include "qsessionmanager.h" | - | ||||||||||||||||||
63 | #include <private/qscreen_p.h> | - | ||||||||||||||||||
64 | #include <private/qdrawhelper_p.h> | - | ||||||||||||||||||
65 | - | |||||||||||||||||||
66 | #include <QtGui/qgenericpluginfactory.h> | - | ||||||||||||||||||
67 | #include <QtGui/qstylehints.h> | - | ||||||||||||||||||
68 | #include <QtGui/qinputmethod.h> | - | ||||||||||||||||||
69 | #include <QtGui/qpixmapcache.h> | - | ||||||||||||||||||
70 | #include <qpa/qplatforminputcontext.h> | - | ||||||||||||||||||
71 | #include <qpa/qplatforminputcontext_p.h> | - | ||||||||||||||||||
72 | - | |||||||||||||||||||
73 | #include <qpa/qwindowsysteminterface.h> | - | ||||||||||||||||||
74 | #include <qpa/qwindowsysteminterface_p.h> | - | ||||||||||||||||||
75 | #include "private/qwindow_p.h" | - | ||||||||||||||||||
76 | #include "private/qcursor_p.h" | - | ||||||||||||||||||
77 | #include "private/qopenglcontext_p.h" | - | ||||||||||||||||||
78 | #include "private/qinputdevicemanager_p.h" | - | ||||||||||||||||||
79 | - | |||||||||||||||||||
80 | #include "private/qdnd_p.h" | - | ||||||||||||||||||
81 | #include <qpa/qplatformthemefactory_p.h> | - | ||||||||||||||||||
82 | - | |||||||||||||||||||
83 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
84 | #include <qpa/qplatformcursor.h> | - | ||||||||||||||||||
85 | #endif | - | ||||||||||||||||||
86 | - | |||||||||||||||||||
87 | #include <QtGui/QPixmap> | - | ||||||||||||||||||
88 | - | |||||||||||||||||||
89 | #ifndef QT_NO_CLIPBOARD | - | ||||||||||||||||||
90 | #include <QtGui/QClipboard> | - | ||||||||||||||||||
91 | #endif | - | ||||||||||||||||||
92 | - | |||||||||||||||||||
93 | #ifndef QT_NO_LIBRARY | - | ||||||||||||||||||
94 | #include <QtCore/QLibrary> | - | ||||||||||||||||||
95 | #endif | - | ||||||||||||||||||
96 | - | |||||||||||||||||||
97 | #if defined(Q_OS_MAC) | - | ||||||||||||||||||
98 | # include "private/qcore_mac_p.h" | - | ||||||||||||||||||
99 | #elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - | ||||||||||||||||||
100 | # include <QtCore/qt_windows.h> | - | ||||||||||||||||||
101 | # include <QtCore/QLibraryInfo> | - | ||||||||||||||||||
102 | # if defined(Q_OS_WINPHONE) | - | ||||||||||||||||||
103 | # include <Objbase.h> | - | ||||||||||||||||||
104 | # endif | - | ||||||||||||||||||
105 | #endif // Q_OS_WIN && !Q_OS_WINCE | - | ||||||||||||||||||
106 | - | |||||||||||||||||||
107 | #include <ctype.h> | - | ||||||||||||||||||
108 | - | |||||||||||||||||||
109 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
110 | - | |||||||||||||||||||
111 | // Helper macro for static functions to check on the existence of the application class. | - | ||||||||||||||||||
112 | #define CHECK_QAPP_INSTANCE(...) \ | - | ||||||||||||||||||
113 | if (Q_LIKELY(QCoreApplication::instance())) { \ | - | ||||||||||||||||||
114 | } else { \ | - | ||||||||||||||||||
115 | qWarning("Must construct a QGuiApplication first."); \ | - | ||||||||||||||||||
116 | return __VA_ARGS__; \ | - | ||||||||||||||||||
117 | } | - | ||||||||||||||||||
118 | - | |||||||||||||||||||
119 | Q_GUI_EXPORT bool qt_is_gui_used = true; | - | ||||||||||||||||||
120 | - | |||||||||||||||||||
121 | Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton; | - | ||||||||||||||||||
122 | Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; | - | ||||||||||||||||||
123 | - | |||||||||||||||||||
124 | QPointF QGuiApplicationPrivate::lastCursorPosition(qInf(), qInf()); | - | ||||||||||||||||||
125 | - | |||||||||||||||||||
126 | Qt::MouseButtons QGuiApplicationPrivate::tabletState = Qt::NoButton; | - | ||||||||||||||||||
127 | QWindow *QGuiApplicationPrivate::tabletPressTarget = 0; | - | ||||||||||||||||||
128 | QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; | - | ||||||||||||||||||
129 | - | |||||||||||||||||||
130 | QString QGuiApplicationPrivate::styleOverride; | - | ||||||||||||||||||
131 | - | |||||||||||||||||||
132 | Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive; | - | ||||||||||||||||||
133 | - | |||||||||||||||||||
134 | bool QGuiApplicationPrivate::highDpiScalingUpdated = false; | - | ||||||||||||||||||
135 | - | |||||||||||||||||||
136 | QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; | - | ||||||||||||||||||
137 | QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; | - | ||||||||||||||||||
138 | - | |||||||||||||||||||
139 | QList<QObject *> QGuiApplicationPrivate::generic_plugin_list; | - | ||||||||||||||||||
140 | - | |||||||||||||||||||
141 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
142 | bool QGuiApplicationPrivate::is_fallback_session_management_enabled = true; | - | ||||||||||||||||||
143 | #endif | - | ||||||||||||||||||
144 | - | |||||||||||||||||||
145 | enum ApplicationResourceFlags | - | ||||||||||||||||||
146 | { | - | ||||||||||||||||||
147 | ApplicationPaletteExplicitlySet = 0x1, | - | ||||||||||||||||||
148 | ApplicationFontExplicitlySet = 0x2 | - | ||||||||||||||||||
149 | }; | - | ||||||||||||||||||
150 | - | |||||||||||||||||||
151 | static unsigned applicationResourceFlags = 0; | - | ||||||||||||||||||
152 | - | |||||||||||||||||||
153 | QIcon *QGuiApplicationPrivate::app_icon = 0; | - | ||||||||||||||||||
154 | - | |||||||||||||||||||
155 | QString *QGuiApplicationPrivate::platform_name = 0; | - | ||||||||||||||||||
156 | QString *QGuiApplicationPrivate::displayName = 0; | - | ||||||||||||||||||
157 | - | |||||||||||||||||||
158 | QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette | - | ||||||||||||||||||
159 | - | |||||||||||||||||||
160 | Qt::MouseButtons QGuiApplicationPrivate::buttons = Qt::NoButton; | - | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | ulong QGuiApplicationPrivate::mousePressTime = 0; | - | ||||||||||||||||||
163 | Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton; | - | ||||||||||||||||||
164 | int QGuiApplicationPrivate::mousePressX = 0; | - | ||||||||||||||||||
165 | int QGuiApplicationPrivate::mousePressY = 0; | - | ||||||||||||||||||
166 | int QGuiApplicationPrivate::mouse_double_click_distance = -1; | - | ||||||||||||||||||
167 | - | |||||||||||||||||||
168 | QWindow *QGuiApplicationPrivate::currentMousePressWindow = 0; | - | ||||||||||||||||||
169 | - | |||||||||||||||||||
170 | static Qt::LayoutDirection layout_direction = Qt::LayoutDirectionAuto; | - | ||||||||||||||||||
171 | static bool force_reverse = false; | - | ||||||||||||||||||
172 | - | |||||||||||||||||||
173 | QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0; | - | ||||||||||||||||||
174 | QTouchDevice *QGuiApplicationPrivate::m_fakeTouchDevice = 0; | - | ||||||||||||||||||
175 | int QGuiApplicationPrivate::m_fakeMouseSourcePointId = 0; | - | ||||||||||||||||||
176 | - | |||||||||||||||||||
177 | #ifndef QT_NO_CLIPBOARD | - | ||||||||||||||||||
178 | QClipboard *QGuiApplicationPrivate::qt_clipboard = 0; | - | ||||||||||||||||||
179 | #endif | - | ||||||||||||||||||
180 | - | |||||||||||||||||||
181 | QList<QScreen *> QGuiApplicationPrivate::screen_list; | - | ||||||||||||||||||
182 | - | |||||||||||||||||||
183 | QWindowList QGuiApplicationPrivate::window_list; | - | ||||||||||||||||||
184 | QWindow *QGuiApplicationPrivate::focus_window = 0; | - | ||||||||||||||||||
185 | - | |||||||||||||||||||
186 | static QBasicMutex applicationFontMutex; | - | ||||||||||||||||||
187 | QFont *QGuiApplicationPrivate::app_font = 0; | - | ||||||||||||||||||
188 | QStyleHints *QGuiApplicationPrivate::styleHints = Q_NULLPTR; | - | ||||||||||||||||||
189 | bool QGuiApplicationPrivate::obey_desktop_settings = true; | - | ||||||||||||||||||
190 | - | |||||||||||||||||||
191 | QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = 0; | - | ||||||||||||||||||
192 | - | |||||||||||||||||||
193 | // enable the fix for QTBUG-50199; TODO remove this check in 5.7 | - | ||||||||||||||||||
194 | bool QGuiApplicationPrivate::scrollNoPhaseAllowed = false; | - | ||||||||||||||||||
195 | - | |||||||||||||||||||
196 | static qreal fontSmoothingGamma = 1.7; | - | ||||||||||||||||||
197 | - | |||||||||||||||||||
198 | extern void qRegisterGuiVariant(); | - | ||||||||||||||||||
199 | #ifndef QT_NO_ANIMATION | - | ||||||||||||||||||
200 | extern void qRegisterGuiGetInterpolator(); | - | ||||||||||||||||||
201 | #endif | - | ||||||||||||||||||
202 | - | |||||||||||||||||||
203 | static bool qt_detectRTLLanguage() | - | ||||||||||||||||||
204 | { | - | ||||||||||||||||||
205 | return force_reverse ^ never executed: return force_reverse ^ (QGuiApplication::tr("QT_LAYOUT_DIRECTION", "Translate this string to the string 'LTR' in left-to-right" " languages or to 'RTL' in right-to-left languages (such as Hebrew" " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); | 0 | ||||||||||||||||||
206 | (QGuiApplication::tr("QT_LAYOUT_DIRECTION", never executed: return force_reverse ^ (QGuiApplication::tr("QT_LAYOUT_DIRECTION", "Translate this string to the string 'LTR' in left-to-right" " languages or to 'RTL' in right-to-left languages (such as Hebrew" " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); | 0 | ||||||||||||||||||
207 | "Translate this string to the string 'LTR' in left-to-right" never executed: return force_reverse ^ (QGuiApplication::tr("QT_LAYOUT_DIRECTION", "Translate this string to the string 'LTR' in left-to-right" " languages or to 'RTL' in right-to-left languages (such as Hebrew" " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); | 0 | ||||||||||||||||||
208 | " languages or to 'RTL' in right-to-left languages (such as Hebrew" never executed: return force_reverse ^ (QGuiApplication::tr("QT_LAYOUT_DIRECTION", "Translate this string to the string 'LTR' in left-to-right" " languages or to 'RTL' in right-to-left languages (such as Hebrew" " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); | 0 | ||||||||||||||||||
209 | " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); never executed: return force_reverse ^ (QGuiApplication::tr("QT_LAYOUT_DIRECTION", "Translate this string to the string 'LTR' in left-to-right" " languages or to 'RTL' in right-to-left languages (such as Hebrew" " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); | 0 | ||||||||||||||||||
210 | } | - | ||||||||||||||||||
211 | - | |||||||||||||||||||
212 | static void initPalette() | - | ||||||||||||||||||
213 | { | - | ||||||||||||||||||
214 | if (!QGuiApplicationPrivate::app_pal)
| 0 | ||||||||||||||||||
215 | if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette())
| 0 | ||||||||||||||||||
216 | QGuiApplicationPrivate::app_pal = new QPalette(*themePalette); never executed: QGuiApplicationPrivate::app_pal = new QPalette(*themePalette); | 0 | ||||||||||||||||||
217 | if (!QGuiApplicationPrivate::app_pal)
| 0 | ||||||||||||||||||
218 | QGuiApplicationPrivate::app_pal = new QPalette(Qt::gray); never executed: QGuiApplicationPrivate::app_pal = new QPalette(Qt::gray); | 0 | ||||||||||||||||||
219 | } never executed: end of block | 0 | ||||||||||||||||||
220 | - | |||||||||||||||||||
221 | static inline void clearPalette() | - | ||||||||||||||||||
222 | { | - | ||||||||||||||||||
223 | delete QGuiApplicationPrivate::app_pal; | - | ||||||||||||||||||
224 | QGuiApplicationPrivate::app_pal = 0; | - | ||||||||||||||||||
225 | } never executed: end of block | 0 | ||||||||||||||||||
226 | - | |||||||||||||||||||
227 | static void initFontUnlocked() | - | ||||||||||||||||||
228 | { | - | ||||||||||||||||||
229 | if (!QGuiApplicationPrivate::app_font) {
| 0 | ||||||||||||||||||
230 | if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
| 0 | ||||||||||||||||||
231 | if (const QFont *font = theme->font(QPlatformTheme::SystemFont))
| 0 | ||||||||||||||||||
232 | QGuiApplicationPrivate::app_font = new QFont(*font); never executed: QGuiApplicationPrivate::app_font = new QFont(*font); | 0 | ||||||||||||||||||
233 | } never executed: end of block | 0 | ||||||||||||||||||
234 | if (!QGuiApplicationPrivate::app_font)
| 0 | ||||||||||||||||||
235 | QGuiApplicationPrivate::app_font = never executed: QGuiApplicationPrivate::app_font = new QFont(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFont()); | 0 | ||||||||||||||||||
236 | new QFont(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFont()); never executed: QGuiApplicationPrivate::app_font = new QFont(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFont()); | 0 | ||||||||||||||||||
237 | } never executed: end of block | 0 | ||||||||||||||||||
238 | - | |||||||||||||||||||
239 | static inline void clearFontUnlocked() | - | ||||||||||||||||||
240 | { | - | ||||||||||||||||||
241 | delete QGuiApplicationPrivate::app_font; | - | ||||||||||||||||||
242 | QGuiApplicationPrivate::app_font = 0; | - | ||||||||||||||||||
243 | } never executed: end of block | 0 | ||||||||||||||||||
244 | - | |||||||||||||||||||
245 | // Using aggregate initialization instead of ctor so we can have a POD global static | - | ||||||||||||||||||
246 | #define Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER { Qt::TopLeftCorner, -1, -1, -1, -1 } | - | ||||||||||||||||||
247 | - | |||||||||||||||||||
248 | // Geometry specification for top level windows following the convention of the | - | ||||||||||||||||||
249 | // -geometry command line arguments in X11 (see XParseGeometry). | - | ||||||||||||||||||
250 | struct QWindowGeometrySpecification | - | ||||||||||||||||||
251 | { | - | ||||||||||||||||||
252 | static QWindowGeometrySpecification fromArgument(const QByteArray &a); | - | ||||||||||||||||||
253 | void applyTo(QWindow *window) const; | - | ||||||||||||||||||
254 | - | |||||||||||||||||||
255 | Qt::Corner corner; | - | ||||||||||||||||||
256 | int xOffset; | - | ||||||||||||||||||
257 | int yOffset; | - | ||||||||||||||||||
258 | int width; | - | ||||||||||||||||||
259 | int height; | - | ||||||||||||||||||
260 | }; | - | ||||||||||||||||||
261 | - | |||||||||||||||||||
262 | // Parse a token of a X11 geometry specification "200x100+10-20". | - | ||||||||||||||||||
263 | static inline int nextGeometryToken(const QByteArray &a, int &pos, char *op) | - | ||||||||||||||||||
264 | { | - | ||||||||||||||||||
265 | *op = 0; | - | ||||||||||||||||||
266 | const int size = a.size(); | - | ||||||||||||||||||
267 | if (pos >= size)
| 0 | ||||||||||||||||||
268 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
269 | - | |||||||||||||||||||
270 | *op = a.at(pos); | - | ||||||||||||||||||
271 | if (*op == '+' || *op == '-' || *op == 'x')
| 0 | ||||||||||||||||||
272 | pos++; never executed: pos++; | 0 | ||||||||||||||||||
273 | else if (isdigit(*op))
| 0 | ||||||||||||||||||
274 | *op = 'x'; // If it starts with a digit, it is supposed to be a width specification. never executed: *op = 'x'; | 0 | ||||||||||||||||||
275 | else | - | ||||||||||||||||||
276 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
277 | - | |||||||||||||||||||
278 | const int numberPos = pos; | - | ||||||||||||||||||
279 | for ( ; pos < size && isdigit(a.at(pos)); ++pos) ; never executed: ;
| 0 | ||||||||||||||||||
280 | - | |||||||||||||||||||
281 | bool ok; | - | ||||||||||||||||||
282 | const int result = a.mid(numberPos, pos - numberPos).toInt(&ok); | - | ||||||||||||||||||
283 | return ok ? result : -1; never executed: return ok ? result : -1;
| 0 | ||||||||||||||||||
284 | } | - | ||||||||||||||||||
285 | - | |||||||||||||||||||
286 | QWindowGeometrySpecification QWindowGeometrySpecification::fromArgument(const QByteArray &a) | - | ||||||||||||||||||
287 | { | - | ||||||||||||||||||
288 | QWindowGeometrySpecification result = Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER; | - | ||||||||||||||||||
289 | int pos = 0; | - | ||||||||||||||||||
290 | for (int i = 0; i < 4; ++i) {
| 0 | ||||||||||||||||||
291 | char op; | - | ||||||||||||||||||
292 | const int value = nextGeometryToken(a, pos, &op); | - | ||||||||||||||||||
293 | if (value < 0)
| 0 | ||||||||||||||||||
294 | break; never executed: break; | 0 | ||||||||||||||||||
295 | switch (op) { | - | ||||||||||||||||||
296 | case 'x': never executed: case 'x': | 0 | ||||||||||||||||||
297 | (result.width >= 0 ? result.height : result.width) = value; | - | ||||||||||||||||||
298 | break; never executed: break; | 0 | ||||||||||||||||||
299 | case '+': never executed: case '+': | 0 | ||||||||||||||||||
300 | case '-': never executed: case '-': | 0 | ||||||||||||||||||
301 | if (result.xOffset >= 0) {
| 0 | ||||||||||||||||||
302 | result.yOffset = value; | - | ||||||||||||||||||
303 | if (op == '-')
| 0 | ||||||||||||||||||
304 | result.corner = result.corner == Qt::TopRightCorner ? Qt::BottomRightCorner : Qt::BottomLeftCorner; never executed: result.corner = result.corner == Qt::TopRightCorner ? Qt::BottomRightCorner : Qt::BottomLeftCorner;
| 0 | ||||||||||||||||||
305 | } else { never executed: end of block | 0 | ||||||||||||||||||
306 | result.xOffset = value; | - | ||||||||||||||||||
307 | if (op == '-')
| 0 | ||||||||||||||||||
308 | result.corner = Qt::TopRightCorner; never executed: result.corner = Qt::TopRightCorner; | 0 | ||||||||||||||||||
309 | } never executed: end of block | 0 | ||||||||||||||||||
310 | } | - | ||||||||||||||||||
311 | } never executed: end of block | 0 | ||||||||||||||||||
312 | return result; never executed: return result; | 0 | ||||||||||||||||||
313 | } | - | ||||||||||||||||||
314 | - | |||||||||||||||||||
315 | void QWindowGeometrySpecification::applyTo(QWindow *window) const | - | ||||||||||||||||||
316 | { | - | ||||||||||||||||||
317 | QRect windowGeometry = window->frameGeometry(); | - | ||||||||||||||||||
318 | QSize size = windowGeometry.size(); | - | ||||||||||||||||||
319 | if (width >= 0 || height >= 0) {
| 0 | ||||||||||||||||||
320 | const QSize windowMinimumSize = window->minimumSize(); | - | ||||||||||||||||||
321 | const QSize windowMaximumSize = window->maximumSize(); | - | ||||||||||||||||||
322 | if (width >= 0)
| 0 | ||||||||||||||||||
323 | size.setWidth(qBound(windowMinimumSize.width(), width, windowMaximumSize.width())); never executed: size.setWidth(qBound(windowMinimumSize.width(), width, windowMaximumSize.width())); | 0 | ||||||||||||||||||
324 | if (height >= 0)
| 0 | ||||||||||||||||||
325 | size.setHeight(qBound(windowMinimumSize.height(), height, windowMaximumSize.height())); never executed: size.setHeight(qBound(windowMinimumSize.height(), height, windowMaximumSize.height())); | 0 | ||||||||||||||||||
326 | window->resize(size); | - | ||||||||||||||||||
327 | } never executed: end of block | 0 | ||||||||||||||||||
328 | if (xOffset >= 0 || yOffset >= 0) {
| 0 | ||||||||||||||||||
329 | const QRect availableGeometry = window->screen()->virtualGeometry(); | - | ||||||||||||||||||
330 | QPoint topLeft = windowGeometry.topLeft(); | - | ||||||||||||||||||
331 | if (xOffset >= 0) {
| 0 | ||||||||||||||||||
332 | topLeft.setX(corner == Qt::TopLeftCorner || corner == Qt::BottomLeftCorner ? | - | ||||||||||||||||||
333 | xOffset : | - | ||||||||||||||||||
334 | qMax(availableGeometry.right() - size.width() - xOffset, availableGeometry.left())); | - | ||||||||||||||||||
335 | } never executed: end of block | 0 | ||||||||||||||||||
336 | if (yOffset >= 0) {
| 0 | ||||||||||||||||||
337 | topLeft.setY(corner == Qt::TopLeftCorner || corner == Qt::TopRightCorner ? | - | ||||||||||||||||||
338 | yOffset : | - | ||||||||||||||||||
339 | qMax(availableGeometry.bottom() - size.height() - yOffset, availableGeometry.top())); | - | ||||||||||||||||||
340 | } never executed: end of block | 0 | ||||||||||||||||||
341 | window->setFramePosition(topLeft); | - | ||||||||||||||||||
342 | } never executed: end of block | 0 | ||||||||||||||||||
343 | } never executed: end of block | 0 | ||||||||||||||||||
344 | - | |||||||||||||||||||
345 | static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER; | - | ||||||||||||||||||
346 | - | |||||||||||||||||||
347 | /*! | - | ||||||||||||||||||
348 | \macro qGuiApp | - | ||||||||||||||||||
349 | \relates QGuiApplication | - | ||||||||||||||||||
350 | - | |||||||||||||||||||
351 | A global pointer referring to the unique application object. | - | ||||||||||||||||||
352 | Only valid for use when that object is a QGuiApplication. | - | ||||||||||||||||||
353 | - | |||||||||||||||||||
354 | \sa QCoreApplication::instance(), qApp | - | ||||||||||||||||||
355 | */ | - | ||||||||||||||||||
356 | - | |||||||||||||||||||
357 | /*! | - | ||||||||||||||||||
358 | \class QGuiApplication | - | ||||||||||||||||||
359 | \brief The QGuiApplication class manages the GUI application's control | - | ||||||||||||||||||
360 | flow and main settings. | - | ||||||||||||||||||
361 | - | |||||||||||||||||||
362 | \inmodule QtGui | - | ||||||||||||||||||
363 | \since 5.0 | - | ||||||||||||||||||
364 | - | |||||||||||||||||||
365 | QGuiApplication contains the main event loop, where all events from the window | - | ||||||||||||||||||
366 | system and other sources are processed and dispatched. It also handles the | - | ||||||||||||||||||
367 | application's initialization and finalization, and provides session management. | - | ||||||||||||||||||
368 | In addition, QGuiApplication handles most of the system-wide and application-wide | - | ||||||||||||||||||
369 | settings. | - | ||||||||||||||||||
370 | - | |||||||||||||||||||
371 | For any GUI application using Qt, there is precisely \b one QGuiApplication | - | ||||||||||||||||||
372 | object no matter whether the application has 0, 1, 2 or more windows at | - | ||||||||||||||||||
373 | any given time. For non-GUI Qt applications, use QCoreApplication instead, | - | ||||||||||||||||||
374 | as it does not depend on the Qt GUI module. For QWidget based Qt applications, | - | ||||||||||||||||||
375 | use QApplication instead, as it provides some functionality needed for creating | - | ||||||||||||||||||
376 | QWidget instances. | - | ||||||||||||||||||
377 | - | |||||||||||||||||||
378 | The QGuiApplication object is accessible through the instance() function, which | - | ||||||||||||||||||
379 | returns a pointer equivalent to the global \l qApp pointer. | - | ||||||||||||||||||
380 | - | |||||||||||||||||||
381 | QGuiApplication's main areas of responsibility are: | - | ||||||||||||||||||
382 | \list | - | ||||||||||||||||||
383 | \li It initializes the application with the user's desktop settings, | - | ||||||||||||||||||
384 | such as palette(), font() and styleHints(). It keeps | - | ||||||||||||||||||
385 | track of these properties in case the user changes the desktop | - | ||||||||||||||||||
386 | globally, for example, through some kind of control panel. | - | ||||||||||||||||||
387 | - | |||||||||||||||||||
388 | \li It performs event handling, meaning that it receives events | - | ||||||||||||||||||
389 | from the underlying window system and dispatches them to the | - | ||||||||||||||||||
390 | relevant widgets. You can send your own events to windows by | - | ||||||||||||||||||
391 | using sendEvent() and postEvent(). | - | ||||||||||||||||||
392 | - | |||||||||||||||||||
393 | \li It parses common command line arguments and sets its internal | - | ||||||||||||||||||
394 | state accordingly. See the \l{QGuiApplication::QGuiApplication()} | - | ||||||||||||||||||
395 | {constructor documentation} below for more details. | - | ||||||||||||||||||
396 | - | |||||||||||||||||||
397 | \li It provides localization of strings that are visible to the | - | ||||||||||||||||||
398 | user via translate(). | - | ||||||||||||||||||
399 | - | |||||||||||||||||||
400 | \li It provides some magical objects like the clipboard(). | - | ||||||||||||||||||
401 | - | |||||||||||||||||||
402 | \li It knows about the application's windows. You can ask which | - | ||||||||||||||||||
403 | window is at a certain position using topLevelAt(), get a list of | - | ||||||||||||||||||
404 | topLevelWindows(), etc. | - | ||||||||||||||||||
405 | - | |||||||||||||||||||
406 | \li It manages the application's mouse cursor handling, see | - | ||||||||||||||||||
407 | setOverrideCursor() | - | ||||||||||||||||||
408 | - | |||||||||||||||||||
409 | \li It provides support for sophisticated \l{Session Management} | - | ||||||||||||||||||
410 | {session management}. This makes it possible for applications | - | ||||||||||||||||||
411 | to terminate gracefully when the user logs out, to cancel a | - | ||||||||||||||||||
412 | shutdown process if termination isn't possible and even to | - | ||||||||||||||||||
413 | preserve the entire application's state for a future session. | - | ||||||||||||||||||
414 | See isSessionRestored(), sessionId() and commitDataRequest() and | - | ||||||||||||||||||
415 | saveStateRequest() for details. | - | ||||||||||||||||||
416 | \endlist | - | ||||||||||||||||||
417 | - | |||||||||||||||||||
418 | Since the QGuiApplication object does so much initialization, it \e{must} be | - | ||||||||||||||||||
419 | created before any other objects related to the user interface are created. | - | ||||||||||||||||||
420 | QGuiApplication also deals with common command line arguments. Hence, it is | - | ||||||||||||||||||
421 | usually a good idea to create it \e before any interpretation or | - | ||||||||||||||||||
422 | modification of \c argv is done in the application itself. | - | ||||||||||||||||||
423 | - | |||||||||||||||||||
424 | \table | - | ||||||||||||||||||
425 | \header | - | ||||||||||||||||||
426 | \li{2,1} Groups of functions | - | ||||||||||||||||||
427 | - | |||||||||||||||||||
428 | \row | - | ||||||||||||||||||
429 | \li System settings | - | ||||||||||||||||||
430 | \li desktopSettingsAware(), | - | ||||||||||||||||||
431 | setDesktopSettingsAware(), | - | ||||||||||||||||||
432 | styleHints(), | - | ||||||||||||||||||
433 | palette(), | - | ||||||||||||||||||
434 | setPalette(), | - | ||||||||||||||||||
435 | font(), | - | ||||||||||||||||||
436 | setFont(). | - | ||||||||||||||||||
437 | - | |||||||||||||||||||
438 | \row | - | ||||||||||||||||||
439 | \li Event handling | - | ||||||||||||||||||
440 | \li exec(), | - | ||||||||||||||||||
441 | processEvents(), | - | ||||||||||||||||||
442 | exit(), | - | ||||||||||||||||||
443 | quit(). | - | ||||||||||||||||||
444 | sendEvent(), | - | ||||||||||||||||||
445 | postEvent(), | - | ||||||||||||||||||
446 | sendPostedEvents(), | - | ||||||||||||||||||
447 | removePostedEvents(), | - | ||||||||||||||||||
448 | hasPendingEvents(), | - | ||||||||||||||||||
449 | notify(). | - | ||||||||||||||||||
450 | - | |||||||||||||||||||
451 | \row | - | ||||||||||||||||||
452 | \li Windows | - | ||||||||||||||||||
453 | \li allWindows(), | - | ||||||||||||||||||
454 | topLevelWindows(), | - | ||||||||||||||||||
455 | focusWindow(), | - | ||||||||||||||||||
456 | clipboard(), | - | ||||||||||||||||||
457 | topLevelAt(). | - | ||||||||||||||||||
458 | - | |||||||||||||||||||
459 | \row | - | ||||||||||||||||||
460 | \li Advanced cursor handling | - | ||||||||||||||||||
461 | \li overrideCursor(), | - | ||||||||||||||||||
462 | setOverrideCursor(), | - | ||||||||||||||||||
463 | restoreOverrideCursor(). | - | ||||||||||||||||||
464 | - | |||||||||||||||||||
465 | \row | - | ||||||||||||||||||
466 | \li Session management | - | ||||||||||||||||||
467 | \li isSessionRestored(), | - | ||||||||||||||||||
468 | sessionId(), | - | ||||||||||||||||||
469 | commitDataRequest(), | - | ||||||||||||||||||
470 | saveStateRequest(). | - | ||||||||||||||||||
471 | - | |||||||||||||||||||
472 | \row | - | ||||||||||||||||||
473 | \li Miscellaneous | - | ||||||||||||||||||
474 | \li startingUp(), | - | ||||||||||||||||||
475 | closingDown(). | - | ||||||||||||||||||
476 | \endtable | - | ||||||||||||||||||
477 | - | |||||||||||||||||||
478 | \sa QCoreApplication, QAbstractEventDispatcher, QEventLoop | - | ||||||||||||||||||
479 | */ | - | ||||||||||||||||||
480 | - | |||||||||||||||||||
481 | /*! | - | ||||||||||||||||||
482 | Initializes the window system and constructs an application object with | - | ||||||||||||||||||
483 | \a argc command line arguments in \a argv. | - | ||||||||||||||||||
484 | - | |||||||||||||||||||
485 | \warning The data referred to by \a argc and \a argv must stay valid for | - | ||||||||||||||||||
486 | the entire lifetime of the QGuiApplication object. In addition, \a argc must | - | ||||||||||||||||||
487 | be greater than zero and \a argv must contain at least one valid character | - | ||||||||||||||||||
488 | string. | - | ||||||||||||||||||
489 | - | |||||||||||||||||||
490 | The global \c qApp pointer refers to this application object. Only one | - | ||||||||||||||||||
491 | application object should be created. | - | ||||||||||||||||||
492 | - | |||||||||||||||||||
493 | This application object must be constructed before any \l{QPaintDevice} | - | ||||||||||||||||||
494 | {paint devices} (including pixmaps, bitmaps etc.). | - | ||||||||||||||||||
495 | - | |||||||||||||||||||
496 | \note \a argc and \a argv might be changed as Qt removes command line | - | ||||||||||||||||||
497 | arguments that it recognizes. | - | ||||||||||||||||||
498 | - | |||||||||||||||||||
499 | \section1 Supported Command Line Options | - | ||||||||||||||||||
500 | - | |||||||||||||||||||
501 | All Qt programs automatically support a set of command-line options that | - | ||||||||||||||||||
502 | allow modifying the way Qt will interact with the windowing system. Some of | - | ||||||||||||||||||
503 | the options are also accessible via environment variables, which are the | - | ||||||||||||||||||
504 | preferred form if the application can launch GUI sub-processes or other | - | ||||||||||||||||||
505 | applications (environment variables will be inherited by child processes). | - | ||||||||||||||||||
506 | When in doubt, use the environment variables. | - | ||||||||||||||||||
507 | - | |||||||||||||||||||
508 | The options currently supported are the following: | - | ||||||||||||||||||
509 | \list | - | ||||||||||||||||||
510 | - | |||||||||||||||||||
511 | \li \c{-platform} \e {platformName[:options]}, specifies the | - | ||||||||||||||||||
512 | \l{Qt Platform Abstraction} (QPA) plugin. | - | ||||||||||||||||||
513 | - | |||||||||||||||||||
514 | Overridden by the \c QT_QPA_PLATFORM environment variable. | - | ||||||||||||||||||
515 | \li \c{-platformpluginpath} \e path, specifies the path to platform | - | ||||||||||||||||||
516 | plugins. | - | ||||||||||||||||||
517 | - | |||||||||||||||||||
518 | Overridden by the \c QT_QPA_PLATFORM_PLUGIN_PATH environment | - | ||||||||||||||||||
519 | variable. | - | ||||||||||||||||||
520 | - | |||||||||||||||||||
521 | \li \c{-platformtheme} \e platformTheme, specifies the platform theme. | - | ||||||||||||||||||
522 | - | |||||||||||||||||||
523 | Overridden by the \c QT_QPA_PLATFORMTHEME environment variable. | - | ||||||||||||||||||
524 | - | |||||||||||||||||||
525 | \li \c{-plugin} \e plugin, specifies additional plugins to load. The argument | - | ||||||||||||||||||
526 | may appear multiple times. | - | ||||||||||||||||||
527 | - | |||||||||||||||||||
528 | Overridden by the \c QT_QPA_GENERIC_PLUGINS environment variable. | - | ||||||||||||||||||
529 | - | |||||||||||||||||||
530 | \li \c{-qmljsdebugger=}, activates the QML/JS debugger with a specified port. | - | ||||||||||||||||||
531 | The value must be of format \c{port:1234}\e{[,block]}, where | - | ||||||||||||||||||
532 | \e block is optional | - | ||||||||||||||||||
533 | and will make the application wait until a debugger connects to it. | - | ||||||||||||||||||
534 | \li \c {-qwindowgeometry} \e geometry, specifies window geometry for | - | ||||||||||||||||||
535 | the main window using the X11-syntax. For example: | - | ||||||||||||||||||
536 | \c {-qwindowgeometry 100x100+50+50} | - | ||||||||||||||||||
537 | \li \c {-qwindowicon}, sets the default window icon | - | ||||||||||||||||||
538 | \li \c {-qwindowtitle}, sets the title of the first window | - | ||||||||||||||||||
539 | \li \c{-reverse}, sets the application's layout direction to | - | ||||||||||||||||||
540 | Qt::RightToLeft. This option is intended to aid debugging and should | - | ||||||||||||||||||
541 | not be used in production. The default value is automatically detected | - | ||||||||||||||||||
542 | from the user's locale (see also QLocale::textDirection()). | - | ||||||||||||||||||
543 | \li \c{-session} \e session, restores the application from an earlier | - | ||||||||||||||||||
544 | \l{Session Management}{session}. | - | ||||||||||||||||||
545 | \endlist | - | ||||||||||||||||||
546 | - | |||||||||||||||||||
547 | The following standard command line options are available for X11: | - | ||||||||||||||||||
548 | - | |||||||||||||||||||
549 | \list | - | ||||||||||||||||||
550 | \li \c {-display} \e {hostname:screen_number}, switches displays on X11. | - | ||||||||||||||||||
551 | - | |||||||||||||||||||
552 | Overrides the \c DISPLAY environment variable. | - | ||||||||||||||||||
553 | \li \c {-geometry} \e geometry, same as \c {-qwindowgeometry}. | - | ||||||||||||||||||
554 | \endlist | - | ||||||||||||||||||
555 | - | |||||||||||||||||||
556 | \section1 Platform-Specific Arguments | - | ||||||||||||||||||
557 | - | |||||||||||||||||||
558 | You can specify platform-specific arguments for the \c{-platform} option. | - | ||||||||||||||||||
559 | Place them after the platform plugin name following a colon as a | - | ||||||||||||||||||
560 | comma-separated list. For example, | - | ||||||||||||||||||
561 | \c{-platform windows:dialogs=xp,fontengine=freetype}. | - | ||||||||||||||||||
562 | - | |||||||||||||||||||
563 | The following parameters are available for \c {-platform windows}: | - | ||||||||||||||||||
564 | - | |||||||||||||||||||
565 | \list | - | ||||||||||||||||||
566 | \li \c {dialogs=[xp|none]}, \c xp uses XP-style native dialogs and | - | ||||||||||||||||||
567 | \c none disables them. | - | ||||||||||||||||||
568 | \li \c {fontengine=freetype}, uses the FreeType font engine. | - | ||||||||||||||||||
569 | \endlist | - | ||||||||||||||||||
570 | - | |||||||||||||||||||
571 | For more information about the platform-specific arguments available for | - | ||||||||||||||||||
572 | embedded Linux platforms, see \l{Qt for Embedded Linux}. | - | ||||||||||||||||||
573 | - | |||||||||||||||||||
574 | \sa arguments() QGuiApplication::platformName | - | ||||||||||||||||||
575 | */ | - | ||||||||||||||||||
576 | #ifdef Q_QDOC | - | ||||||||||||||||||
577 | QGuiApplication::QGuiApplication(int &argc, char **argv) | - | ||||||||||||||||||
578 | #else | - | ||||||||||||||||||
579 | QGuiApplication::QGuiApplication(int &argc, char **argv, int flags) | - | ||||||||||||||||||
580 | #endif | - | ||||||||||||||||||
581 | : QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags)) | - | ||||||||||||||||||
582 | { | - | ||||||||||||||||||
583 | d_func()->init(); | - | ||||||||||||||||||
584 | - | |||||||||||||||||||
585 | QCoreApplicationPrivate::eventDispatcher->startingUp(); | - | ||||||||||||||||||
586 | } never executed: end of block | 0 | ||||||||||||||||||
587 | - | |||||||||||||||||||
588 | /*! | - | ||||||||||||||||||
589 | \internal | - | ||||||||||||||||||
590 | */ | - | ||||||||||||||||||
591 | QGuiApplication::QGuiApplication(QGuiApplicationPrivate &p) | - | ||||||||||||||||||
592 | : QCoreApplication(p) | - | ||||||||||||||||||
593 | { | - | ||||||||||||||||||
594 | } never executed: end of block | 0 | ||||||||||||||||||
595 | - | |||||||||||||||||||
596 | /*! | - | ||||||||||||||||||
597 | Destructs the application. | - | ||||||||||||||||||
598 | */ | - | ||||||||||||||||||
599 | QGuiApplication::~QGuiApplication() | - | ||||||||||||||||||
600 | { | - | ||||||||||||||||||
601 | Q_D(QGuiApplication); | - | ||||||||||||||||||
602 | - | |||||||||||||||||||
603 | d->eventDispatcher->closingDown(); | - | ||||||||||||||||||
604 | d->eventDispatcher = 0; | - | ||||||||||||||||||
605 | - | |||||||||||||||||||
606 | #ifndef QT_NO_CLIPBOARD | - | ||||||||||||||||||
607 | delete QGuiApplicationPrivate::qt_clipboard; | - | ||||||||||||||||||
608 | QGuiApplicationPrivate::qt_clipboard = 0; | - | ||||||||||||||||||
609 | #endif | - | ||||||||||||||||||
610 | - | |||||||||||||||||||
611 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
612 | delete d->session_manager; | - | ||||||||||||||||||
613 | d->session_manager = 0; | - | ||||||||||||||||||
614 | #endif //QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
615 | - | |||||||||||||||||||
616 | clearPalette(); | - | ||||||||||||||||||
617 | QFontDatabase::removeAllApplicationFonts(); | - | ||||||||||||||||||
618 | - | |||||||||||||||||||
619 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
620 | d->cursor_list.clear(); | - | ||||||||||||||||||
621 | #endif | - | ||||||||||||||||||
622 | - | |||||||||||||||||||
623 | delete QGuiApplicationPrivate::app_icon; | - | ||||||||||||||||||
624 | QGuiApplicationPrivate::app_icon = 0; | - | ||||||||||||||||||
625 | delete QGuiApplicationPrivate::platform_name; | - | ||||||||||||||||||
626 | QGuiApplicationPrivate::platform_name = 0; | - | ||||||||||||||||||
627 | delete QGuiApplicationPrivate::displayName; | - | ||||||||||||||||||
628 | QGuiApplicationPrivate::displayName = 0; | - | ||||||||||||||||||
629 | delete QGuiApplicationPrivate::m_inputDeviceManager; | - | ||||||||||||||||||
630 | QGuiApplicationPrivate::m_inputDeviceManager = 0; | - | ||||||||||||||||||
631 | } never executed: end of block | 0 | ||||||||||||||||||
632 | - | |||||||||||||||||||
633 | QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags) | - | ||||||||||||||||||
634 | : QCoreApplicationPrivate(argc, argv, flags), | - | ||||||||||||||||||
635 | inputMethod(0), | - | ||||||||||||||||||
636 | lastTouchType(QEvent::TouchEnd), | - | ||||||||||||||||||
637 | ownGlobalShareContext(false) | - | ||||||||||||||||||
638 | { | - | ||||||||||||||||||
639 | self = this; | - | ||||||||||||||||||
640 | application_type = QCoreApplicationPrivate::Gui; | - | ||||||||||||||||||
641 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
642 | is_session_restored = false; | - | ||||||||||||||||||
643 | is_saving_session = false; | - | ||||||||||||||||||
644 | #endif | - | ||||||||||||||||||
645 | } never executed: end of block | 0 | ||||||||||||||||||
646 | - | |||||||||||||||||||
647 | /*! | - | ||||||||||||||||||
648 | \property QGuiApplication::applicationDisplayName | - | ||||||||||||||||||
649 | \brief the user-visible name of this application | - | ||||||||||||||||||
650 | \since 5.0 | - | ||||||||||||||||||
651 | - | |||||||||||||||||||
652 | This name is shown to the user, for instance in window titles. | - | ||||||||||||||||||
653 | It can be translated, if necessary. | - | ||||||||||||||||||
654 | - | |||||||||||||||||||
655 | If not set, the application display name defaults to the application name. | - | ||||||||||||||||||
656 | - | |||||||||||||||||||
657 | \sa applicationName | - | ||||||||||||||||||
658 | */ | - | ||||||||||||||||||
659 | void QGuiApplication::setApplicationDisplayName(const QString &name) | - | ||||||||||||||||||
660 | { | - | ||||||||||||||||||
661 | if (!QGuiApplicationPrivate::displayName)
| 0 | ||||||||||||||||||
662 | QGuiApplicationPrivate::displayName = new QString; never executed: QGuiApplicationPrivate::displayName = new QString; | 0 | ||||||||||||||||||
663 | *QGuiApplicationPrivate::displayName = name; | - | ||||||||||||||||||
664 | } never executed: end of block | 0 | ||||||||||||||||||
665 | - | |||||||||||||||||||
666 | QString QGuiApplication::applicationDisplayName() | - | ||||||||||||||||||
667 | { | - | ||||||||||||||||||
668 | return QGuiApplicationPrivate::displayName ? *QGuiApplicationPrivate::displayName : applicationName(); never executed: return QGuiApplicationPrivate::displayName ? *QGuiApplicationPrivate::displayName : applicationName();
| 0 | ||||||||||||||||||
669 | } | - | ||||||||||||||||||
670 | - | |||||||||||||||||||
671 | /*! | - | ||||||||||||||||||
672 | Returns the most recently shown modal window. If no modal windows are | - | ||||||||||||||||||
673 | visible, this function returns zero. | - | ||||||||||||||||||
674 | - | |||||||||||||||||||
675 | A modal window is a window which has its | - | ||||||||||||||||||
676 | \l{QWindow::modality}{modality} property set to Qt::WindowModal | - | ||||||||||||||||||
677 | or Qt::ApplicationModal. A modal window must be closed before the user can | - | ||||||||||||||||||
678 | continue with other parts of the program. | - | ||||||||||||||||||
679 | - | |||||||||||||||||||
680 | Modal window are organized in a stack. This function returns the modal | - | ||||||||||||||||||
681 | window at the top of the stack. | - | ||||||||||||||||||
682 | - | |||||||||||||||||||
683 | \sa Qt::WindowModality, QWindow::setModality() | - | ||||||||||||||||||
684 | */ | - | ||||||||||||||||||
685 | QWindow *QGuiApplication::modalWindow() | - | ||||||||||||||||||
686 | { | - | ||||||||||||||||||
687 | CHECK_QAPP_INSTANCE(Q_NULLPTR) never executed: end of block never executed: return nullptr;
| 0 | ||||||||||||||||||
688 | if (QGuiApplicationPrivate::self->modalWindowList.isEmpty())
| 0 | ||||||||||||||||||
689 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
690 | return QGuiApplicationPrivate::self->modalWindowList.first(); never executed: return QGuiApplicationPrivate::self->modalWindowList.first(); | 0 | ||||||||||||||||||
691 | } | - | ||||||||||||||||||
692 | - | |||||||||||||||||||
693 | static void updateBlockedStatusRecursion(QWindow *window, bool shouldBeBlocked) | - | ||||||||||||||||||
694 | { | - | ||||||||||||||||||
695 | QWindowPrivate *p = qt_window_private(window); | - | ||||||||||||||||||
696 | if (p->blockedByModalWindow != shouldBeBlocked) {
| 0 | ||||||||||||||||||
697 | p->blockedByModalWindow = shouldBeBlocked; | - | ||||||||||||||||||
698 | QEvent e(shouldBeBlocked ? QEvent::WindowBlocked : QEvent::WindowUnblocked); | - | ||||||||||||||||||
699 | QGuiApplication::sendEvent(window, &e); | - | ||||||||||||||||||
700 | foreach (QObject *c, window->children()) | - | ||||||||||||||||||
701 | if (c->isWindowType())
| 0 | ||||||||||||||||||
702 | updateBlockedStatusRecursion(static_cast<QWindow *>(c), shouldBeBlocked); never executed: updateBlockedStatusRecursion(static_cast<QWindow *>(c), shouldBeBlocked); | 0 | ||||||||||||||||||
703 | } never executed: end of block | 0 | ||||||||||||||||||
704 | } never executed: end of block | 0 | ||||||||||||||||||
705 | - | |||||||||||||||||||
706 | void QGuiApplicationPrivate::updateBlockedStatus(QWindow *window) | - | ||||||||||||||||||
707 | { | - | ||||||||||||||||||
708 | bool shouldBeBlocked = false; | - | ||||||||||||||||||
709 | if (!QWindowPrivate::get(window)->isPopup() && !self->modalWindowList.isEmpty())
| 0 | ||||||||||||||||||
710 | shouldBeBlocked = self->isWindowBlocked(window); never executed: shouldBeBlocked = self->isWindowBlocked(window); | 0 | ||||||||||||||||||
711 | updateBlockedStatusRecursion(window, shouldBeBlocked); | - | ||||||||||||||||||
712 | } never executed: end of block | 0 | ||||||||||||||||||
713 | - | |||||||||||||||||||
714 | void QGuiApplicationPrivate::showModalWindow(QWindow *modal) | - | ||||||||||||||||||
715 | { | - | ||||||||||||||||||
716 | self->modalWindowList.prepend(modal); | - | ||||||||||||||||||
717 | - | |||||||||||||||||||
718 | // Send leave for currently entered window if it should be blocked | - | ||||||||||||||||||
719 | if (currentMouseWindow && !QWindowPrivate::get(currentMouseWindow)->isPopup()) {
| 0 | ||||||||||||||||||
720 | bool shouldBeBlocked = self->isWindowBlocked(currentMouseWindow); | - | ||||||||||||||||||
721 | if (shouldBeBlocked) {
| 0 | ||||||||||||||||||
722 | // Remove the new window from modalWindowList temporarily so leave can go through | - | ||||||||||||||||||
723 | self->modalWindowList.removeFirst(); | - | ||||||||||||||||||
724 | QEvent e(QEvent::Leave); | - | ||||||||||||||||||
725 | QGuiApplication::sendEvent(currentMouseWindow, &e); | - | ||||||||||||||||||
726 | currentMouseWindow = 0; | - | ||||||||||||||||||
727 | self->modalWindowList.prepend(modal); | - | ||||||||||||||||||
728 | } never executed: end of block | 0 | ||||||||||||||||||
729 | } never executed: end of block | 0 | ||||||||||||||||||
730 | - | |||||||||||||||||||
731 | QWindowList windows = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
732 | for (int i = 0; i < windows.count(); ++i) {
| 0 | ||||||||||||||||||
733 | QWindow *window = windows.at(i); | - | ||||||||||||||||||
734 | if (!window->d_func()->blockedByModalWindow)
| 0 | ||||||||||||||||||
735 | updateBlockedStatus(window); never executed: updateBlockedStatus(window); | 0 | ||||||||||||||||||
736 | } never executed: end of block | 0 | ||||||||||||||||||
737 | - | |||||||||||||||||||
738 | updateBlockedStatus(modal); | - | ||||||||||||||||||
739 | } never executed: end of block | 0 | ||||||||||||||||||
740 | - | |||||||||||||||||||
741 | void QGuiApplicationPrivate::hideModalWindow(QWindow *window) | - | ||||||||||||||||||
742 | { | - | ||||||||||||||||||
743 | self->modalWindowList.removeAll(window); | - | ||||||||||||||||||
744 | - | |||||||||||||||||||
745 | QWindowList windows = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
746 | for (int i = 0; i < windows.count(); ++i) {
| 0 | ||||||||||||||||||
747 | QWindow *window = windows.at(i); | - | ||||||||||||||||||
748 | if (window->d_func()->blockedByModalWindow)
| 0 | ||||||||||||||||||
749 | updateBlockedStatus(window); never executed: updateBlockedStatus(window); | 0 | ||||||||||||||||||
750 | } never executed: end of block | 0 | ||||||||||||||||||
751 | } never executed: end of block | 0 | ||||||||||||||||||
752 | - | |||||||||||||||||||
753 | /* | - | ||||||||||||||||||
754 | Returns \c true if \a window is blocked by a modal window. If \a | - | ||||||||||||||||||
755 | blockingWindow is non-zero, *blockingWindow will be set to the blocking | - | ||||||||||||||||||
756 | window (or to zero if \a window is not blocked). | - | ||||||||||||||||||
757 | */ | - | ||||||||||||||||||
758 | bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const | - | ||||||||||||||||||
759 | { | - | ||||||||||||||||||
760 | QWindow *unused = 0; | - | ||||||||||||||||||
761 | if (!blockingWindow)
| 0 | ||||||||||||||||||
762 | blockingWindow = &unused; never executed: blockingWindow = &unused; | 0 | ||||||||||||||||||
763 | - | |||||||||||||||||||
764 | if (modalWindowList.isEmpty()) {
| 0 | ||||||||||||||||||
765 | *blockingWindow = 0; | - | ||||||||||||||||||
766 | return false; never executed: return false; | 0 | ||||||||||||||||||
767 | } | - | ||||||||||||||||||
768 | - | |||||||||||||||||||
769 | for (int i = 0; i < modalWindowList.count(); ++i) {
| 0 | ||||||||||||||||||
770 | QWindow *modalWindow = modalWindowList.at(i); | - | ||||||||||||||||||
771 | - | |||||||||||||||||||
772 | { | - | ||||||||||||||||||
773 | // check if the modal window is our window or a (transient) parent of our window | - | ||||||||||||||||||
774 | QWindow *w = window; | - | ||||||||||||||||||
775 | while (w) {
| 0 | ||||||||||||||||||
776 | if (w == modalWindow) {
| 0 | ||||||||||||||||||
777 | *blockingWindow = 0; | - | ||||||||||||||||||
778 | return false; never executed: return false; | 0 | ||||||||||||||||||
779 | } | - | ||||||||||||||||||
780 | QWindow *p = w->parent(); | - | ||||||||||||||||||
781 | if (!p)
| 0 | ||||||||||||||||||
782 | p = w->transientParent(); never executed: p = w->transientParent(); | 0 | ||||||||||||||||||
783 | w = p; | - | ||||||||||||||||||
784 | } never executed: end of block | 0 | ||||||||||||||||||
785 | } | - | ||||||||||||||||||
786 | - | |||||||||||||||||||
787 | Qt::WindowModality windowModality = modalWindow->modality(); | - | ||||||||||||||||||
788 | switch (windowModality) { | - | ||||||||||||||||||
789 | case Qt::ApplicationModal: never executed: case Qt::ApplicationModal: | 0 | ||||||||||||||||||
790 | { | - | ||||||||||||||||||
791 | if (modalWindow != window) {
| 0 | ||||||||||||||||||
792 | *blockingWindow = modalWindow; | - | ||||||||||||||||||
793 | return true; never executed: return true; | 0 | ||||||||||||||||||
794 | } | - | ||||||||||||||||||
795 | break; never executed: break; | 0 | ||||||||||||||||||
796 | } | - | ||||||||||||||||||
797 | case Qt::WindowModal: never executed: case Qt::WindowModal: | 0 | ||||||||||||||||||
798 | { | - | ||||||||||||||||||
799 | QWindow *w = window; | - | ||||||||||||||||||
800 | do { | - | ||||||||||||||||||
801 | QWindow *m = modalWindow; | - | ||||||||||||||||||
802 | do { | - | ||||||||||||||||||
803 | if (m == w) {
| 0 | ||||||||||||||||||
804 | *blockingWindow = m; | - | ||||||||||||||||||
805 | return true; never executed: return true; | 0 | ||||||||||||||||||
806 | } | - | ||||||||||||||||||
807 | QWindow *p = m->parent(); | - | ||||||||||||||||||
808 | if (!p)
| 0 | ||||||||||||||||||
809 | p = m->transientParent(); never executed: p = m->transientParent(); | 0 | ||||||||||||||||||
810 | m = p; | - | ||||||||||||||||||
811 | } while (m); never executed: end of block
| 0 | ||||||||||||||||||
812 | QWindow *p = w->parent(); | - | ||||||||||||||||||
813 | if (!p)
| 0 | ||||||||||||||||||
814 | p = w->transientParent(); never executed: p = w->transientParent(); | 0 | ||||||||||||||||||
815 | w = p; | - | ||||||||||||||||||
816 | } while (w); never executed: end of block
| 0 | ||||||||||||||||||
817 | break; never executed: break; | 0 | ||||||||||||||||||
818 | } | - | ||||||||||||||||||
819 | default: never executed: default: | 0 | ||||||||||||||||||
820 | Q_ASSERT_X(false, "QGuiApplication", "internal error, a modal widget cannot be modeless"); | - | ||||||||||||||||||
821 | break; never executed: break; | 0 | ||||||||||||||||||
822 | } | - | ||||||||||||||||||
823 | } | - | ||||||||||||||||||
824 | *blockingWindow = 0; | - | ||||||||||||||||||
825 | return false; never executed: return false; | 0 | ||||||||||||||||||
826 | } | - | ||||||||||||||||||
827 | - | |||||||||||||||||||
828 | /*! | - | ||||||||||||||||||
829 | Returns the QWindow that receives events tied to focus, | - | ||||||||||||||||||
830 | such as key events. | - | ||||||||||||||||||
831 | */ | - | ||||||||||||||||||
832 | QWindow *QGuiApplication::focusWindow() | - | ||||||||||||||||||
833 | { | - | ||||||||||||||||||
834 | return QGuiApplicationPrivate::focus_window; never executed: return QGuiApplicationPrivate::focus_window; | 0 | ||||||||||||||||||
835 | } | - | ||||||||||||||||||
836 | - | |||||||||||||||||||
837 | /*! | - | ||||||||||||||||||
838 | \fn QGuiApplication::focusObjectChanged(QObject *focusObject) | - | ||||||||||||||||||
839 | - | |||||||||||||||||||
840 | This signal is emitted when final receiver of events tied to focus is changed. | - | ||||||||||||||||||
841 | \a focusObject is the new receiver. | - | ||||||||||||||||||
842 | - | |||||||||||||||||||
843 | \sa focusObject() | - | ||||||||||||||||||
844 | */ | - | ||||||||||||||||||
845 | - | |||||||||||||||||||
846 | /*! | - | ||||||||||||||||||
847 | \fn QGuiApplication::focusWindowChanged(QWindow *focusWindow) | - | ||||||||||||||||||
848 | - | |||||||||||||||||||
849 | This signal is emitted when the focused window changes. | - | ||||||||||||||||||
850 | \a focusWindow is the new focused window. | - | ||||||||||||||||||
851 | - | |||||||||||||||||||
852 | \sa focusWindow() | - | ||||||||||||||||||
853 | */ | - | ||||||||||||||||||
854 | - | |||||||||||||||||||
855 | /*! | - | ||||||||||||||||||
856 | Returns the QObject in currently active window that will be final receiver of events | - | ||||||||||||||||||
857 | tied to focus, such as key events. | - | ||||||||||||||||||
858 | */ | - | ||||||||||||||||||
859 | QObject *QGuiApplication::focusObject() | - | ||||||||||||||||||
860 | { | - | ||||||||||||||||||
861 | if (focusWindow())
| 0 | ||||||||||||||||||
862 | return focusWindow()->focusObject(); never executed: return focusWindow()->focusObject(); | 0 | ||||||||||||||||||
863 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
864 | } | - | ||||||||||||||||||
865 | - | |||||||||||||||||||
866 | /*! | - | ||||||||||||||||||
867 | \fn QGuiApplication::allWindows() | - | ||||||||||||||||||
868 | - | |||||||||||||||||||
869 | Returns a list of all the windows in the application. | - | ||||||||||||||||||
870 | - | |||||||||||||||||||
871 | The list is empty if there are no windows. | - | ||||||||||||||||||
872 | - | |||||||||||||||||||
873 | \sa topLevelWindows() | - | ||||||||||||||||||
874 | */ | - | ||||||||||||||||||
875 | QWindowList QGuiApplication::allWindows() | - | ||||||||||||||||||
876 | { | - | ||||||||||||||||||
877 | return QGuiApplicationPrivate::window_list; never executed: return QGuiApplicationPrivate::window_list; | 0 | ||||||||||||||||||
878 | } | - | ||||||||||||||||||
879 | - | |||||||||||||||||||
880 | /*! | - | ||||||||||||||||||
881 | \fn QGuiApplication::topLevelWindows() | - | ||||||||||||||||||
882 | - | |||||||||||||||||||
883 | Returns a list of the top-level windows in the application. | - | ||||||||||||||||||
884 | - | |||||||||||||||||||
885 | \sa allWindows() | - | ||||||||||||||||||
886 | */ | - | ||||||||||||||||||
887 | QWindowList QGuiApplication::topLevelWindows() | - | ||||||||||||||||||
888 | { | - | ||||||||||||||||||
889 | const QWindowList &list = QGuiApplicationPrivate::window_list; | - | ||||||||||||||||||
890 | QWindowList topLevelWindows; | - | ||||||||||||||||||
891 | for (int i = 0; i < list.size(); i++) {
| 0 | ||||||||||||||||||
892 | if (!list.at(i)->parent() && list.at(i)->type() != Qt::Desktop) {
| 0 | ||||||||||||||||||
893 | // Top windows of embedded QAxServers do not have QWindow parents, | - | ||||||||||||||||||
894 | // but they are not true top level windows, so do not include them. | - | ||||||||||||||||||
895 | const bool embedded = list.at(i)->handle() && list.at(i)->handle()->isEmbedded();
| 0 | ||||||||||||||||||
896 | if (!embedded)
| 0 | ||||||||||||||||||
897 | topLevelWindows.prepend(list.at(i)); never executed: topLevelWindows.prepend(list.at(i)); | 0 | ||||||||||||||||||
898 | } never executed: end of block | 0 | ||||||||||||||||||
899 | } never executed: end of block | 0 | ||||||||||||||||||
900 | return topLevelWindows; never executed: return topLevelWindows; | 0 | ||||||||||||||||||
901 | } | - | ||||||||||||||||||
902 | - | |||||||||||||||||||
903 | QScreen *QGuiApplication::primaryScreen() | - | ||||||||||||||||||
904 | { | - | ||||||||||||||||||
905 | if (QGuiApplicationPrivate::screen_list.isEmpty())
| 0 | ||||||||||||||||||
906 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
907 | return QGuiApplicationPrivate::screen_list.at(0); never executed: return QGuiApplicationPrivate::screen_list.at(0); | 0 | ||||||||||||||||||
908 | } | - | ||||||||||||||||||
909 | - | |||||||||||||||||||
910 | /*! | - | ||||||||||||||||||
911 | Returns a list of all the screens associated with the | - | ||||||||||||||||||
912 | windowing system the application is connected to. | - | ||||||||||||||||||
913 | */ | - | ||||||||||||||||||
914 | QList<QScreen *> QGuiApplication::screens() | - | ||||||||||||||||||
915 | { | - | ||||||||||||||||||
916 | return QGuiApplicationPrivate::screen_list; never executed: return QGuiApplicationPrivate::screen_list; | 0 | ||||||||||||||||||
917 | } | - | ||||||||||||||||||
918 | - | |||||||||||||||||||
919 | /*! | - | ||||||||||||||||||
920 | \fn void QGuiApplication::screenAdded(QScreen *screen) | - | ||||||||||||||||||
921 | - | |||||||||||||||||||
922 | This signal is emitted whenever a new screen \a screen has been added to the system. | - | ||||||||||||||||||
923 | - | |||||||||||||||||||
924 | \sa screens(), primaryScreen, screenRemoved() | - | ||||||||||||||||||
925 | */ | - | ||||||||||||||||||
926 | - | |||||||||||||||||||
927 | /*! | - | ||||||||||||||||||
928 | \fn void QGuiApplication::screenRemoved(QScreen *screen) | - | ||||||||||||||||||
929 | - | |||||||||||||||||||
930 | This signal is emitted whenever a \a screen is removed from the system. It | - | ||||||||||||||||||
931 | provides an opportunity to manage the windows on the screen before Qt falls back | - | ||||||||||||||||||
932 | to moving them to the primary screen. | - | ||||||||||||||||||
933 | - | |||||||||||||||||||
934 | \sa screens(), screenAdded(), QObject::destroyed(), QWindow::setScreen() | - | ||||||||||||||||||
935 | - | |||||||||||||||||||
936 | \since 5.4 | - | ||||||||||||||||||
937 | */ | - | ||||||||||||||||||
938 | - | |||||||||||||||||||
939 | - | |||||||||||||||||||
940 | /*! | - | ||||||||||||||||||
941 | \property QGuiApplication::primaryScreen | - | ||||||||||||||||||
942 | - | |||||||||||||||||||
943 | \brief the primary (or default) screen of the application. | - | ||||||||||||||||||
944 | - | |||||||||||||||||||
945 | This will be the screen where QWindows are initially shown, unless otherwise specified. | - | ||||||||||||||||||
946 | - | |||||||||||||||||||
947 | The primaryScreenChanged signal was introduced in Qt 5.6. | - | ||||||||||||||||||
948 | - | |||||||||||||||||||
949 | \sa screens() | - | ||||||||||||||||||
950 | */ | - | ||||||||||||||||||
951 | - | |||||||||||||||||||
952 | /*! | - | ||||||||||||||||||
953 | Returns the highest screen device pixel ratio found on | - | ||||||||||||||||||
954 | the system. This is the ratio between physical pixels and | - | ||||||||||||||||||
955 | device-independent pixels. | - | ||||||||||||||||||
956 | - | |||||||||||||||||||
957 | Use this function only when you don't know which window you are targeting. | - | ||||||||||||||||||
958 | If you do know the target window, use QWindow::devicePixelRatio() instead. | - | ||||||||||||||||||
959 | - | |||||||||||||||||||
960 | \sa QWindow::devicePixelRatio() | - | ||||||||||||||||||
961 | */ | - | ||||||||||||||||||
962 | qreal QGuiApplication::devicePixelRatio() const | - | ||||||||||||||||||
963 | { | - | ||||||||||||||||||
964 | // Cache topDevicePixelRatio, iterate through the screen list once only. | - | ||||||||||||||||||
965 | static qreal topDevicePixelRatio = 0.0; | - | ||||||||||||||||||
966 | if (!qFuzzyIsNull(topDevicePixelRatio)) {
| 0 | ||||||||||||||||||
967 | return topDevicePixelRatio; never executed: return topDevicePixelRatio; | 0 | ||||||||||||||||||
968 | } | - | ||||||||||||||||||
969 | - | |||||||||||||||||||
970 | topDevicePixelRatio = 1.0; // make sure we never return 0. | - | ||||||||||||||||||
971 | foreach (QScreen *screen, QGuiApplicationPrivate::screen_list) { | - | ||||||||||||||||||
972 | topDevicePixelRatio = qMax(topDevicePixelRatio, screen->devicePixelRatio()); | - | ||||||||||||||||||
973 | } never executed: end of block | 0 | ||||||||||||||||||
974 | - | |||||||||||||||||||
975 | return topDevicePixelRatio; never executed: return topDevicePixelRatio; | 0 | ||||||||||||||||||
976 | } | - | ||||||||||||||||||
977 | - | |||||||||||||||||||
978 | /*! | - | ||||||||||||||||||
979 | Returns the top level window at the given position \a pos, if any. | - | ||||||||||||||||||
980 | */ | - | ||||||||||||||||||
981 | QWindow *QGuiApplication::topLevelAt(const QPoint &pos) | - | ||||||||||||||||||
982 | { | - | ||||||||||||||||||
983 | const QList<QScreen *> screens = QGuiApplication::screens(); | - | ||||||||||||||||||
984 | if (!screens.isEmpty()) {
| 0 | ||||||||||||||||||
985 | const QList<QScreen *> primaryScreens = screens.first()->virtualSiblings(); | - | ||||||||||||||||||
986 | QScreen *windowScreen = Q_NULLPTR; | - | ||||||||||||||||||
987 | - | |||||||||||||||||||
988 | // Find the window on the primary virtual desktop first | - | ||||||||||||||||||
989 | foreach (QScreen *screen, primaryScreens) { | - | ||||||||||||||||||
990 | if (screen->geometry().contains(pos)) {
| 0 | ||||||||||||||||||
991 | windowScreen = screen; | - | ||||||||||||||||||
992 | break; never executed: break; | 0 | ||||||||||||||||||
993 | } | - | ||||||||||||||||||
994 | } never executed: end of block | 0 | ||||||||||||||||||
995 | - | |||||||||||||||||||
996 | // If the window is not found on primary virtual desktop, find it on all screens | - | ||||||||||||||||||
997 | // except the first which was for sure in the previous loop. Some other screens | - | ||||||||||||||||||
998 | // may repeat. Find only when there is more than one virtual desktop. | - | ||||||||||||||||||
999 | if (!windowScreen && screens.count() != primaryScreens.count()) {
| 0 | ||||||||||||||||||
1000 | for (int i = 1; i < screens.size(); ++i) {
| 0 | ||||||||||||||||||
1001 | QScreen *screen = screens[i]; | - | ||||||||||||||||||
1002 | if (screen->geometry().contains(pos)) {
| 0 | ||||||||||||||||||
1003 | windowScreen = screen; | - | ||||||||||||||||||
1004 | break; never executed: break; | 0 | ||||||||||||||||||
1005 | } | - | ||||||||||||||||||
1006 | } never executed: end of block | 0 | ||||||||||||||||||
1007 | } never executed: end of block | 0 | ||||||||||||||||||
1008 | - | |||||||||||||||||||
1009 | if (windowScreen) {
| 0 | ||||||||||||||||||
1010 | const QPoint devicePosition = QHighDpi::toNativePixels(pos, windowScreen); | - | ||||||||||||||||||
1011 | return windowScreen->handle()->topLevelAt(devicePosition); never executed: return windowScreen->handle()->topLevelAt(devicePosition); | 0 | ||||||||||||||||||
1012 | } | - | ||||||||||||||||||
1013 | } never executed: end of block | 0 | ||||||||||||||||||
1014 | return Q_NULLPTR; never executed: return nullptr; | 0 | ||||||||||||||||||
1015 | } | - | ||||||||||||||||||
1016 | - | |||||||||||||||||||
1017 | /*! | - | ||||||||||||||||||
1018 | \property QGuiApplication::platformName | - | ||||||||||||||||||
1019 | \brief The name of the underlying platform plugin. | - | ||||||||||||||||||
1020 | - | |||||||||||||||||||
1021 | The QPA platform plugins are located in \c {qtbase\src\plugins\platforms}. | - | ||||||||||||||||||
1022 | At the time of writing, the following platform plugin names are supported: | - | ||||||||||||||||||
1023 | - | |||||||||||||||||||
1024 | \list | - | ||||||||||||||||||
1025 | \li \c android | - | ||||||||||||||||||
1026 | \li \c cocoa is a platform plugin for \macos. | - | ||||||||||||||||||
1027 | \li \c directfb | - | ||||||||||||||||||
1028 | \li \c eglfs is a platform plugin for running Qt5 applications on top of | - | ||||||||||||||||||
1029 | EGL and OpenGL ES 2.0 without an actual windowing system (like X11 | - | ||||||||||||||||||
1030 | or Wayland). For more information, see \l{EGLFS}. | - | ||||||||||||||||||
1031 | \li \c ios | - | ||||||||||||||||||
1032 | \li \c kms is an experimental platform plugin using kernel modesetting | - | ||||||||||||||||||
1033 | and \l{http://dri.freedesktop.org/wiki/DRM}{DRM} (Direct Rendering | - | ||||||||||||||||||
1034 | Manager). | - | ||||||||||||||||||
1035 | \li \c linuxfb writes directly to the framebuffer. For more information, | - | ||||||||||||||||||
1036 | see \l{LinuxFB}. | - | ||||||||||||||||||
1037 | \li \c minimal is provided as an examples for developers who want to | - | ||||||||||||||||||
1038 | write their own platform plugins. However, you can use the plugin to | - | ||||||||||||||||||
1039 | run GUI applications in environments without a GUI, such as servers. | - | ||||||||||||||||||
1040 | \li \c minimalegl is an example plugin. | - | ||||||||||||||||||
1041 | \li \c offscreen | - | ||||||||||||||||||
1042 | \li \c openwfd | - | ||||||||||||||||||
1043 | \li \c qnx | - | ||||||||||||||||||
1044 | \li \c windows | - | ||||||||||||||||||
1045 | \li \c xcb is the X11 plugin used on regular desktop Linux platforms. | - | ||||||||||||||||||
1046 | \endlist | - | ||||||||||||||||||
1047 | - | |||||||||||||||||||
1048 | For more information about the platform plugins for embedded Linux devices, | - | ||||||||||||||||||
1049 | see \l{Qt for Embedded Linux}. | - | ||||||||||||||||||
1050 | */ | - | ||||||||||||||||||
1051 | - | |||||||||||||||||||
1052 | QString QGuiApplication::platformName() | - | ||||||||||||||||||
1053 | { | - | ||||||||||||||||||
1054 | return QGuiApplicationPrivate::platform_name ? never executed: return QGuiApplicationPrivate::platform_name ? *QGuiApplicationPrivate::platform_name : QString();
| 0 | ||||||||||||||||||
1055 | *QGuiApplicationPrivate::platform_name : QString(); never executed: return QGuiApplicationPrivate::platform_name ? *QGuiApplicationPrivate::platform_name : QString(); | 0 | ||||||||||||||||||
1056 | } | - | ||||||||||||||||||
1057 | - | |||||||||||||||||||
1058 | static void init_platform(const QString &pluginArgument, const QString &platformPluginPath, const QString &platformThemeName, int &argc, char **argv) | - | ||||||||||||||||||
1059 | { | - | ||||||||||||||||||
1060 | // Split into platform name and arguments | - | ||||||||||||||||||
1061 | QStringList arguments = pluginArgument.split(QLatin1Char(':')); | - | ||||||||||||||||||
1062 | const QString name = arguments.takeFirst().toLower(); | - | ||||||||||||||||||
1063 | QString argumentsKey = name; | - | ||||||||||||||||||
1064 | argumentsKey[0] = argumentsKey.at(0).toUpper(); | - | ||||||||||||||||||
1065 | arguments.append(QLibraryInfo::platformPluginArguments(argumentsKey)); | - | ||||||||||||||||||
1066 | - | |||||||||||||||||||
1067 | // Create the platform integration. | - | ||||||||||||||||||
1068 | QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, argc, argv, platformPluginPath); | - | ||||||||||||||||||
1069 | if (QGuiApplicationPrivate::platform_integration) {
| 0 | ||||||||||||||||||
1070 | QGuiApplicationPrivate::platform_name = new QString(name); | - | ||||||||||||||||||
1071 | } else { never executed: end of block | 0 | ||||||||||||||||||
1072 | QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath); | - | ||||||||||||||||||
1073 | - | |||||||||||||||||||
1074 | QString fatalMessage | - | ||||||||||||||||||
1075 | = QStringLiteral("This application failed to start because it could not find or load the Qt platform plugin \"%1\"\nin \"%2\".\n\n").arg(name, QDir::toNativeSeparators(platformPluginPath)); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
1076 | if (!keys.isEmpty()) {
| 0 | ||||||||||||||||||
1077 | fatalMessage += QStringLiteral("Available platform plugins are: %1.\n\n").arg( never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
1078 | keys.join(QStringLiteral(", "))); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
1079 | } never executed: end of block | 0 | ||||||||||||||||||
1080 | fatalMessage += QStringLiteral("Reinstalling the application may fix this problem."); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
1081 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) | - | ||||||||||||||||||
1082 | // Windows: Display message box unless it is a console application | - | ||||||||||||||||||
1083 | // or debug build showing an assert box. | - | ||||||||||||||||||
1084 | if (!QLibraryInfo::isDebugBuild() && !GetConsoleWindow()) | - | ||||||||||||||||||
1085 | MessageBox(0, (LPCTSTR)fatalMessage.utf16(), (LPCTSTR)(QCoreApplication::applicationName().utf16()), MB_OK | MB_ICONERROR); | - | ||||||||||||||||||
1086 | #endif // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT | - | ||||||||||||||||||
1087 | qFatal("%s", qPrintable(fatalMessage)); | - | ||||||||||||||||||
1088 | return; never executed: return; | 0 | ||||||||||||||||||
1089 | } | - | ||||||||||||||||||
1090 | - | |||||||||||||||||||
1091 | // Many platforms have created QScreens at this point. Finish initializing | - | ||||||||||||||||||
1092 | // QHighDpiScaling to be prepared for early calls to qt_defaultDpi(). | - | ||||||||||||||||||
1093 | if (QGuiApplication::primaryScreen()) {
| 0 | ||||||||||||||||||
1094 | QGuiApplicationPrivate::highDpiScalingUpdated = true; | - | ||||||||||||||||||
1095 | QHighDpiScaling::updateHighDpiScaling(); | - | ||||||||||||||||||
1096 | } never executed: end of block | 0 | ||||||||||||||||||
1097 | - | |||||||||||||||||||
1098 | // Create the platform theme: | - | ||||||||||||||||||
1099 | - | |||||||||||||||||||
1100 | // 1) Fetch the platform name from the environment if present. | - | ||||||||||||||||||
1101 | QStringList themeNames; | - | ||||||||||||||||||
1102 | if (!platformThemeName.isEmpty())
| 0 | ||||||||||||||||||
1103 | themeNames.append(platformThemeName); never executed: themeNames.append(platformThemeName); | 0 | ||||||||||||||||||
1104 | - | |||||||||||||||||||
1105 | // 2) Ask the platform integration for a list of theme names | - | ||||||||||||||||||
1106 | themeNames += QGuiApplicationPrivate::platform_integration->themeNames(); | - | ||||||||||||||||||
1107 | // 3) Look for a theme plugin. | - | ||||||||||||||||||
1108 | foreach (const QString &themeName, themeNames) { | - | ||||||||||||||||||
1109 | QGuiApplicationPrivate::platform_theme = QPlatformThemeFactory::create(themeName, platformPluginPath); | - | ||||||||||||||||||
1110 | if (QGuiApplicationPrivate::platform_theme)
| 0 | ||||||||||||||||||
1111 | break; never executed: break; | 0 | ||||||||||||||||||
1112 | } never executed: end of block | 0 | ||||||||||||||||||
1113 | - | |||||||||||||||||||
1114 | // 4) If no theme plugin was found ask the platform integration to | - | ||||||||||||||||||
1115 | // create a theme | - | ||||||||||||||||||
1116 | if (!QGuiApplicationPrivate::platform_theme) {
| 0 | ||||||||||||||||||
1117 | foreach (const QString &themeName, themeNames) { | - | ||||||||||||||||||
1118 | QGuiApplicationPrivate::platform_theme = QGuiApplicationPrivate::platform_integration->createPlatformTheme(themeName); | - | ||||||||||||||||||
1119 | if (QGuiApplicationPrivate::platform_theme)
| 0 | ||||||||||||||||||
1120 | break; never executed: break; | 0 | ||||||||||||||||||
1121 | } never executed: end of block | 0 | ||||||||||||||||||
1122 | // No error message; not having a theme plugin is allowed. | - | ||||||||||||||||||
1123 | } never executed: end of block | 0 | ||||||||||||||||||
1124 | - | |||||||||||||||||||
1125 | // 5) Fall back on the built-in "null" platform theme. | - | ||||||||||||||||||
1126 | if (!QGuiApplicationPrivate::platform_theme)
| 0 | ||||||||||||||||||
1127 | QGuiApplicationPrivate::platform_theme = new QPlatformTheme; never executed: QGuiApplicationPrivate::platform_theme = new QPlatformTheme; | 0 | ||||||||||||||||||
1128 | - | |||||||||||||||||||
1129 | #ifndef QT_NO_PROPERTIES | - | ||||||||||||||||||
1130 | // Set arguments as dynamic properties on the native interface as | - | ||||||||||||||||||
1131 | // boolean 'foo' or strings: 'foo=bar' | - | ||||||||||||||||||
1132 | if (!arguments.isEmpty()) {
| 0 | ||||||||||||||||||
1133 | if (QObject *nativeInterface = QGuiApplicationPrivate::platform_integration->nativeInterface()) {
| 0 | ||||||||||||||||||
1134 | foreach (const QString &argument, arguments) { | - | ||||||||||||||||||
1135 | const int equalsPos = argument.indexOf(QLatin1Char('=')); | - | ||||||||||||||||||
1136 | const QByteArray name = | - | ||||||||||||||||||
1137 | equalsPos != -1 ? argument.left(equalsPos).toUtf8() : argument.toUtf8();
| 0 | ||||||||||||||||||
1138 | const QVariant value = | - | ||||||||||||||||||
1139 | equalsPos != -1 ? QVariant(argument.mid(equalsPos + 1)) : QVariant(true);
| 0 | ||||||||||||||||||
1140 | nativeInterface->setProperty(name.constData(), value); | - | ||||||||||||||||||
1141 | } never executed: end of block | 0 | ||||||||||||||||||
1142 | } never executed: end of block | 0 | ||||||||||||||||||
1143 | } never executed: end of block | 0 | ||||||||||||||||||
1144 | #endif | - | ||||||||||||||||||
1145 | - | |||||||||||||||||||
1146 | fontSmoothingGamma = QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal(); | - | ||||||||||||||||||
1147 | } never executed: end of block | 0 | ||||||||||||||||||
1148 | - | |||||||||||||||||||
1149 | static void init_plugins(const QList<QByteArray> &pluginList) | - | ||||||||||||||||||
1150 | { | - | ||||||||||||||||||
1151 | for (int i = 0; i < pluginList.count(); ++i) {
| 0 | ||||||||||||||||||
1152 | QByteArray pluginSpec = pluginList.at(i); | - | ||||||||||||||||||
1153 | int colonPos = pluginSpec.indexOf(':'); | - | ||||||||||||||||||
1154 | QObject *plugin; | - | ||||||||||||||||||
1155 | if (colonPos < 0)
| 0 | ||||||||||||||||||
1156 | plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString()); never executed: plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString()); | 0 | ||||||||||||||||||
1157 | else | - | ||||||||||||||||||
1158 | plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)), never executed: plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)), QLatin1String(pluginSpec.mid(colonPos+1))); | 0 | ||||||||||||||||||
1159 | QLatin1String(pluginSpec.mid(colonPos+1))); never executed: plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)), QLatin1String(pluginSpec.mid(colonPos+1))); | 0 | ||||||||||||||||||
1160 | if (plugin)
| 0 | ||||||||||||||||||
1161 | QGuiApplicationPrivate::generic_plugin_list.append(plugin); never executed: QGuiApplicationPrivate::generic_plugin_list.append(plugin); | 0 | ||||||||||||||||||
1162 | else | - | ||||||||||||||||||
1163 | qWarning() << "No such plugin for spec " << pluginSpec; never executed: QMessageLogger(__FILE__, 1163, __PRETTY_FUNCTION__).warning() << "No such plugin for spec " << pluginSpec; | 0 | ||||||||||||||||||
1164 | } | - | ||||||||||||||||||
1165 | } never executed: end of block | 0 | ||||||||||||||||||
1166 | - | |||||||||||||||||||
1167 | void QGuiApplicationPrivate::createPlatformIntegration() | - | ||||||||||||||||||
1168 | { | - | ||||||||||||||||||
1169 | // Use the Qt menus by default. Platform plugins that | - | ||||||||||||||||||
1170 | // want to enable a native menu implementation can clear | - | ||||||||||||||||||
1171 | // this flag. | - | ||||||||||||||||||
1172 | QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); | - | ||||||||||||||||||
1173 | - | |||||||||||||||||||
1174 | - | |||||||||||||||||||
1175 | QHighDpiScaling::initHighDpiScaling(); | - | ||||||||||||||||||
1176 | - | |||||||||||||||||||
1177 | // Load the platform integration | - | ||||||||||||||||||
1178 | QString platformPluginPath = QString::fromLocal8Bit(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH")); | - | ||||||||||||||||||
1179 | - | |||||||||||||||||||
1180 | - | |||||||||||||||||||
1181 | QByteArray platformName; | - | ||||||||||||||||||
1182 | #ifdef QT_QPA_DEFAULT_PLATFORM_NAME | - | ||||||||||||||||||
1183 | platformName = QT_QPA_DEFAULT_PLATFORM_NAME; | - | ||||||||||||||||||
1184 | #endif | - | ||||||||||||||||||
1185 | QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM"); | - | ||||||||||||||||||
1186 | if (!platformNameEnv.isEmpty()) {
| 0 | ||||||||||||||||||
1187 | platformName = platformNameEnv; | - | ||||||||||||||||||
1188 | } never executed: end of block | 0 | ||||||||||||||||||
1189 | - | |||||||||||||||||||
1190 | QString platformThemeName = QString::fromLocal8Bit(qgetenv("QT_QPA_PLATFORMTHEME")); | - | ||||||||||||||||||
1191 | - | |||||||||||||||||||
1192 | // Get command line params | - | ||||||||||||||||||
1193 | - | |||||||||||||||||||
1194 | QString icon; | - | ||||||||||||||||||
1195 | - | |||||||||||||||||||
1196 | int j = argc ? 1 : 0;
| 0 | ||||||||||||||||||
1197 | for (int i=1; i<argc; i++) {
| 0 | ||||||||||||||||||
1198 | if (!argv[i])
| 0 | ||||||||||||||||||
1199 | continue; never executed: continue; | 0 | ||||||||||||||||||
1200 | if (*argv[i] != '-') {
| 0 | ||||||||||||||||||
1201 | argv[j++] = argv[i]; | - | ||||||||||||||||||
1202 | continue; never executed: continue; | 0 | ||||||||||||||||||
1203 | } | - | ||||||||||||||||||
1204 | const bool isXcb = platformName == "xcb"; | - | ||||||||||||||||||
1205 | const char *arg = argv[i]; | - | ||||||||||||||||||
1206 | if (arg[1] == '-') // startsWith("--")
| 0 | ||||||||||||||||||
1207 | ++arg; never executed: ++arg; | 0 | ||||||||||||||||||
1208 | if (strcmp(arg, "-platformpluginpath") == 0) {
| 0 | ||||||||||||||||||
1209 | if (++i < argc)
| 0 | ||||||||||||||||||
1210 | platformPluginPath = QString::fromLocal8Bit(argv[i]); never executed: platformPluginPath = QString::fromLocal8Bit(argv[i]); | 0 | ||||||||||||||||||
1211 | } else if (strcmp(arg, "-platform") == 0) { never executed: end of block
| 0 | ||||||||||||||||||
1212 | if (++i < argc)
| 0 | ||||||||||||||||||
1213 | platformName = argv[i]; never executed: platformName = argv[i]; | 0 | ||||||||||||||||||
1214 | } else if (strcmp(arg, "-platformtheme") == 0) { never executed: end of block
| 0 | ||||||||||||||||||
1215 | if (++i < argc)
| 0 | ||||||||||||||||||
1216 | platformThemeName = QString::fromLocal8Bit(argv[i]); never executed: platformThemeName = QString::fromLocal8Bit(argv[i]); | 0 | ||||||||||||||||||
1217 | } else if (strcmp(arg, "-qwindowgeometry") == 0 || (isXcb && strcmp(arg, "-geometry") == 0)) { never executed: end of block
| 0 | ||||||||||||||||||
1218 | if (++i < argc)
| 0 | ||||||||||||||||||
1219 | windowGeometrySpecification = QWindowGeometrySpecification::fromArgument(argv[i]); never executed: windowGeometrySpecification = QWindowGeometrySpecification::fromArgument(argv[i]); | 0 | ||||||||||||||||||
1220 | } else if (strcmp(arg, "-qwindowtitle") == 0 || (isXcb && strcmp(arg, "-title") == 0)) { never executed: end of block
| 0 | ||||||||||||||||||
1221 | if (++i < argc)
| 0 | ||||||||||||||||||
1222 | firstWindowTitle = QString::fromLocal8Bit(argv[i]); never executed: firstWindowTitle = QString::fromLocal8Bit(argv[i]); | 0 | ||||||||||||||||||
1223 | } else if (strcmp(arg, "-qwindowicon") == 0 || (isXcb && strcmp(arg, "-icon") == 0)) { never executed: end of block
| 0 | ||||||||||||||||||
1224 | if (++i < argc) {
| 0 | ||||||||||||||||||
1225 | icon = QString::fromLocal8Bit(argv[i]); | - | ||||||||||||||||||
1226 | } never executed: end of block | 0 | ||||||||||||||||||
1227 | } else { never executed: end of block | 0 | ||||||||||||||||||
1228 | argv[j++] = argv[i]; | - | ||||||||||||||||||
1229 | } never executed: end of block | 0 | ||||||||||||||||||
1230 | } | - | ||||||||||||||||||
1231 | - | |||||||||||||||||||
1232 | if (j < argc) {
| 0 | ||||||||||||||||||
1233 | argv[j] = 0; | - | ||||||||||||||||||
1234 | argc = j; | - | ||||||||||||||||||
1235 | } never executed: end of block | 0 | ||||||||||||||||||
1236 | - | |||||||||||||||||||
1237 | init_platform(QLatin1String(platformName), platformPluginPath, platformThemeName, argc, argv); | - | ||||||||||||||||||
1238 | - | |||||||||||||||||||
1239 | if (!icon.isEmpty())
| 0 | ||||||||||||||||||
1240 | forcedWindowIcon = QDir::isAbsolutePath(icon) ? QIcon(icon) : QIcon::fromTheme(icon); never executed: forcedWindowIcon = QDir::isAbsolutePath(icon) ? QIcon(icon) : QIcon::fromTheme(icon);
| 0 | ||||||||||||||||||
1241 | } never executed: end of block | 0 | ||||||||||||||||||
1242 | - | |||||||||||||||||||
1243 | /*! | - | ||||||||||||||||||
1244 | Called from QCoreApplication::init() | - | ||||||||||||||||||
1245 | - | |||||||||||||||||||
1246 | Responsible for creating an event dispatcher when QCoreApplication | - | ||||||||||||||||||
1247 | decides that it needs one (because a custom one has not been set). | - | ||||||||||||||||||
1248 | */ | - | ||||||||||||||||||
1249 | void QGuiApplicationPrivate::createEventDispatcher() | - | ||||||||||||||||||
1250 | { | - | ||||||||||||||||||
1251 | Q_ASSERT(!eventDispatcher); | - | ||||||||||||||||||
1252 | - | |||||||||||||||||||
1253 | if (platform_integration == 0)
| 0 | ||||||||||||||||||
1254 | createPlatformIntegration(); never executed: createPlatformIntegration(); | 0 | ||||||||||||||||||
1255 | - | |||||||||||||||||||
1256 | // The platform integration should not mess with the event dispatcher | - | ||||||||||||||||||
1257 | Q_ASSERT(!eventDispatcher); | - | ||||||||||||||||||
1258 | - | |||||||||||||||||||
1259 | eventDispatcher = platform_integration->createEventDispatcher(); | - | ||||||||||||||||||
1260 | } never executed: end of block | 0 | ||||||||||||||||||
1261 | - | |||||||||||||||||||
1262 | void QGuiApplicationPrivate::eventDispatcherReady() | - | ||||||||||||||||||
1263 | { | - | ||||||||||||||||||
1264 | if (platform_integration == 0)
| 0 | ||||||||||||||||||
1265 | createPlatformIntegration(); never executed: createPlatformIntegration(); | 0 | ||||||||||||||||||
1266 | - | |||||||||||||||||||
1267 | platform_integration->initialize(); | - | ||||||||||||||||||
1268 | - | |||||||||||||||||||
1269 | // All platforms should have added screens at this point. Finish | - | ||||||||||||||||||
1270 | // QHighDpiScaling initialization if it has not been done so already. | - | ||||||||||||||||||
1271 | if (!QGuiApplicationPrivate::highDpiScalingUpdated)
| 0 | ||||||||||||||||||
1272 | QHighDpiScaling::updateHighDpiScaling(); never executed: QHighDpiScaling::updateHighDpiScaling(); | 0 | ||||||||||||||||||
1273 | } never executed: end of block | 0 | ||||||||||||||||||
1274 | - | |||||||||||||||||||
1275 | void QGuiApplicationPrivate::init() | - | ||||||||||||||||||
1276 | { | - | ||||||||||||||||||
1277 | QCoreApplicationPrivate::init(); | - | ||||||||||||||||||
1278 | - | |||||||||||||||||||
1279 | QCoreApplicationPrivate::is_app_running = false; // Starting up. | - | ||||||||||||||||||
1280 | - | |||||||||||||||||||
1281 | bool loadTestability = false; | - | ||||||||||||||||||
1282 | QList<QByteArray> pluginList; | - | ||||||||||||||||||
1283 | // Get command line params | - | ||||||||||||||||||
1284 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
1285 | QString session_id; | - | ||||||||||||||||||
1286 | QString session_key; | - | ||||||||||||||||||
1287 | # if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - | ||||||||||||||||||
1288 | wchar_t guidstr[40]; | - | ||||||||||||||||||
1289 | GUID guid; | - | ||||||||||||||||||
1290 | CoCreateGuid(&guid); | - | ||||||||||||||||||
1291 | StringFromGUID2(guid, guidstr, 40); | - | ||||||||||||||||||
1292 | session_id = QString::fromWCharArray(guidstr); | - | ||||||||||||||||||
1293 | CoCreateGuid(&guid); | - | ||||||||||||||||||
1294 | StringFromGUID2(guid, guidstr, 40); | - | ||||||||||||||||||
1295 | session_key = QString::fromWCharArray(guidstr); | - | ||||||||||||||||||
1296 | # endif | - | ||||||||||||||||||
1297 | #endif | - | ||||||||||||||||||
1298 | QString s; | - | ||||||||||||||||||
1299 | int j = argc ? 1 : 0;
| 0 | ||||||||||||||||||
1300 | for (int i=1; i<argc; i++) {
| 0 | ||||||||||||||||||
1301 | if (!argv[i])
| 0 | ||||||||||||||||||
1302 | continue; never executed: continue; | 0 | ||||||||||||||||||
1303 | if (*argv[i] != '-') {
| 0 | ||||||||||||||||||
1304 | argv[j++] = argv[i]; | - | ||||||||||||||||||
1305 | continue; never executed: continue; | 0 | ||||||||||||||||||
1306 | } | - | ||||||||||||||||||
1307 | const char *arg = argv[i]; | - | ||||||||||||||||||
1308 | if (arg[1] == '-') // startsWith("--")
| 0 | ||||||||||||||||||
1309 | ++arg; never executed: ++arg; | 0 | ||||||||||||||||||
1310 | if (strcmp(arg, "-plugin") == 0) {
| 0 | ||||||||||||||||||
1311 | if (++i < argc)
| 0 | ||||||||||||||||||
1312 | pluginList << argv[i]; never executed: pluginList << argv[i]; | 0 | ||||||||||||||||||
1313 | } else if (strcmp(arg, "-reverse") == 0) { never executed: end of block
| 0 | ||||||||||||||||||
1314 | force_reverse = true; | - | ||||||||||||||||||
1315 | #ifdef Q_OS_MAC | - | ||||||||||||||||||
1316 | } else if (strncmp(arg, "-psn_", 5) == 0) { | - | ||||||||||||||||||
1317 | // eat "-psn_xxxx" on Mac, which is passed when starting an app from Finder. | - | ||||||||||||||||||
1318 | // special hack to change working directory (for an app bundle) when running from finder | - | ||||||||||||||||||
1319 | if (QDir::currentPath() == QLatin1String("/")) { | - | ||||||||||||||||||
1320 | QCFType<CFURLRef> bundleURL(CFBundleCopyBundleURL(CFBundleGetMainBundle())); | - | ||||||||||||||||||
1321 | QString qbundlePath = QCFString(CFURLCopyFileSystemPath(bundleURL, | - | ||||||||||||||||||
1322 | kCFURLPOSIXPathStyle)); | - | ||||||||||||||||||
1323 | if (qbundlePath.endsWith(QLatin1String(".app"))) | - | ||||||||||||||||||
1324 | QDir::setCurrent(qbundlePath.section(QLatin1Char('/'), 0, -2)); | - | ||||||||||||||||||
1325 | } | - | ||||||||||||||||||
1326 | #endif | - | ||||||||||||||||||
1327 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
1328 | } else if (strcmp(arg, "-session") == 0 && i < argc - 1) { never executed: end of block
| 0 | ||||||||||||||||||
1329 | ++i; | - | ||||||||||||||||||
1330 | if (argv[i] && *argv[i]) {
| 0 | ||||||||||||||||||
1331 | session_id = QString::fromLatin1(argv[i]); | - | ||||||||||||||||||
1332 | int p = session_id.indexOf(QLatin1Char('_')); | - | ||||||||||||||||||
1333 | if (p >= 0) {
| 0 | ||||||||||||||||||
1334 | session_key = session_id.mid(p +1); | - | ||||||||||||||||||
1335 | session_id = session_id.left(p); | - | ||||||||||||||||||
1336 | } never executed: end of block | 0 | ||||||||||||||||||
1337 | is_session_restored = true; | - | ||||||||||||||||||
1338 | } never executed: end of block | 0 | ||||||||||||||||||
1339 | #endif | - | ||||||||||||||||||
1340 | } else if (strcmp(arg, "-testability") == 0) { never executed: end of block
| 0 | ||||||||||||||||||
1341 | loadTestability = true; | - | ||||||||||||||||||
1342 | } else if (strncmp(arg, "-style=", 7) == 0) { never executed: end of block
| 0 | ||||||||||||||||||
1343 | s = QString::fromLocal8Bit(arg + 7).toLower(); | - | ||||||||||||||||||
1344 | } else if (strcmp(arg, "-style") == 0 && i < argc - 1) { never executed: end of block
| 0 | ||||||||||||||||||
1345 | s = QString::fromLocal8Bit(argv[++i]).toLower(); | - | ||||||||||||||||||
1346 | } else { never executed: end of block | 0 | ||||||||||||||||||
1347 | argv[j++] = argv[i]; | - | ||||||||||||||||||
1348 | } never executed: end of block | 0 | ||||||||||||||||||
1349 | - | |||||||||||||||||||
1350 | if (!s.isEmpty())
| 0 | ||||||||||||||||||
1351 | styleOverride = s; never executed: styleOverride = s; | 0 | ||||||||||||||||||
1352 | } never executed: end of block | 0 | ||||||||||||||||||
1353 | - | |||||||||||||||||||
1354 | if (j < argc) {
| 0 | ||||||||||||||||||
1355 | argv[j] = 0; | - | ||||||||||||||||||
1356 | argc = j; | - | ||||||||||||||||||
1357 | } never executed: end of block | 0 | ||||||||||||||||||
1358 | - | |||||||||||||||||||
1359 | // Load environment exported generic plugins | - | ||||||||||||||||||
1360 | QByteArray envPlugins = qgetenv("QT_QPA_GENERIC_PLUGINS"); | - | ||||||||||||||||||
1361 | if (!envPlugins.isEmpty()) {
| 0 | ||||||||||||||||||
1362 | foreach (const QByteArray &plugin, envPlugins.split(',')) | - | ||||||||||||||||||
1363 | pluginList << plugin; never executed: pluginList << plugin; | 0 | ||||||||||||||||||
1364 | } never executed: end of block | 0 | ||||||||||||||||||
1365 | - | |||||||||||||||||||
1366 | if (platform_integration == 0)
| 0 | ||||||||||||||||||
1367 | createPlatformIntegration(); never executed: createPlatformIntegration(); | 0 | ||||||||||||||||||
1368 | - | |||||||||||||||||||
1369 | initPalette(); | - | ||||||||||||||||||
1370 | QFont::initialize(); | - | ||||||||||||||||||
1371 | - | |||||||||||||||||||
1372 | mouse_double_click_distance = platformTheme()->themeHint(QPlatformTheme::MouseDoubleClickDistance).toInt(); | - | ||||||||||||||||||
1373 | - | |||||||||||||||||||
1374 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
1375 | QCursorData::initialize(); | - | ||||||||||||||||||
1376 | #endif | - | ||||||||||||||||||
1377 | - | |||||||||||||||||||
1378 | // trigger registering of QVariant's GUI types | - | ||||||||||||||||||
1379 | qRegisterGuiVariant(); | - | ||||||||||||||||||
1380 | - | |||||||||||||||||||
1381 | #ifndef QT_NO_ANIMATION | - | ||||||||||||||||||
1382 | // trigger registering of animation interpolators | - | ||||||||||||||||||
1383 | qRegisterGuiGetInterpolator(); | - | ||||||||||||||||||
1384 | #endif | - | ||||||||||||||||||
1385 | - | |||||||||||||||||||
1386 | // set a global share context when enabled unless there is already one | - | ||||||||||||||||||
1387 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||
1388 | if (qApp->testAttribute(Qt::AA_ShareOpenGLContexts) && !qt_gl_global_share_context()) {
| 0 | ||||||||||||||||||
1389 | QOpenGLContext *ctx = new QOpenGLContext; | - | ||||||||||||||||||
1390 | ctx->setFormat(QSurfaceFormat::defaultFormat()); | - | ||||||||||||||||||
1391 | ctx->create(); | - | ||||||||||||||||||
1392 | qt_gl_set_global_share_context(ctx); | - | ||||||||||||||||||
1393 | ownGlobalShareContext = true; | - | ||||||||||||||||||
1394 | } never executed: end of block | 0 | ||||||||||||||||||
1395 | #endif | - | ||||||||||||||||||
1396 | - | |||||||||||||||||||
1397 | QWindowSystemInterfacePrivate::eventTime.start(); | - | ||||||||||||||||||
1398 | - | |||||||||||||||||||
1399 | is_app_running = true; | - | ||||||||||||||||||
1400 | init_plugins(pluginList); | - | ||||||||||||||||||
1401 | QWindowSystemInterface::flushWindowSystemEvents(); | - | ||||||||||||||||||
1402 | - | |||||||||||||||||||
1403 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
1404 | Q_Q(QGuiApplication); | - | ||||||||||||||||||
1405 | - | |||||||||||||||||||
1406 | // connect to the session manager | - | ||||||||||||||||||
1407 | session_manager = new QSessionManager(q, session_id, session_key); | - | ||||||||||||||||||
1408 | #endif | - | ||||||||||||||||||
1409 | - | |||||||||||||||||||
1410 | #ifndef QT_NO_LIBRARY | - | ||||||||||||||||||
1411 | if (qEnvironmentVariableIntValue("QT_LOAD_TESTABILITY") > 0)
| 0 | ||||||||||||||||||
1412 | loadTestability = true; never executed: loadTestability = true; | 0 | ||||||||||||||||||
1413 | - | |||||||||||||||||||
1414 | if (loadTestability) {
| 0 | ||||||||||||||||||
1415 | QLibrary testLib(QStringLiteral("qttestability")); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
1416 | if (testLib.load()) {
| 0 | ||||||||||||||||||
1417 | typedef void (*TasInitialize)(void); | - | ||||||||||||||||||
1418 | TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); | - | ||||||||||||||||||
1419 | if (initFunction) {
| 0 | ||||||||||||||||||
1420 | initFunction(); | - | ||||||||||||||||||
1421 | } else { never executed: end of block | 0 | ||||||||||||||||||
1422 | qCritical() << "Library qttestability resolve failed!"; | - | ||||||||||||||||||
1423 | } never executed: end of block | 0 | ||||||||||||||||||
1424 | } else { | - | ||||||||||||||||||
1425 | qCritical() << "Library qttestability load failed:" << testLib.errorString(); | - | ||||||||||||||||||
1426 | } never executed: end of block | 0 | ||||||||||||||||||
1427 | } | - | ||||||||||||||||||
1428 | #else | - | ||||||||||||||||||
1429 | Q_UNUSED(loadTestability); | - | ||||||||||||||||||
1430 | #endif // QT_NO_LIBRARY | - | ||||||||||||||||||
1431 | - | |||||||||||||||||||
1432 | if (layout_direction == Qt::LayoutDirectionAuto || force_reverse)
| 0 | ||||||||||||||||||
1433 | QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight); never executed: QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight); | 0 | ||||||||||||||||||
1434 | - | |||||||||||||||||||
1435 | scrollNoPhaseAllowed = qEnvironmentVariableIsSet("QT_ENABLE_MOUSE_WHEEL_TRACKING"); | - | ||||||||||||||||||
1436 | } never executed: end of block | 0 | ||||||||||||||||||
1437 | - | |||||||||||||||||||
1438 | extern void qt_cleanupFontDatabase(); | - | ||||||||||||||||||
1439 | - | |||||||||||||||||||
1440 | QGuiApplicationPrivate::~QGuiApplicationPrivate() | - | ||||||||||||||||||
1441 | { | - | ||||||||||||||||||
1442 | is_app_closing = true; | - | ||||||||||||||||||
1443 | is_app_running = false; | - | ||||||||||||||||||
1444 | - | |||||||||||||||||||
1445 | for (int i = 0; i < generic_plugin_list.count(); ++i)
| 0 | ||||||||||||||||||
1446 | delete generic_plugin_list.at(i); never executed: delete generic_plugin_list.at(i); | 0 | ||||||||||||||||||
1447 | generic_plugin_list.clear(); | - | ||||||||||||||||||
1448 | - | |||||||||||||||||||
1449 | clearFontUnlocked(); | - | ||||||||||||||||||
1450 | - | |||||||||||||||||||
1451 | QFont::cleanup(); | - | ||||||||||||||||||
1452 | - | |||||||||||||||||||
1453 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
1454 | QCursorData::cleanup(); | - | ||||||||||||||||||
1455 | #endif | - | ||||||||||||||||||
1456 | - | |||||||||||||||||||
1457 | layout_direction = Qt::LeftToRight; | - | ||||||||||||||||||
1458 | - | |||||||||||||||||||
1459 | cleanupThreadData(); | - | ||||||||||||||||||
1460 | - | |||||||||||||||||||
1461 | delete QGuiApplicationPrivate::styleHints; | - | ||||||||||||||||||
1462 | QGuiApplicationPrivate::styleHints = Q_NULLPTR; | - | ||||||||||||||||||
1463 | delete inputMethod; | - | ||||||||||||||||||
1464 | - | |||||||||||||||||||
1465 | qt_cleanupFontDatabase(); | - | ||||||||||||||||||
1466 | - | |||||||||||||||||||
1467 | QPixmapCache::clear(); | - | ||||||||||||||||||
1468 | - | |||||||||||||||||||
1469 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||
1470 | if (ownGlobalShareContext) {
| 0 | ||||||||||||||||||
1471 | delete qt_gl_global_share_context(); | - | ||||||||||||||||||
1472 | qt_gl_set_global_share_context(0); | - | ||||||||||||||||||
1473 | } never executed: end of block | 0 | ||||||||||||||||||
1474 | #endif | - | ||||||||||||||||||
1475 | - | |||||||||||||||||||
1476 | platform_integration->destroy(); | - | ||||||||||||||||||
1477 | - | |||||||||||||||||||
1478 | delete platform_theme; | - | ||||||||||||||||||
1479 | platform_theme = 0; | - | ||||||||||||||||||
1480 | delete platform_integration; | - | ||||||||||||||||||
1481 | platform_integration = 0; | - | ||||||||||||||||||
1482 | delete m_gammaTables.load(); | - | ||||||||||||||||||
1483 | - | |||||||||||||||||||
1484 | window_list.clear(); | - | ||||||||||||||||||
1485 | } never executed: end of block | 0 | ||||||||||||||||||
1486 | - | |||||||||||||||||||
1487 | #if 0 | - | ||||||||||||||||||
1488 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
1489 | QCursor *overrideCursor(); | - | ||||||||||||||||||
1490 | void setOverrideCursor(const QCursor &); | - | ||||||||||||||||||
1491 | void changeOverrideCursor(const QCursor &); | - | ||||||||||||||||||
1492 | void restoreOverrideCursor(); | - | ||||||||||||||||||
1493 | #endif | - | ||||||||||||||||||
1494 | - | |||||||||||||||||||
1495 | static QFont font(); | - | ||||||||||||||||||
1496 | static QFont font(const QWidget*); | - | ||||||||||||||||||
1497 | static QFont font(const char *className); | - | ||||||||||||||||||
1498 | static void setFont(const QFont &, const char* className = 0); | - | ||||||||||||||||||
1499 | static QFontMetrics fontMetrics(); | - | ||||||||||||||||||
1500 | - | |||||||||||||||||||
1501 | #ifndef QT_NO_CLIPBOARD | - | ||||||||||||||||||
1502 | static QClipboard *clipboard(); | - | ||||||||||||||||||
1503 | #endif | - | ||||||||||||||||||
1504 | #endif | - | ||||||||||||||||||
1505 | - | |||||||||||||||||||
1506 | /*! | - | ||||||||||||||||||
1507 | Returns the current state of the modifier keys on the keyboard. The current | - | ||||||||||||||||||
1508 | state is updated sychronously as the event queue is emptied of events that | - | ||||||||||||||||||
1509 | will spontaneously change the keyboard state (QEvent::KeyPress and | - | ||||||||||||||||||
1510 | QEvent::KeyRelease events). | - | ||||||||||||||||||
1511 | - | |||||||||||||||||||
1512 | It should be noted this may not reflect the actual keys held on the input | - | ||||||||||||||||||
1513 | device at the time of calling but rather the modifiers as last reported in | - | ||||||||||||||||||
1514 | one of the above events. If no keys are being held Qt::NoModifier is | - | ||||||||||||||||||
1515 | returned. | - | ||||||||||||||||||
1516 | - | |||||||||||||||||||
1517 | \sa mouseButtons(), queryKeyboardModifiers() | - | ||||||||||||||||||
1518 | */ | - | ||||||||||||||||||
1519 | Qt::KeyboardModifiers QGuiApplication::keyboardModifiers() | - | ||||||||||||||||||
1520 | { | - | ||||||||||||||||||
1521 | return QGuiApplicationPrivate::modifier_buttons; never executed: return QGuiApplicationPrivate::modifier_buttons; | 0 | ||||||||||||||||||
1522 | } | - | ||||||||||||||||||
1523 | - | |||||||||||||||||||
1524 | /*! | - | ||||||||||||||||||
1525 | \fn Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers() | - | ||||||||||||||||||
1526 | - | |||||||||||||||||||
1527 | Queries and returns the state of the modifier keys on the keyboard. | - | ||||||||||||||||||
1528 | Unlike keyboardModifiers, this method returns the actual keys held | - | ||||||||||||||||||
1529 | on the input device at the time of calling the method. | - | ||||||||||||||||||
1530 | - | |||||||||||||||||||
1531 | It does not rely on the keypress events having been received by this | - | ||||||||||||||||||
1532 | process, which makes it possible to check the modifiers while moving | - | ||||||||||||||||||
1533 | a window, for instance. Note that in most cases, you should use | - | ||||||||||||||||||
1534 | keyboardModifiers(), which is faster and more accurate since it contains | - | ||||||||||||||||||
1535 | the state of the modifiers as they were when the currently processed | - | ||||||||||||||||||
1536 | event was received. | - | ||||||||||||||||||
1537 | - | |||||||||||||||||||
1538 | \sa keyboardModifiers() | - | ||||||||||||||||||
1539 | */ | - | ||||||||||||||||||
1540 | Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers() | - | ||||||||||||||||||
1541 | { | - | ||||||||||||||||||
1542 | CHECK_QAPP_INSTANCE(Qt::KeyboardModifiers(0)) never executed: end of block never executed: return Qt::KeyboardModifiers(0);
| 0 | ||||||||||||||||||
1543 | QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); | - | ||||||||||||||||||
1544 | return pi->queryKeyboardModifiers(); never executed: return pi->queryKeyboardModifiers(); | 0 | ||||||||||||||||||
1545 | } | - | ||||||||||||||||||
1546 | - | |||||||||||||||||||
1547 | /*! | - | ||||||||||||||||||
1548 | Returns the current state of the buttons on the mouse. The current state is | - | ||||||||||||||||||
1549 | updated syncronously as the event queue is emptied of events that will | - | ||||||||||||||||||
1550 | spontaneously change the mouse state (QEvent::MouseButtonPress and | - | ||||||||||||||||||
1551 | QEvent::MouseButtonRelease events). | - | ||||||||||||||||||
1552 | - | |||||||||||||||||||
1553 | It should be noted this may not reflect the actual buttons held on the | - | ||||||||||||||||||
1554 | input device at the time of calling but rather the mouse buttons as last | - | ||||||||||||||||||
1555 | reported in one of the above events. If no mouse buttons are being held | - | ||||||||||||||||||
1556 | Qt::NoButton is returned. | - | ||||||||||||||||||
1557 | - | |||||||||||||||||||
1558 | \sa keyboardModifiers() | - | ||||||||||||||||||
1559 | */ | - | ||||||||||||||||||
1560 | Qt::MouseButtons QGuiApplication::mouseButtons() | - | ||||||||||||||||||
1561 | { | - | ||||||||||||||||||
1562 | return QGuiApplicationPrivate::mouse_buttons; never executed: return QGuiApplicationPrivate::mouse_buttons; | 0 | ||||||||||||||||||
1563 | } | - | ||||||||||||||||||
1564 | - | |||||||||||||||||||
1565 | /*! | - | ||||||||||||||||||
1566 | Returns the platform's native interface, for platform specific | - | ||||||||||||||||||
1567 | functionality. | - | ||||||||||||||||||
1568 | */ | - | ||||||||||||||||||
1569 | QPlatformNativeInterface *QGuiApplication::platformNativeInterface() | - | ||||||||||||||||||
1570 | { | - | ||||||||||||||||||
1571 | QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); | - | ||||||||||||||||||
1572 | return pi ? pi->nativeInterface() : 0; never executed: return pi ? pi->nativeInterface() : 0;
| 0 | ||||||||||||||||||
1573 | } | - | ||||||||||||||||||
1574 | - | |||||||||||||||||||
1575 | /*! | - | ||||||||||||||||||
1576 | Returns a function pointer from the platformplugin matching \a function | - | ||||||||||||||||||
1577 | */ | - | ||||||||||||||||||
1578 | QFunctionPointer QGuiApplication::platformFunction(const QByteArray &function) | - | ||||||||||||||||||
1579 | { | - | ||||||||||||||||||
1580 | QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); | - | ||||||||||||||||||
1581 | if (!pi) {
| 0 | ||||||||||||||||||
1582 | qWarning() << "QGuiApplication::platformFunction(): Must construct a QGuiApplication before accessing a platform function"; | - | ||||||||||||||||||
1583 | return Q_NULLPTR; never executed: return nullptr; | 0 | ||||||||||||||||||
1584 | } | - | ||||||||||||||||||
1585 | - | |||||||||||||||||||
1586 | return pi->nativeInterface() ? pi->nativeInterface()->platformFunction(function) : Q_NULLPTR; never executed: return pi->nativeInterface() ? pi->nativeInterface()->platformFunction(function) : nullptr;
| 0 | ||||||||||||||||||
1587 | } | - | ||||||||||||||||||
1588 | - | |||||||||||||||||||
1589 | /*! | - | ||||||||||||||||||
1590 | Enters the main event loop and waits until exit() is called, and then | - | ||||||||||||||||||
1591 | returns the value that was set to exit() (which is 0 if exit() is called | - | ||||||||||||||||||
1592 | via quit()). | - | ||||||||||||||||||
1593 | - | |||||||||||||||||||
1594 | It is necessary to call this function to start event handling. The main | - | ||||||||||||||||||
1595 | event loop receives events from the window system and dispatches these to | - | ||||||||||||||||||
1596 | the application widgets. | - | ||||||||||||||||||
1597 | - | |||||||||||||||||||
1598 | Generally, no user interaction can take place before calling exec(). | - | ||||||||||||||||||
1599 | - | |||||||||||||||||||
1600 | To make your application perform idle processing, e.g., executing a special | - | ||||||||||||||||||
1601 | function whenever there are no pending events, use a QTimer with 0 timeout. | - | ||||||||||||||||||
1602 | More advanced idle processing schemes can be achieved using processEvents(). | - | ||||||||||||||||||
1603 | - | |||||||||||||||||||
1604 | We recommend that you connect clean-up code to the | - | ||||||||||||||||||
1605 | \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your | - | ||||||||||||||||||
1606 | application's \c{main()} function. This is because, on some platforms, the | - | ||||||||||||||||||
1607 | QApplication::exec() call may not return. | - | ||||||||||||||||||
1608 | - | |||||||||||||||||||
1609 | \sa quitOnLastWindowClosed, quit(), exit(), processEvents(), | - | ||||||||||||||||||
1610 | QCoreApplication::exec() | - | ||||||||||||||||||
1611 | */ | - | ||||||||||||||||||
1612 | int QGuiApplication::exec() | - | ||||||||||||||||||
1613 | { | - | ||||||||||||||||||
1614 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
1615 | QAccessible::setRootObject(qApp); | - | ||||||||||||||||||
1616 | #endif | - | ||||||||||||||||||
1617 | return QCoreApplication::exec(); never executed: return QCoreApplication::exec(); | 0 | ||||||||||||||||||
1618 | } | - | ||||||||||||||||||
1619 | - | |||||||||||||||||||
1620 | /*! \reimp | - | ||||||||||||||||||
1621 | */ | - | ||||||||||||||||||
1622 | bool QGuiApplication::notify(QObject *object, QEvent *event) | - | ||||||||||||||||||
1623 | { | - | ||||||||||||||||||
1624 | if (object->isWindowType())
| 0 | ||||||||||||||||||
1625 | QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(object), event); never executed: QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(object), event); | 0 | ||||||||||||||||||
1626 | return QCoreApplication::notify(object, event); never executed: return QCoreApplication::notify(object, event); | 0 | ||||||||||||||||||
1627 | } | - | ||||||||||||||||||
1628 | - | |||||||||||||||||||
1629 | /*! \reimp | - | ||||||||||||||||||
1630 | */ | - | ||||||||||||||||||
1631 | bool QGuiApplication::event(QEvent *e) | - | ||||||||||||||||||
1632 | { | - | ||||||||||||||||||
1633 | if(e->type() == QEvent::LanguageChange) {
| 0 | ||||||||||||||||||
1634 | setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight); | - | ||||||||||||||||||
1635 | } never executed: end of block | 0 | ||||||||||||||||||
1636 | return QCoreApplication::event(e); never executed: return QCoreApplication::event(e); | 0 | ||||||||||||||||||
1637 | } | - | ||||||||||||||||||
1638 | - | |||||||||||||||||||
1639 | /*! | - | ||||||||||||||||||
1640 | \internal | - | ||||||||||||||||||
1641 | */ | - | ||||||||||||||||||
1642 | bool QGuiApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) | - | ||||||||||||||||||
1643 | { | - | ||||||||||||||||||
1644 | return QCoreApplication::compressEvent(event, receiver, postedEvents); never executed: return QCoreApplication::compressEvent(event, receiver, postedEvents); | 0 | ||||||||||||||||||
1645 | } | - | ||||||||||||||||||
1646 | - | |||||||||||||||||||
1647 | void QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event) | - | ||||||||||||||||||
1648 | { | - | ||||||||||||||||||
1649 | if (!window)
| 0 | ||||||||||||||||||
1650 | return; never executed: return; | 0 | ||||||||||||||||||
1651 | QPlatformWindow *platformWindow = window->handle(); | - | ||||||||||||||||||
1652 | if (!platformWindow)
| 0 | ||||||||||||||||||
1653 | return; never executed: return; | 0 | ||||||||||||||||||
1654 | // spontaneous events come from the platform integration already, we don't need to send the events back | - | ||||||||||||||||||
1655 | if (event->spontaneous())
| 0 | ||||||||||||||||||
1656 | return; never executed: return; | 0 | ||||||||||||||||||
1657 | // let the platform window do any handling it needs to as well | - | ||||||||||||||||||
1658 | platformWindow->windowEvent(event); | - | ||||||||||||||||||
1659 | } never executed: end of block | 0 | ||||||||||||||||||
1660 | - | |||||||||||||||||||
1661 | bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result) | - | ||||||||||||||||||
1662 | { | - | ||||||||||||||||||
1663 | return window->nativeEvent(eventType, message, result); never executed: return window->nativeEvent(eventType, message, result); | 0 | ||||||||||||||||||
1664 | } | - | ||||||||||||||||||
1665 | - | |||||||||||||||||||
1666 | void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e) | - | ||||||||||||||||||
1667 | { | - | ||||||||||||||||||
1668 | switch(e->type) { | - | ||||||||||||||||||
1669 | case QWindowSystemInterfacePrivate::FrameStrutMouse: never executed: case QWindowSystemInterfacePrivate::FrameStrutMouse: | 0 | ||||||||||||||||||
1670 | case QWindowSystemInterfacePrivate::Mouse: never executed: case QWindowSystemInterfacePrivate::Mouse: | 0 | ||||||||||||||||||
1671 | QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e)); | - | ||||||||||||||||||
1672 | break; never executed: break; | 0 | ||||||||||||||||||
1673 | case QWindowSystemInterfacePrivate::Wheel: never executed: case QWindowSystemInterfacePrivate::Wheel: | 0 | ||||||||||||||||||
1674 | QGuiApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterfacePrivate::WheelEvent *>(e)); | - | ||||||||||||||||||
1675 | break; never executed: break; | 0 | ||||||||||||||||||
1676 | case QWindowSystemInterfacePrivate::Key: never executed: case QWindowSystemInterfacePrivate::Key: | 0 | ||||||||||||||||||
1677 | QGuiApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e)); | - | ||||||||||||||||||
1678 | break; never executed: break; | 0 | ||||||||||||||||||
1679 | case QWindowSystemInterfacePrivate::Touch: never executed: case QWindowSystemInterfacePrivate::Touch: | 0 | ||||||||||||||||||
1680 | QGuiApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e)); | - | ||||||||||||||||||
1681 | break; never executed: break; | 0 | ||||||||||||||||||
1682 | case QWindowSystemInterfacePrivate::GeometryChange: never executed: case QWindowSystemInterfacePrivate::GeometryChange: | 0 | ||||||||||||||||||
1683 | QGuiApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e)); | - | ||||||||||||||||||
1684 | break; never executed: break; | 0 | ||||||||||||||||||
1685 | case QWindowSystemInterfacePrivate::Enter: never executed: case QWindowSystemInterfacePrivate::Enter: | 0 | ||||||||||||||||||
1686 | QGuiApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e)); | - | ||||||||||||||||||
1687 | break; never executed: break; | 0 | ||||||||||||||||||
1688 | case QWindowSystemInterfacePrivate::Leave: never executed: case QWindowSystemInterfacePrivate::Leave: | 0 | ||||||||||||||||||
1689 | QGuiApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e)); | - | ||||||||||||||||||
1690 | break; never executed: break; | 0 | ||||||||||||||||||
1691 | case QWindowSystemInterfacePrivate::ActivatedWindow: never executed: case QWindowSystemInterfacePrivate::ActivatedWindow: | 0 | ||||||||||||||||||
1692 | QGuiApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e)); | - | ||||||||||||||||||
1693 | break; never executed: break; | 0 | ||||||||||||||||||
1694 | case QWindowSystemInterfacePrivate::WindowStateChanged: never executed: case QWindowSystemInterfacePrivate::WindowStateChanged: | 0 | ||||||||||||||||||
1695 | QGuiApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e)); | - | ||||||||||||||||||
1696 | break; never executed: break; | 0 | ||||||||||||||||||
1697 | case QWindowSystemInterfacePrivate::WindowScreenChanged: never executed: case QWindowSystemInterfacePrivate::WindowScreenChanged: | 0 | ||||||||||||||||||
1698 | QGuiApplicationPrivate::processWindowScreenChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowScreenChangedEvent *>(e)); | - | ||||||||||||||||||
1699 | break; never executed: break; | 0 | ||||||||||||||||||
1700 | case QWindowSystemInterfacePrivate::ApplicationStateChanged: { never executed: case QWindowSystemInterfacePrivate::ApplicationStateChanged: | 0 | ||||||||||||||||||
1701 | QWindowSystemInterfacePrivate::ApplicationStateChangedEvent * changeEvent = static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e); | - | ||||||||||||||||||
1702 | QGuiApplicationPrivate::setApplicationState(changeEvent->newState, changeEvent->forcePropagate); } | - | ||||||||||||||||||
1703 | break; never executed: break; | 0 | ||||||||||||||||||
1704 | case QWindowSystemInterfacePrivate::FlushEvents: { never executed: case QWindowSystemInterfacePrivate::FlushEvents: | 0 | ||||||||||||||||||
1705 | QWindowSystemInterfacePrivate::FlushEventsEvent *flushEventsEvent = static_cast<QWindowSystemInterfacePrivate::FlushEventsEvent *>(e); | - | ||||||||||||||||||
1706 | QWindowSystemInterface::deferredFlushWindowSystemEvents(flushEventsEvent->flags); } | - | ||||||||||||||||||
1707 | break; never executed: break; | 0 | ||||||||||||||||||
1708 | case QWindowSystemInterfacePrivate::Close: never executed: case QWindowSystemInterfacePrivate::Close: | 0 | ||||||||||||||||||
1709 | QGuiApplicationPrivate::processCloseEvent( | - | ||||||||||||||||||
1710 | static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e)); | - | ||||||||||||||||||
1711 | break; never executed: break; | 0 | ||||||||||||||||||
1712 | case QWindowSystemInterfacePrivate::ScreenOrientation: never executed: case QWindowSystemInterfacePrivate::ScreenOrientation: | 0 | ||||||||||||||||||
1713 | QGuiApplicationPrivate::reportScreenOrientationChange( | - | ||||||||||||||||||
1714 | static_cast<QWindowSystemInterfacePrivate::ScreenOrientationEvent *>(e)); | - | ||||||||||||||||||
1715 | break; never executed: break; | 0 | ||||||||||||||||||
1716 | case QWindowSystemInterfacePrivate::ScreenGeometry: never executed: case QWindowSystemInterfacePrivate::ScreenGeometry: | 0 | ||||||||||||||||||
1717 | QGuiApplicationPrivate::reportGeometryChange( | - | ||||||||||||||||||
1718 | static_cast<QWindowSystemInterfacePrivate::ScreenGeometryEvent *>(e)); | - | ||||||||||||||||||
1719 | break; never executed: break; | 0 | ||||||||||||||||||
1720 | case QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInch: never executed: case QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInch: | 0 | ||||||||||||||||||
1721 | QGuiApplicationPrivate::reportLogicalDotsPerInchChange( | - | ||||||||||||||||||
1722 | static_cast<QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *>(e)); | - | ||||||||||||||||||
1723 | break; never executed: break; | 0 | ||||||||||||||||||
1724 | case QWindowSystemInterfacePrivate::ScreenRefreshRate: never executed: case QWindowSystemInterfacePrivate::ScreenRefreshRate: | 0 | ||||||||||||||||||
1725 | QGuiApplicationPrivate::reportRefreshRateChange( | - | ||||||||||||||||||
1726 | static_cast<QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *>(e)); | - | ||||||||||||||||||
1727 | break; never executed: break; | 0 | ||||||||||||||||||
1728 | case QWindowSystemInterfacePrivate::ThemeChange: never executed: case QWindowSystemInterfacePrivate::ThemeChange: | 0 | ||||||||||||||||||
1729 | QGuiApplicationPrivate::processThemeChanged( | - | ||||||||||||||||||
1730 | static_cast<QWindowSystemInterfacePrivate::ThemeChangeEvent *>(e)); | - | ||||||||||||||||||
1731 | break; never executed: break; | 0 | ||||||||||||||||||
1732 | case QWindowSystemInterfacePrivate::Expose: never executed: case QWindowSystemInterfacePrivate::Expose: | 0 | ||||||||||||||||||
1733 | QGuiApplicationPrivate::processExposeEvent(static_cast<QWindowSystemInterfacePrivate::ExposeEvent *>(e)); | - | ||||||||||||||||||
1734 | break; never executed: break; | 0 | ||||||||||||||||||
1735 | case QWindowSystemInterfacePrivate::Tablet: never executed: case QWindowSystemInterfacePrivate::Tablet: | 0 | ||||||||||||||||||
1736 | QGuiApplicationPrivate::processTabletEvent( | - | ||||||||||||||||||
1737 | static_cast<QWindowSystemInterfacePrivate::TabletEvent *>(e)); | - | ||||||||||||||||||
1738 | break; never executed: break; | 0 | ||||||||||||||||||
1739 | case QWindowSystemInterfacePrivate::TabletEnterProximity: never executed: case QWindowSystemInterfacePrivate::TabletEnterProximity: | 0 | ||||||||||||||||||
1740 | QGuiApplicationPrivate::processTabletEnterProximityEvent( | - | ||||||||||||||||||
1741 | static_cast<QWindowSystemInterfacePrivate::TabletEnterProximityEvent *>(e)); | - | ||||||||||||||||||
1742 | break; never executed: break; | 0 | ||||||||||||||||||
1743 | case QWindowSystemInterfacePrivate::TabletLeaveProximity: never executed: case QWindowSystemInterfacePrivate::TabletLeaveProximity: | 0 | ||||||||||||||||||
1744 | QGuiApplicationPrivate::processTabletLeaveProximityEvent( | - | ||||||||||||||||||
1745 | static_cast<QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *>(e)); | - | ||||||||||||||||||
1746 | break; never executed: break; | 0 | ||||||||||||||||||
1747 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||
1748 | case QWindowSystemInterfacePrivate::Gesture: never executed: case QWindowSystemInterfacePrivate::Gesture: | 0 | ||||||||||||||||||
1749 | QGuiApplicationPrivate::processGestureEvent( | - | ||||||||||||||||||
1750 | static_cast<QWindowSystemInterfacePrivate::GestureEvent *>(e)); | - | ||||||||||||||||||
1751 | break; never executed: break; | 0 | ||||||||||||||||||
1752 | #endif | - | ||||||||||||||||||
1753 | case QWindowSystemInterfacePrivate::PlatformPanel: never executed: case QWindowSystemInterfacePrivate::PlatformPanel: | 0 | ||||||||||||||||||
1754 | QGuiApplicationPrivate::processPlatformPanelEvent( | - | ||||||||||||||||||
1755 | static_cast<QWindowSystemInterfacePrivate::PlatformPanelEvent *>(e)); | - | ||||||||||||||||||
1756 | break; never executed: break; | 0 | ||||||||||||||||||
1757 | case QWindowSystemInterfacePrivate::FileOpen: never executed: case QWindowSystemInterfacePrivate::FileOpen: | 0 | ||||||||||||||||||
1758 | QGuiApplicationPrivate::processFileOpenEvent( | - | ||||||||||||||||||
1759 | static_cast<QWindowSystemInterfacePrivate::FileOpenEvent *>(e)); | - | ||||||||||||||||||
1760 | break; never executed: break; | 0 | ||||||||||||||||||
1761 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||||||||
1762 | case QWindowSystemInterfacePrivate::ContextMenu: never executed: case QWindowSystemInterfacePrivate::ContextMenu: | 0 | ||||||||||||||||||
1763 | QGuiApplicationPrivate::processContextMenuEvent( | - | ||||||||||||||||||
1764 | static_cast<QWindowSystemInterfacePrivate::ContextMenuEvent *>(e)); | - | ||||||||||||||||||
1765 | break; never executed: break; | 0 | ||||||||||||||||||
1766 | #endif | - | ||||||||||||||||||
1767 | case QWindowSystemInterfacePrivate::EnterWhatsThisMode: never executed: case QWindowSystemInterfacePrivate::EnterWhatsThisMode: | 0 | ||||||||||||||||||
1768 | QGuiApplication::postEvent(QGuiApplication::instance(), new QEvent(QEvent::EnterWhatsThisMode)); | - | ||||||||||||||||||
1769 | break; never executed: break; | 0 | ||||||||||||||||||
1770 | default: never executed: default: | 0 | ||||||||||||||||||
1771 | qWarning() << "Unknown user input event type:" << e->type; | - | ||||||||||||||||||
1772 | break; never executed: break; | 0 | ||||||||||||||||||
1773 | } | - | ||||||||||||||||||
1774 | } | - | ||||||||||||||||||
1775 | - | |||||||||||||||||||
1776 | void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e) | - | ||||||||||||||||||
1777 | { | - | ||||||||||||||||||
1778 | QEvent::Type type; | - | ||||||||||||||||||
1779 | Qt::MouseButtons stateChange = e->buttons ^ buttons; | - | ||||||||||||||||||
1780 | if (e->globalPos != QGuiApplicationPrivate::lastCursorPosition && (stateChange != Qt::NoButton)) {
| 0 | ||||||||||||||||||
1781 | // A mouse event should not change both position and buttons at the same time. Instead we | - | ||||||||||||||||||
1782 | // should first send a move event followed by a button changed event. Since this is not the case | - | ||||||||||||||||||
1783 | // with the current event, we split it in two. | - | ||||||||||||||||||
1784 | QWindowSystemInterfacePrivate::MouseEvent mouseButtonEvent( | - | ||||||||||||||||||
1785 | e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers, e->source); | - | ||||||||||||||||||
1786 | if (e->flags & QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic)
| 0 | ||||||||||||||||||
1787 | mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; never executed: mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; | 0 | ||||||||||||||||||
1788 | e->buttons = buttons; | - | ||||||||||||||||||
1789 | processMouseEvent(e); | - | ||||||||||||||||||
1790 | processMouseEvent(&mouseButtonEvent); | - | ||||||||||||||||||
1791 | return; never executed: return; | 0 | ||||||||||||||||||
1792 | } | - | ||||||||||||||||||
1793 | - | |||||||||||||||||||
1794 | QWindow *window = e->window.data(); | - | ||||||||||||||||||
1795 | modifier_buttons = e->modifiers; | - | ||||||||||||||||||
1796 | - | |||||||||||||||||||
1797 | QPointF localPoint = e->localPos; | - | ||||||||||||||||||
1798 | QPointF globalPoint = e->globalPos; | - | ||||||||||||||||||
1799 | - | |||||||||||||||||||
1800 | if (e->nullWindow()) {
| 0 | ||||||||||||||||||
1801 | window = QGuiApplication::topLevelAt(globalPoint.toPoint()); | - | ||||||||||||||||||
1802 | if (window) {
| 0 | ||||||||||||||||||
1803 | // Moves and the release following a press must go to the same | - | ||||||||||||||||||
1804 | // window, even if the cursor has moved on over another window. | - | ||||||||||||||||||
1805 | if (e->buttons != Qt::NoButton) {
| 0 | ||||||||||||||||||
1806 | if (!currentMousePressWindow)
| 0 | ||||||||||||||||||
1807 | currentMousePressWindow = window; never executed: currentMousePressWindow = window; | 0 | ||||||||||||||||||
1808 | else | - | ||||||||||||||||||
1809 | window = currentMousePressWindow; never executed: window = currentMousePressWindow; | 0 | ||||||||||||||||||
1810 | } else if (currentMousePressWindow) {
| 0 | ||||||||||||||||||
1811 | window = currentMousePressWindow; | - | ||||||||||||||||||
1812 | currentMousePressWindow = 0; | - | ||||||||||||||||||
1813 | } never executed: end of block | 0 | ||||||||||||||||||
1814 | QPointF delta = globalPoint - globalPoint.toPoint(); | - | ||||||||||||||||||
1815 | localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; | - | ||||||||||||||||||
1816 | } never executed: end of block | 0 | ||||||||||||||||||
1817 | } never executed: end of block | 0 | ||||||||||||||||||
1818 | - | |||||||||||||||||||
1819 | Qt::MouseButton button = Qt::NoButton; | - | ||||||||||||||||||
1820 | bool doubleClick = false; | - | ||||||||||||||||||
1821 | const bool frameStrut = e->type == QWindowSystemInterfacePrivate::FrameStrutMouse; | - | ||||||||||||||||||
1822 | - | |||||||||||||||||||
1823 | if (QGuiApplicationPrivate::lastCursorPosition != globalPoint) {
| 0 | ||||||||||||||||||
1824 | type = frameStrut ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove;
| 0 | ||||||||||||||||||
1825 | QGuiApplicationPrivate::lastCursorPosition = globalPoint; | - | ||||||||||||||||||
1826 | if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance||
| 0 | ||||||||||||||||||
1827 | qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance)
| 0 | ||||||||||||||||||
1828 | mousePressButton = Qt::NoButton; never executed: mousePressButton = Qt::NoButton; | 0 | ||||||||||||||||||
1829 | } else { // Check to see if a new button has been pressed/released. never executed: end of block | 0 | ||||||||||||||||||
1830 | for (int check = Qt::LeftButton; | - | ||||||||||||||||||
1831 | check <= int(Qt::MaxMouseButton);
| 0 | ||||||||||||||||||
1832 | check = check << 1) { | - | ||||||||||||||||||
1833 | if (check & stateChange) {
| 0 | ||||||||||||||||||
1834 | button = Qt::MouseButton(check); | - | ||||||||||||||||||
1835 | break; never executed: break; | 0 | ||||||||||||||||||
1836 | } | - | ||||||||||||||||||
1837 | } never executed: end of block | 0 | ||||||||||||||||||
1838 | if (button == Qt::NoButton) {
| 0 | ||||||||||||||||||
1839 | // Ignore mouse events that don't change the current state. | - | ||||||||||||||||||
1840 | return; never executed: return; | 0 | ||||||||||||||||||
1841 | } | - | ||||||||||||||||||
1842 | mouse_buttons = buttons = e->buttons; | - | ||||||||||||||||||
1843 | if (button & e->buttons) {
| 0 | ||||||||||||||||||
1844 | ulong doubleClickInterval = static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval()); | - | ||||||||||||||||||
1845 | doubleClick = e->timestamp - mousePressTime < doubleClickInterval && button == mousePressButton;
| 0 | ||||||||||||||||||
1846 | type = frameStrut ? QEvent::NonClientAreaMouseButtonPress : QEvent::MouseButtonPress;
| 0 | ||||||||||||||||||
1847 | mousePressTime = e->timestamp; | - | ||||||||||||||||||
1848 | mousePressButton = button; | - | ||||||||||||||||||
1849 | const QPoint point = QGuiApplicationPrivate::lastCursorPosition.toPoint(); | - | ||||||||||||||||||
1850 | mousePressX = point.x(); | - | ||||||||||||||||||
1851 | mousePressY = point.y(); | - | ||||||||||||||||||
1852 | } else { never executed: end of block | 0 | ||||||||||||||||||
1853 | type = frameStrut ? QEvent::NonClientAreaMouseButtonRelease : QEvent::MouseButtonRelease;
| 0 | ||||||||||||||||||
1854 | } never executed: end of block | 0 | ||||||||||||||||||
1855 | } | - | ||||||||||||||||||
1856 | - | |||||||||||||||||||
1857 | if (!window)
| 0 | ||||||||||||||||||
1858 | return; never executed: return; | 0 | ||||||||||||||||||
1859 | - | |||||||||||||||||||
1860 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
1861 | if (!e->synthetic()) {
| 0 | ||||||||||||||||||
1862 | if (const QScreen *screen = window->screen())
| 0 | ||||||||||||||||||
1863 | if (QPlatformCursor *cursor = screen->handle()->cursor()) {
| 0 | ||||||||||||||||||
1864 | const QPointF nativeLocalPoint = QHighDpi::toNativePixels(localPoint, screen); | - | ||||||||||||||||||
1865 | const QPointF nativeGlobalPoint = QHighDpi::toNativePixels(globalPoint, screen); | - | ||||||||||||||||||
1866 | QMouseEvent ev(type, nativeLocalPoint, nativeLocalPoint, nativeGlobalPoint, | - | ||||||||||||||||||
1867 | button, buttons, e->modifiers, e->source); | - | ||||||||||||||||||
1868 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
1869 | cursor->pointerEvent(ev); | - | ||||||||||||||||||
1870 | } never executed: end of block | 0 | ||||||||||||||||||
1871 | } never executed: end of block | 0 | ||||||||||||||||||
1872 | #endif | - | ||||||||||||||||||
1873 | - | |||||||||||||||||||
1874 | QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, buttons, e->modifiers, e->source); | - | ||||||||||||||||||
1875 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
1876 | - | |||||||||||||||||||
1877 | if (window->d_func()->blockedByModalWindow && !qApp->d_func()->popupActive()) {
| 0 | ||||||||||||||||||
1878 | // a modal window is blocking this window, don't allow mouse events through | - | ||||||||||||||||||
1879 | return; never executed: return; | 0 | ||||||||||||||||||
1880 | } | - | ||||||||||||||||||
1881 | - | |||||||||||||||||||
1882 | if (doubleClick && (ev.type() == QEvent::MouseButtonPress)) {
| 0 | ||||||||||||||||||
1883 | // QtBUG-25831, used to suppress delivery in qwidgetwindow.cpp | - | ||||||||||||||||||
1884 | setMouseEventFlags(&ev, ev.flags() | Qt::MouseEventCreatedDoubleClick); | - | ||||||||||||||||||
1885 | } never executed: end of block | 0 | ||||||||||||||||||
1886 | - | |||||||||||||||||||
1887 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - | ||||||||||||||||||
1888 | e->eventAccepted = ev.isAccepted(); | - | ||||||||||||||||||
1889 | if (!e->synthetic() && !ev.isAccepted()
| 0 | ||||||||||||||||||
1890 | && !frameStrut
| 0 | ||||||||||||||||||
1891 | && qApp->testAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents)) {
| 0 | ||||||||||||||||||
1892 | if (!m_fakeTouchDevice) {
| 0 | ||||||||||||||||||
1893 | m_fakeTouchDevice = new QTouchDevice; | - | ||||||||||||||||||
1894 | QWindowSystemInterface::registerTouchDevice(m_fakeTouchDevice); | - | ||||||||||||||||||
1895 | } never executed: end of block | 0 | ||||||||||||||||||
1896 | QList<QWindowSystemInterface::TouchPoint> points; | - | ||||||||||||||||||
1897 | QWindowSystemInterface::TouchPoint point; | - | ||||||||||||||||||
1898 | point.id = 1; | - | ||||||||||||||||||
1899 | point.area = QRectF(globalPoint.x() - 2, globalPoint.y() - 2, 4, 4); | - | ||||||||||||||||||
1900 | - | |||||||||||||||||||
1901 | // only translate left button related events to | - | ||||||||||||||||||
1902 | // avoid strange touch event sequences when several | - | ||||||||||||||||||
1903 | // buttons are pressed | - | ||||||||||||||||||
1904 | if (type == QEvent::MouseButtonPress && button == Qt::LeftButton) {
| 0 | ||||||||||||||||||
1905 | point.state = Qt::TouchPointPressed; | - | ||||||||||||||||||
1906 | } else if (type == QEvent::MouseButtonRelease && button == Qt::LeftButton) { never executed: end of block
| 0 | ||||||||||||||||||
1907 | point.state = Qt::TouchPointReleased; | - | ||||||||||||||||||
1908 | } else if (type == QEvent::MouseMove && (buttons & Qt::LeftButton)) { never executed: end of block
| 0 | ||||||||||||||||||
1909 | point.state = Qt::TouchPointMoved; | - | ||||||||||||||||||
1910 | } else { never executed: end of block | 0 | ||||||||||||||||||
1911 | return; never executed: return; | 0 | ||||||||||||||||||
1912 | } | - | ||||||||||||||||||
1913 | - | |||||||||||||||||||
1914 | points << point; | - | ||||||||||||||||||
1915 | - | |||||||||||||||||||
1916 | QEvent::Type type; | - | ||||||||||||||||||
1917 | QList<QTouchEvent::TouchPoint> touchPoints = QWindowSystemInterfacePrivate::fromNativeTouchPoints(points, window, &type); | - | ||||||||||||||||||
1918 | - | |||||||||||||||||||
1919 | QWindowSystemInterfacePrivate::TouchEvent fake(window, e->timestamp, type, m_fakeTouchDevice, touchPoints, e->modifiers); | - | ||||||||||||||||||
1920 | fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; | - | ||||||||||||||||||
1921 | processTouchEvent(&fake); | - | ||||||||||||||||||
1922 | } never executed: end of block | 0 | ||||||||||||||||||
1923 | if (doubleClick) {
| 0 | ||||||||||||||||||
1924 | mousePressButton = Qt::NoButton; | - | ||||||||||||||||||
1925 | if (!e->window.isNull() || e->nullWindow()) { // QTBUG-36364, check if window closed in response to press
| 0 | ||||||||||||||||||
1926 | const QEvent::Type doubleClickType = frameStrut ? QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick;
| 0 | ||||||||||||||||||
1927 | QMouseEvent dblClickEvent(doubleClickType, localPoint, localPoint, globalPoint, | - | ||||||||||||||||||
1928 | button, buttons, e->modifiers, e->source); | - | ||||||||||||||||||
1929 | dblClickEvent.setTimestamp(e->timestamp); | - | ||||||||||||||||||
1930 | QGuiApplication::sendSpontaneousEvent(window, &dblClickEvent); | - | ||||||||||||||||||
1931 | } never executed: end of block | 0 | ||||||||||||||||||
1932 | } never executed: end of block | 0 | ||||||||||||||||||
1933 | } never executed: end of block | 0 | ||||||||||||||||||
1934 | - | |||||||||||||||||||
1935 | void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e) | - | ||||||||||||||||||
1936 | { | - | ||||||||||||||||||
1937 | #ifndef QT_NO_WHEELEVENT | - | ||||||||||||||||||
1938 | QWindow *window = e->window.data(); | - | ||||||||||||||||||
1939 | QPointF globalPoint = e->globalPos; | - | ||||||||||||||||||
1940 | QPointF localPoint = e->localPos; | - | ||||||||||||||||||
1941 | - | |||||||||||||||||||
1942 | if (e->nullWindow()) {
| 0 | ||||||||||||||||||
1943 | window = QGuiApplication::topLevelAt(globalPoint.toPoint()); | - | ||||||||||||||||||
1944 | if (window) {
| 0 | ||||||||||||||||||
1945 | QPointF delta = globalPoint - globalPoint.toPoint(); | - | ||||||||||||||||||
1946 | localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; | - | ||||||||||||||||||
1947 | } never executed: end of block | 0 | ||||||||||||||||||
1948 | } never executed: end of block | 0 | ||||||||||||||||||
1949 | - | |||||||||||||||||||
1950 | if (!window)
| 0 | ||||||||||||||||||
1951 | return; never executed: return; | 0 | ||||||||||||||||||
1952 | - | |||||||||||||||||||
1953 | QGuiApplicationPrivate::lastCursorPosition = globalPoint; | - | ||||||||||||||||||
1954 | modifier_buttons = e->modifiers; | - | ||||||||||||||||||
1955 | - | |||||||||||||||||||
1956 | if (window->d_func()->blockedByModalWindow) {
| 0 | ||||||||||||||||||
1957 | // a modal window is blocking this window, don't allow wheel events through | - | ||||||||||||||||||
1958 | return; never executed: return; | 0 | ||||||||||||||||||
1959 | } | - | ||||||||||||||||||
1960 | - | |||||||||||||||||||
1961 | QWheelEvent ev(localPoint, globalPoint, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation, buttons, e->modifiers, e->phase, e->source); | - | ||||||||||||||||||
1962 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
1963 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - | ||||||||||||||||||
1964 | #endif /* ifndef QT_NO_WHEELEVENT */ | - | ||||||||||||||||||
1965 | } never executed: end of block | 0 | ||||||||||||||||||
1966 | - | |||||||||||||||||||
1967 | // Remember, Qt convention is: keyboard state is state *before* | - | ||||||||||||||||||
1968 | - | |||||||||||||||||||
1969 | void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e) | - | ||||||||||||||||||
1970 | { | - | ||||||||||||||||||
1971 | QWindow *window = e->window.data(); | - | ||||||||||||||||||
1972 | modifier_buttons = e->modifiers; | - | ||||||||||||||||||
1973 | if (e->nullWindow()
| 0 | ||||||||||||||||||
1974 | #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) | - | ||||||||||||||||||
1975 | || e->key == Qt::Key_Back || e->key == Qt::Key_Menu | - | ||||||||||||||||||
1976 | #endif | - | ||||||||||||||||||
1977 | ) { | - | ||||||||||||||||||
1978 | window = QGuiApplication::focusWindow(); | - | ||||||||||||||||||
1979 | } never executed: end of block | 0 | ||||||||||||||||||
1980 | - | |||||||||||||||||||
1981 | #if !defined(Q_OS_OSX) | - | ||||||||||||||||||
1982 | // FIXME: Include OS X in this code path by passing the key event through | - | ||||||||||||||||||
1983 | // QPlatformInputContext::filterEvent(). | - | ||||||||||||||||||
1984 | if (e->keyType == QEvent::KeyPress && window) {
| 0 | ||||||||||||||||||
1985 | if (QWindowSystemInterface::handleShortcutEvent(window, e->timestamp, e->key, e->modifiers,
| 0 | ||||||||||||||||||
1986 | e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, e->unicode, e->repeat, e->repeatCount))
| 0 | ||||||||||||||||||
1987 | return; never executed: return; | 0 | ||||||||||||||||||
1988 | } never executed: end of block | 0 | ||||||||||||||||||
1989 | #endif | - | ||||||||||||||||||
1990 | - | |||||||||||||||||||
1991 | QKeyEvent ev(e->keyType, e->key, e->modifiers, | - | ||||||||||||||||||
1992 | e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, | - | ||||||||||||||||||
1993 | e->unicode, e->repeat, e->repeatCount); | - | ||||||||||||||||||
1994 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
1995 | - | |||||||||||||||||||
1996 | // only deliver key events when we have a window, and no modal window is blocking this window | - | ||||||||||||||||||
1997 | - | |||||||||||||||||||
1998 | if (window && !window->d_func()->blockedByModalWindow)
| 0 | ||||||||||||||||||
1999 | QGuiApplication::sendSpontaneousEvent(window, &ev); never executed: QGuiApplication::sendSpontaneousEvent(window, &ev); | 0 | ||||||||||||||||||
2000 | #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) | - | ||||||||||||||||||
2001 | else | - | ||||||||||||||||||
2002 | ev.setAccepted(false); | - | ||||||||||||||||||
2003 | - | |||||||||||||||||||
2004 | static bool backKeyPressAccepted = false; | - | ||||||||||||||||||
2005 | static bool menuKeyPressAccepted = false; | - | ||||||||||||||||||
2006 | if (e->keyType == QEvent::KeyPress) { | - | ||||||||||||||||||
2007 | backKeyPressAccepted = e->key == Qt::Key_Back && ev.isAccepted(); | - | ||||||||||||||||||
2008 | menuKeyPressAccepted = e->key == Qt::Key_Menu && ev.isAccepted(); | - | ||||||||||||||||||
2009 | } else if (e->keyType == QEvent::KeyRelease) { | - | ||||||||||||||||||
2010 | if (e->key == Qt::Key_Back && !backKeyPressAccepted && !ev.isAccepted()) { | - | ||||||||||||||||||
2011 | if (window) | - | ||||||||||||||||||
2012 | QWindowSystemInterface::handleCloseEvent(window); | - | ||||||||||||||||||
2013 | } else if (e->key == Qt::Key_Menu && !menuKeyPressAccepted && !ev.isAccepted()) { | - | ||||||||||||||||||
2014 | platform_theme->showPlatformMenuBar(); | - | ||||||||||||||||||
2015 | } | - | ||||||||||||||||||
2016 | } | - | ||||||||||||||||||
2017 | #endif | - | ||||||||||||||||||
2018 | e->eventAccepted = ev.isAccepted(); | - | ||||||||||||||||||
2019 | } never executed: end of block | 0 | ||||||||||||||||||
2020 | - | |||||||||||||||||||
2021 | void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e) | - | ||||||||||||||||||
2022 | { | - | ||||||||||||||||||
2023 | if (!e->enter)
| 0 | ||||||||||||||||||
2024 | return; never executed: return; | 0 | ||||||||||||||||||
2025 | if (e->enter.data()->d_func()->blockedByModalWindow) {
| 0 | ||||||||||||||||||
2026 | // a modal window is blocking this window, don't allow enter events through | - | ||||||||||||||||||
2027 | return; never executed: return; | 0 | ||||||||||||||||||
2028 | } | - | ||||||||||||||||||
2029 | - | |||||||||||||||||||
2030 | currentMouseWindow = e->enter; | - | ||||||||||||||||||
2031 | - | |||||||||||||||||||
2032 | QEnterEvent event(e->localPos, e->localPos, e->globalPos); | - | ||||||||||||||||||
2033 | QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event); | - | ||||||||||||||||||
2034 | } never executed: end of block | 0 | ||||||||||||||||||
2035 | - | |||||||||||||||||||
2036 | void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e) | - | ||||||||||||||||||
2037 | { | - | ||||||||||||||||||
2038 | if (!e->leave)
| 0 | ||||||||||||||||||
2039 | return; never executed: return; | 0 | ||||||||||||||||||
2040 | if (e->leave.data()->d_func()->blockedByModalWindow) {
| 0 | ||||||||||||||||||
2041 | // a modal window is blocking this window, don't allow leave events through | - | ||||||||||||||||||
2042 | return; never executed: return; | 0 | ||||||||||||||||||
2043 | } | - | ||||||||||||||||||
2044 | - | |||||||||||||||||||
2045 | currentMouseWindow = 0; | - | ||||||||||||||||||
2046 | - | |||||||||||||||||||
2047 | QEvent event(QEvent::Leave); | - | ||||||||||||||||||
2048 | QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event); | - | ||||||||||||||||||
2049 | } never executed: end of block | 0 | ||||||||||||||||||
2050 | - | |||||||||||||||||||
2051 | void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e) | - | ||||||||||||||||||
2052 | { | - | ||||||||||||||||||
2053 | QWindow *previous = QGuiApplicationPrivate::focus_window; | - | ||||||||||||||||||
2054 | QWindow *newFocus = e->activated.data(); | - | ||||||||||||||||||
2055 | - | |||||||||||||||||||
2056 | if (previous == newFocus)
| 0 | ||||||||||||||||||
2057 | return; never executed: return; | 0 | ||||||||||||||||||
2058 | - | |||||||||||||||||||
2059 | if (newFocus)
| 0 | ||||||||||||||||||
2060 | if (QPlatformWindow *platformWindow = newFocus->handle())
| 0 | ||||||||||||||||||
2061 | if (platformWindow->isAlertState())
| 0 | ||||||||||||||||||
2062 | platformWindow->setAlertState(false); never executed: platformWindow->setAlertState(false); | 0 | ||||||||||||||||||
2063 | - | |||||||||||||||||||
2064 | QObject *previousFocusObject = previous ? previous->focusObject() : 0;
| 0 | ||||||||||||||||||
2065 | - | |||||||||||||||||||
2066 | if (previous) {
| 0 | ||||||||||||||||||
2067 | QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); | - | ||||||||||||||||||
2068 | QCoreApplication::sendSpontaneousEvent(previous, &focusAboutToChange); | - | ||||||||||||||||||
2069 | } never executed: end of block | 0 | ||||||||||||||||||
2070 | - | |||||||||||||||||||
2071 | QGuiApplicationPrivate::focus_window = newFocus; | - | ||||||||||||||||||
2072 | if (!qApp)
| 0 | ||||||||||||||||||
2073 | return; never executed: return; | 0 | ||||||||||||||||||
2074 | - | |||||||||||||||||||
2075 | if (previous) {
| 0 | ||||||||||||||||||
2076 | Qt::FocusReason r = e->reason; | - | ||||||||||||||||||
2077 | if ((r == Qt::OtherFocusReason || r == Qt::ActiveWindowFocusReason) &&
| 0 | ||||||||||||||||||
2078 | newFocus && (newFocus->flags() & Qt::Popup) == Qt::Popup)
| 0 | ||||||||||||||||||
2079 | r = Qt::PopupFocusReason; never executed: r = Qt::PopupFocusReason; | 0 | ||||||||||||||||||
2080 | QFocusEvent focusOut(QEvent::FocusOut, r); | - | ||||||||||||||||||
2081 | QCoreApplication::sendSpontaneousEvent(previous, &focusOut); | - | ||||||||||||||||||
2082 | QObject::disconnect(previous, SIGNAL(focusObjectChanged(QObject*)), | - | ||||||||||||||||||
2083 | qApp, SLOT(_q_updateFocusObject(QObject*))); | - | ||||||||||||||||||
2084 | } else if (!platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) { never executed: end of block
| 0 | ||||||||||||||||||
2085 | setApplicationState(Qt::ApplicationActive); | - | ||||||||||||||||||
2086 | } never executed: end of block | 0 | ||||||||||||||||||
2087 | - | |||||||||||||||||||
2088 | if (QGuiApplicationPrivate::focus_window) {
| 0 | ||||||||||||||||||
2089 | Qt::FocusReason r = e->reason; | - | ||||||||||||||||||
2090 | if ((r == Qt::OtherFocusReason || r == Qt::ActiveWindowFocusReason) &&
| 0 | ||||||||||||||||||
2091 | previous && (previous->flags() & Qt::Popup) == Qt::Popup)
| 0 | ||||||||||||||||||
2092 | r = Qt::PopupFocusReason; never executed: r = Qt::PopupFocusReason; | 0 | ||||||||||||||||||
2093 | QFocusEvent focusIn(QEvent::FocusIn, r); | - | ||||||||||||||||||
2094 | QCoreApplication::sendSpontaneousEvent(QGuiApplicationPrivate::focus_window, &focusIn); | - | ||||||||||||||||||
2095 | QObject::connect(QGuiApplicationPrivate::focus_window, SIGNAL(focusObjectChanged(QObject*)), | - | ||||||||||||||||||
2096 | qApp, SLOT(_q_updateFocusObject(QObject*))); | - | ||||||||||||||||||
2097 | } else if (!platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) { never executed: end of block
| 0 | ||||||||||||||||||
2098 | setApplicationState(Qt::ApplicationInactive); | - | ||||||||||||||||||
2099 | } never executed: end of block | 0 | ||||||||||||||||||
2100 | - | |||||||||||||||||||
2101 | if (self) {
| 0 | ||||||||||||||||||
2102 | self->notifyActiveWindowChange(previous); | - | ||||||||||||||||||
2103 | - | |||||||||||||||||||
2104 | if (previousFocusObject != qApp->focusObject())
| 0 | ||||||||||||||||||
2105 | self->_q_updateFocusObject(qApp->focusObject()); never executed: self->_q_updateFocusObject((static_cast<QGuiApplication *>(QCoreApplication::instance()))->focusObject()); | 0 | ||||||||||||||||||
2106 | } never executed: end of block | 0 | ||||||||||||||||||
2107 | - | |||||||||||||||||||
2108 | emit qApp->focusWindowChanged(newFocus); | - | ||||||||||||||||||
2109 | if (previous)
| 0 | ||||||||||||||||||
2110 | emit previous->activeChanged(); never executed: previous->activeChanged(); | 0 | ||||||||||||||||||
2111 | if (newFocus)
| 0 | ||||||||||||||||||
2112 | emit newFocus->activeChanged(); never executed: newFocus->activeChanged(); | 0 | ||||||||||||||||||
2113 | } never executed: end of block | 0 | ||||||||||||||||||
2114 | - | |||||||||||||||||||
2115 | void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse) | - | ||||||||||||||||||
2116 | { | - | ||||||||||||||||||
2117 | if (QWindow *window = wse->window.data()) {
| 0 | ||||||||||||||||||
2118 | QWindowStateChangeEvent e(window->windowState()); | - | ||||||||||||||||||
2119 | window->d_func()->windowState = wse->newState; | - | ||||||||||||||||||
2120 | QGuiApplication::sendSpontaneousEvent(window, &e); | - | ||||||||||||||||||
2121 | } never executed: end of block | 0 | ||||||||||||||||||
2122 | } never executed: end of block | 0 | ||||||||||||||||||
2123 | - | |||||||||||||||||||
2124 | void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *wse) | - | ||||||||||||||||||
2125 | { | - | ||||||||||||||||||
2126 | if (QWindow *window = wse->window.data()) {
| 0 | ||||||||||||||||||
2127 | if (window->isTopLevel()) {
| 0 | ||||||||||||||||||
2128 | if (QScreen *screen = wse->screen.data())
| 0 | ||||||||||||||||||
2129 | window->d_func()->setTopLevelScreen(screen, false /* recreate */); never executed: window->d_func()->setTopLevelScreen(screen, false ); | 0 | ||||||||||||||||||
2130 | else // Fall back to default behavior, and try to find some appropriate screen | - | ||||||||||||||||||
2131 | window->setScreen(0); never executed: window->setScreen(0); | 0 | ||||||||||||||||||
2132 | } | - | ||||||||||||||||||
2133 | // we may have changed scaling, so trigger resize event if needed | - | ||||||||||||||||||
2134 | if (window->handle()) {
| 0 | ||||||||||||||||||
2135 | QWindowSystemInterfacePrivate::GeometryChangeEvent gce(window, QHighDpi::fromNativePixels(window->handle()->geometry(), window), QRect()); | - | ||||||||||||||||||
2136 | processGeometryChangeEvent(&gce); | - | ||||||||||||||||||
2137 | } never executed: end of block | 0 | ||||||||||||||||||
2138 | } never executed: end of block | 0 | ||||||||||||||||||
2139 | } never executed: end of block | 0 | ||||||||||||||||||
2140 | - | |||||||||||||||||||
2141 | void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce) | - | ||||||||||||||||||
2142 | { | - | ||||||||||||||||||
2143 | if (self)
| 0 | ||||||||||||||||||
2144 | self->notifyThemeChanged(); never executed: self->notifyThemeChanged(); | 0 | ||||||||||||||||||
2145 | if (QWindow *window = tce->window.data()) {
| 0 | ||||||||||||||||||
2146 | QEvent e(QEvent::ThemeChange); | - | ||||||||||||||||||
2147 | QGuiApplication::sendSpontaneousEvent(window, &e); | - | ||||||||||||||||||
2148 | } never executed: end of block | 0 | ||||||||||||||||||
2149 | } never executed: end of block | 0 | ||||||||||||||||||
2150 | - | |||||||||||||||||||
2151 | void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e) | - | ||||||||||||||||||
2152 | { | - | ||||||||||||||||||
2153 | if (e->tlw.isNull())
| 0 | ||||||||||||||||||
2154 | return; never executed: return; | 0 | ||||||||||||||||||
2155 | - | |||||||||||||||||||
2156 | QWindow *window = e->tlw.data(); | - | ||||||||||||||||||
2157 | if (!window)
| 0 | ||||||||||||||||||
2158 | return; never executed: return; | 0 | ||||||||||||||||||
2159 | - | |||||||||||||||||||
2160 | QRect newRect = e->newGeometry; | - | ||||||||||||||||||
2161 | QRect oldRect = e->oldGeometry.isNull() ? window->d_func()->geometry : e->oldGeometry;
| 0 | ||||||||||||||||||
2162 | - | |||||||||||||||||||
2163 | bool isResize = oldRect.size() != newRect.size(); | - | ||||||||||||||||||
2164 | bool isMove = oldRect.topLeft() != newRect.topLeft(); | - | ||||||||||||||||||
2165 | - | |||||||||||||||||||
2166 | window->d_func()->geometry = newRect; | - | ||||||||||||||||||
2167 | - | |||||||||||||||||||
2168 | if (isResize || window->d_func()->resizeEventPending) {
| 0 | ||||||||||||||||||
2169 | QResizeEvent e(newRect.size(), oldRect.size()); | - | ||||||||||||||||||
2170 | QGuiApplication::sendSpontaneousEvent(window, &e); | - | ||||||||||||||||||
2171 | - | |||||||||||||||||||
2172 | window->d_func()->resizeEventPending = false; | - | ||||||||||||||||||
2173 | - | |||||||||||||||||||
2174 | if (oldRect.width() != newRect.width())
| 0 | ||||||||||||||||||
2175 | window->widthChanged(newRect.width()); never executed: window->widthChanged(newRect.width()); | 0 | ||||||||||||||||||
2176 | if (oldRect.height() != newRect.height())
| 0 | ||||||||||||||||||
2177 | window->heightChanged(newRect.height()); never executed: window->heightChanged(newRect.height()); | 0 | ||||||||||||||||||
2178 | } never executed: end of block | 0 | ||||||||||||||||||
2179 | - | |||||||||||||||||||
2180 | if (isMove) {
| 0 | ||||||||||||||||||
2181 | //### frame geometry | - | ||||||||||||||||||
2182 | QMoveEvent e(newRect.topLeft(), oldRect.topLeft()); | - | ||||||||||||||||||
2183 | QGuiApplication::sendSpontaneousEvent(window, &e); | - | ||||||||||||||||||
2184 | - | |||||||||||||||||||
2185 | if (oldRect.x() != newRect.x())
| 0 | ||||||||||||||||||
2186 | window->xChanged(newRect.x()); never executed: window->xChanged(newRect.x()); | 0 | ||||||||||||||||||
2187 | if (oldRect.y() != newRect.y())
| 0 | ||||||||||||||||||
2188 | window->yChanged(newRect.y()); never executed: window->yChanged(newRect.y()); | 0 | ||||||||||||||||||
2189 | } never executed: end of block | 0 | ||||||||||||||||||
2190 | } never executed: end of block | 0 | ||||||||||||||||||
2191 | - | |||||||||||||||||||
2192 | void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e) | - | ||||||||||||||||||
2193 | { | - | ||||||||||||||||||
2194 | if (e->window.isNull())
| 0 | ||||||||||||||||||
2195 | return; never executed: return; | 0 | ||||||||||||||||||
2196 | if (e->window.data()->d_func()->blockedByModalWindow) {
| 0 | ||||||||||||||||||
2197 | // a modal window is blocking this window, don't allow close events through | - | ||||||||||||||||||
2198 | return; never executed: return; | 0 | ||||||||||||||||||
2199 | } | - | ||||||||||||||||||
2200 | - | |||||||||||||||||||
2201 | QCloseEvent event; | - | ||||||||||||||||||
2202 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &event); | - | ||||||||||||||||||
2203 | if (e->accepted) {
| 0 | ||||||||||||||||||
2204 | *(e->accepted) = event.isAccepted(); | - | ||||||||||||||||||
2205 | } never executed: end of block | 0 | ||||||||||||||||||
2206 | } never executed: end of block | 0 | ||||||||||||||||||
2207 | - | |||||||||||||||||||
2208 | void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e) | - | ||||||||||||||||||
2209 | { | - | ||||||||||||||||||
2210 | if (e->url.isEmpty())
| 0 | ||||||||||||||||||
2211 | return; never executed: return; | 0 | ||||||||||||||||||
2212 | - | |||||||||||||||||||
2213 | QFileOpenEvent event(e->url); | - | ||||||||||||||||||
2214 | QGuiApplication::sendSpontaneousEvent(qApp, &event); | - | ||||||||||||||||||
2215 | } never executed: end of block | 0 | ||||||||||||||||||
2216 | - | |||||||||||||||||||
2217 | void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e) | - | ||||||||||||||||||
2218 | { | - | ||||||||||||||||||
2219 | #ifndef QT_NO_TABLETEVENT | - | ||||||||||||||||||
2220 | QEvent::Type type = QEvent::TabletMove; | - | ||||||||||||||||||
2221 | if (e->buttons != tabletState)
| 0 | ||||||||||||||||||
2222 | type = (e->buttons > tabletState) ? QEvent::TabletPress : QEvent::TabletRelease; never executed: type = (e->buttons > tabletState) ? QEvent::TabletPress : QEvent::TabletRelease;
| 0 | ||||||||||||||||||
2223 | - | |||||||||||||||||||
2224 | QWindow *window = e->window.data(); | - | ||||||||||||||||||
2225 | modifier_buttons = e->modifiers; | - | ||||||||||||||||||
2226 | - | |||||||||||||||||||
2227 | bool localValid = true; | - | ||||||||||||||||||
2228 | // If window is null, pick one based on the global position and make sure all | - | ||||||||||||||||||
2229 | // subsequent events up to the release are delivered to that same window. | - | ||||||||||||||||||
2230 | // If window is given, just send to that. | - | ||||||||||||||||||
2231 | if (type == QEvent::TabletPress) {
| 0 | ||||||||||||||||||
2232 | if (e->nullWindow()) {
| 0 | ||||||||||||||||||
2233 | window = QGuiApplication::topLevelAt(e->global.toPoint()); | - | ||||||||||||||||||
2234 | localValid = false; | - | ||||||||||||||||||
2235 | } never executed: end of block | 0 | ||||||||||||||||||
2236 | if (!window)
| 0 | ||||||||||||||||||
2237 | return; never executed: return; | 0 | ||||||||||||||||||
2238 | tabletPressTarget = window; | - | ||||||||||||||||||
2239 | } else { never executed: end of block | 0 | ||||||||||||||||||
2240 | if (e->nullWindow()) {
| 0 | ||||||||||||||||||
2241 | window = tabletPressTarget; | - | ||||||||||||||||||
2242 | localValid = false; | - | ||||||||||||||||||
2243 | } never executed: end of block | 0 | ||||||||||||||||||
2244 | if (type == QEvent::TabletRelease)
| 0 | ||||||||||||||||||
2245 | tabletPressTarget = 0; never executed: tabletPressTarget = 0; | 0 | ||||||||||||||||||
2246 | if (!window)
| 0 | ||||||||||||||||||
2247 | return; never executed: return; | 0 | ||||||||||||||||||
2248 | } never executed: end of block | 0 | ||||||||||||||||||
2249 | QPointF local = e->local; | - | ||||||||||||||||||
2250 | if (!localValid) {
| 0 | ||||||||||||||||||
2251 | QPointF delta = e->global - e->global.toPoint(); | - | ||||||||||||||||||
2252 | local = window->mapFromGlobal(e->global.toPoint()) + delta; | - | ||||||||||||||||||
2253 | } never executed: end of block | 0 | ||||||||||||||||||
2254 | Qt::MouseButtons stateChange = e->buttons ^ tabletState; | - | ||||||||||||||||||
2255 | Qt::MouseButton button = Qt::NoButton; | - | ||||||||||||||||||
2256 | for (int check = Qt::LeftButton; check <= int(Qt::MaxMouseButton); check = check << 1) {
| 0 | ||||||||||||||||||
2257 | if (check & stateChange) {
| 0 | ||||||||||||||||||
2258 | button = Qt::MouseButton(check); | - | ||||||||||||||||||
2259 | break; never executed: break; | 0 | ||||||||||||||||||
2260 | } | - | ||||||||||||||||||
2261 | } never executed: end of block | 0 | ||||||||||||||||||
2262 | QTabletEvent ev(type, local, e->global, | - | ||||||||||||||||||
2263 | e->device, e->pointerType, e->pressure, e->xTilt, e->yTilt, | - | ||||||||||||||||||
2264 | e->tangentialPressure, e->rotation, e->z, | - | ||||||||||||||||||
2265 | e->modifiers, e->uid, button, e->buttons); | - | ||||||||||||||||||
2266 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
2267 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - | ||||||||||||||||||
2268 | tabletState = e->buttons; | - | ||||||||||||||||||
2269 | #else | - | ||||||||||||||||||
2270 | Q_UNUSED(e) | - | ||||||||||||||||||
2271 | #endif | - | ||||||||||||||||||
2272 | } never executed: end of block | 0 | ||||||||||||||||||
2273 | - | |||||||||||||||||||
2274 | void QGuiApplicationPrivate::processTabletEnterProximityEvent(QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e) | - | ||||||||||||||||||
2275 | { | - | ||||||||||||||||||
2276 | #ifndef QT_NO_TABLETEVENT | - | ||||||||||||||||||
2277 | QTabletEvent ev(QEvent::TabletEnterProximity, QPointF(), QPointF(), | - | ||||||||||||||||||
2278 | e->device, e->pointerType, 0, 0, 0, | - | ||||||||||||||||||
2279 | 0, 0, 0, | - | ||||||||||||||||||
2280 | Qt::NoModifier, e->uid, Qt::NoButton, tabletState); | - | ||||||||||||||||||
2281 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
2282 | QGuiApplication::sendSpontaneousEvent(qGuiApp, &ev); | - | ||||||||||||||||||
2283 | #else | - | ||||||||||||||||||
2284 | Q_UNUSED(e) | - | ||||||||||||||||||
2285 | #endif | - | ||||||||||||||||||
2286 | } never executed: end of block | 0 | ||||||||||||||||||
2287 | - | |||||||||||||||||||
2288 | void QGuiApplicationPrivate::processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e) | - | ||||||||||||||||||
2289 | { | - | ||||||||||||||||||
2290 | #ifndef QT_NO_TABLETEVENT | - | ||||||||||||||||||
2291 | QTabletEvent ev(QEvent::TabletLeaveProximity, QPointF(), QPointF(), | - | ||||||||||||||||||
2292 | e->device, e->pointerType, 0, 0, 0, | - | ||||||||||||||||||
2293 | 0, 0, 0, | - | ||||||||||||||||||
2294 | Qt::NoModifier, e->uid, Qt::NoButton, tabletState); | - | ||||||||||||||||||
2295 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
2296 | QGuiApplication::sendSpontaneousEvent(qGuiApp, &ev); | - | ||||||||||||||||||
2297 | #else | - | ||||||||||||||||||
2298 | Q_UNUSED(e) | - | ||||||||||||||||||
2299 | #endif | - | ||||||||||||||||||
2300 | } never executed: end of block | 0 | ||||||||||||||||||
2301 | - | |||||||||||||||||||
2302 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||
2303 | void QGuiApplicationPrivate::processGestureEvent(QWindowSystemInterfacePrivate::GestureEvent *e) | - | ||||||||||||||||||
2304 | { | - | ||||||||||||||||||
2305 | if (e->window.isNull())
| 0 | ||||||||||||||||||
2306 | return; never executed: return; | 0 | ||||||||||||||||||
2307 | - | |||||||||||||||||||
2308 | QNativeGestureEvent ev(e->type, e->pos, e->pos, e->globalPos, e->realValue, e->sequenceId, e->intValue); | - | ||||||||||||||||||
2309 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
2310 | QGuiApplication::sendSpontaneousEvent(e->window, &ev); | - | ||||||||||||||||||
2311 | } never executed: end of block | 0 | ||||||||||||||||||
2312 | #endif // QT_NO_GESTURES | - | ||||||||||||||||||
2313 | - | |||||||||||||||||||
2314 | void QGuiApplicationPrivate::processPlatformPanelEvent(QWindowSystemInterfacePrivate::PlatformPanelEvent *e) | - | ||||||||||||||||||
2315 | { | - | ||||||||||||||||||
2316 | if (!e->window)
| 0 | ||||||||||||||||||
2317 | return; never executed: return; | 0 | ||||||||||||||||||
2318 | - | |||||||||||||||||||
2319 | if (e->window->d_func()->blockedByModalWindow) {
| 0 | ||||||||||||||||||
2320 | // a modal window is blocking this window, don't allow events through | - | ||||||||||||||||||
2321 | return; never executed: return; | 0 | ||||||||||||||||||
2322 | } | - | ||||||||||||||||||
2323 | - | |||||||||||||||||||
2324 | QEvent ev(QEvent::PlatformPanel); | - | ||||||||||||||||||
2325 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &ev); | - | ||||||||||||||||||
2326 | } never executed: end of block | 0 | ||||||||||||||||||
2327 | - | |||||||||||||||||||
2328 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||||||||
2329 | void QGuiApplicationPrivate::processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e) | - | ||||||||||||||||||
2330 | { | - | ||||||||||||||||||
2331 | // Widgets do not care about mouse triggered context menu events. Also, do not forward event | - | ||||||||||||||||||
2332 | // to a window blocked by a modal window. | - | ||||||||||||||||||
2333 | if (!e->window || e->mouseTriggered || e->window->d_func()->blockedByModalWindow)
| 0 | ||||||||||||||||||
2334 | return; never executed: return; | 0 | ||||||||||||||||||
2335 | - | |||||||||||||||||||
2336 | QContextMenuEvent ev(QContextMenuEvent::Keyboard, e->pos, e->globalPos, e->modifiers); | - | ||||||||||||||||||
2337 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &ev); | - | ||||||||||||||||||
2338 | } never executed: end of block | 0 | ||||||||||||||||||
2339 | #endif | - | ||||||||||||||||||
2340 | - | |||||||||||||||||||
2341 | Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k) | - | ||||||||||||||||||
2342 | { | - | ||||||||||||||||||
2343 | return qHash(k.device) + k.touchPointId; never executed: return qHash(k.device) + k.touchPointId; | 0 | ||||||||||||||||||
2344 | } | - | ||||||||||||||||||
2345 | - | |||||||||||||||||||
2346 | Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a, | - | ||||||||||||||||||
2347 | const QGuiApplicationPrivate::ActiveTouchPointsKey &b) | - | ||||||||||||||||||
2348 | { | - | ||||||||||||||||||
2349 | return a.device == b.device never executed: return a.device == b.device && a.touchPointId == b.touchPointId;
| 0 | ||||||||||||||||||
2350 | && a.touchPointId == b.touchPointId; never executed: return a.device == b.device && a.touchPointId == b.touchPointId;
| 0 | ||||||||||||||||||
2351 | } | - | ||||||||||||||||||
2352 | - | |||||||||||||||||||
2353 | void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e) | - | ||||||||||||||||||
2354 | { | - | ||||||||||||||||||
2355 | QGuiApplicationPrivate *d = self; | - | ||||||||||||||||||
2356 | modifier_buttons = e->modifiers; | - | ||||||||||||||||||
2357 | - | |||||||||||||||||||
2358 | if (e->touchType == QEvent::TouchCancel) {
| 0 | ||||||||||||||||||
2359 | // The touch sequence has been canceled (e.g. by the compositor). | - | ||||||||||||||||||
2360 | // Send the TouchCancel to all windows with active touches and clean up. | - | ||||||||||||||||||
2361 | QTouchEvent touchEvent(QEvent::TouchCancel, e->device, e->modifiers); | - | ||||||||||||||||||
2362 | touchEvent.setTimestamp(e->timestamp); | - | ||||||||||||||||||
2363 | QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it | - | ||||||||||||||||||
2364 | = self->activeTouchPoints.constBegin(), ite = self->activeTouchPoints.constEnd(); | - | ||||||||||||||||||
2365 | QSet<QWindow *> windowsNeedingCancel; | - | ||||||||||||||||||
2366 | while (it != ite) {
| 0 | ||||||||||||||||||
2367 | QWindow *w = it->window.data(); | - | ||||||||||||||||||
2368 | if (w)
| 0 | ||||||||||||||||||
2369 | windowsNeedingCancel.insert(w); never executed: windowsNeedingCancel.insert(w); | 0 | ||||||||||||||||||
2370 | ++it; | - | ||||||||||||||||||
2371 | } never executed: end of block | 0 | ||||||||||||||||||
2372 | for (QSet<QWindow *>::const_iterator winIt = windowsNeedingCancel.constBegin(), | - | ||||||||||||||||||
2373 | winItEnd = windowsNeedingCancel.constEnd(); winIt != winItEnd; ++winIt) {
| 0 | ||||||||||||||||||
2374 | touchEvent.setWindow(*winIt); | - | ||||||||||||||||||
2375 | QGuiApplication::sendSpontaneousEvent(*winIt, &touchEvent); | - | ||||||||||||||||||
2376 | } never executed: end of block | 0 | ||||||||||||||||||
2377 | if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic()) {
| 0 | ||||||||||||||||||
2378 | for (QHash<QWindow *, SynthesizedMouseData>::const_iterator synthIt = self->synthesizedMousePoints.constBegin(), | - | ||||||||||||||||||
2379 | synthItEnd = self->synthesizedMousePoints.constEnd(); synthIt != synthItEnd; ++synthIt) {
| 0 | ||||||||||||||||||
2380 | if (!synthIt->window)
| 0 | ||||||||||||||||||
2381 | continue; never executed: continue; | 0 | ||||||||||||||||||
2382 | QWindowSystemInterfacePrivate::MouseEvent fake(synthIt->window.data(), | - | ||||||||||||||||||
2383 | e->timestamp, | - | ||||||||||||||||||
2384 | synthIt->pos, | - | ||||||||||||||||||
2385 | synthIt->screenPos, | - | ||||||||||||||||||
2386 | buttons & ~Qt::LeftButton, | - | ||||||||||||||||||
2387 | e->modifiers, | - | ||||||||||||||||||
2388 | Qt::MouseEventSynthesizedByQt); | - | ||||||||||||||||||
2389 | fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; | - | ||||||||||||||||||
2390 | processMouseEvent(&fake); | - | ||||||||||||||||||
2391 | } never executed: end of block | 0 | ||||||||||||||||||
2392 | self->synthesizedMousePoints.clear(); | - | ||||||||||||||||||
2393 | } never executed: end of block | 0 | ||||||||||||||||||
2394 | self->activeTouchPoints.clear(); | - | ||||||||||||||||||
2395 | self->lastTouchType = e->touchType; | - | ||||||||||||||||||
2396 | return; never executed: return; | 0 | ||||||||||||||||||
2397 | } | - | ||||||||||||||||||
2398 | - | |||||||||||||||||||
2399 | // Prevent sending ill-formed event sequences: Cancel can only be followed by a Begin. | - | ||||||||||||||||||
2400 | if (self->lastTouchType == QEvent::TouchCancel && e->touchType != QEvent::TouchBegin)
| 0 | ||||||||||||||||||
2401 | return; never executed: return; | 0 | ||||||||||||||||||
2402 | - | |||||||||||||||||||
2403 | self->lastTouchType = e->touchType; | - | ||||||||||||||||||
2404 | - | |||||||||||||||||||
2405 | QWindow *window = e->window.data(); | - | ||||||||||||||||||
2406 | typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints; | - | ||||||||||||||||||
2407 | QHash<QWindow *, StatesAndTouchPoints> windowsNeedingEvents; | - | ||||||||||||||||||
2408 | - | |||||||||||||||||||
2409 | for (int i = 0; i < e->points.count(); ++i) {
| 0 | ||||||||||||||||||
2410 | QTouchEvent::TouchPoint touchPoint = e->points.at(i); | - | ||||||||||||||||||
2411 | // explicitly detach from the original touch point that we got, so even | - | ||||||||||||||||||
2412 | // if the touchpoint structs are reused, we will make a copy that we'll | - | ||||||||||||||||||
2413 | // deliver to the user (which might want to store the struct for later use). | - | ||||||||||||||||||
2414 | touchPoint.d = touchPoint.d->detach(); | - | ||||||||||||||||||
2415 | - | |||||||||||||||||||
2416 | // update state | - | ||||||||||||||||||
2417 | QPointer<QWindow> w; | - | ||||||||||||||||||
2418 | QTouchEvent::TouchPoint previousTouchPoint; | - | ||||||||||||||||||
2419 | ActiveTouchPointsKey touchInfoKey(e->device, touchPoint.id()); | - | ||||||||||||||||||
2420 | ActiveTouchPointsValue &touchInfo = d->activeTouchPoints[touchInfoKey]; | - | ||||||||||||||||||
2421 | switch (touchPoint.state()) { | - | ||||||||||||||||||
2422 | case Qt::TouchPointPressed: never executed: case Qt::TouchPointPressed: | 0 | ||||||||||||||||||
2423 | if (e->device->type() == QTouchDevice::TouchPad) {
| 0 | ||||||||||||||||||
2424 | // on touch-pads, send all touch points to the same widget | - | ||||||||||||||||||
2425 | w = d->activeTouchPoints.isEmpty()
| 0 | ||||||||||||||||||
2426 | ? QPointer<QWindow>() | - | ||||||||||||||||||
2427 | : d->activeTouchPoints.constBegin().value().window; | - | ||||||||||||||||||
2428 | } never executed: end of block | 0 | ||||||||||||||||||
2429 | - | |||||||||||||||||||
2430 | if (!w) {
| 0 | ||||||||||||||||||
2431 | // determine which window this event will go to | - | ||||||||||||||||||
2432 | if (!window)
| 0 | ||||||||||||||||||
2433 | window = QGuiApplication::topLevelAt(touchPoint.screenPos().toPoint()); never executed: window = QGuiApplication::topLevelAt(touchPoint.screenPos().toPoint()); | 0 | ||||||||||||||||||
2434 | if (!window)
| 0 | ||||||||||||||||||
2435 | continue; never executed: continue; | 0 | ||||||||||||||||||
2436 | w = window; | - | ||||||||||||||||||
2437 | } never executed: end of block | 0 | ||||||||||||||||||
2438 | - | |||||||||||||||||||
2439 | touchInfo.window = w; | - | ||||||||||||||||||
2440 | touchPoint.d->startScreenPos = touchPoint.screenPos(); | - | ||||||||||||||||||
2441 | touchPoint.d->lastScreenPos = touchPoint.screenPos(); | - | ||||||||||||||||||
2442 | touchPoint.d->startNormalizedPos = touchPoint.normalizedPos(); | - | ||||||||||||||||||
2443 | touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos(); | - | ||||||||||||||||||
2444 | if (touchPoint.pressure() < qreal(0.))
| 0 | ||||||||||||||||||
2445 | touchPoint.d->pressure = qreal(1.); never executed: touchPoint.d->pressure = qreal(1.); | 0 | ||||||||||||||||||
2446 | - | |||||||||||||||||||
2447 | touchInfo.touchPoint = touchPoint; | - | ||||||||||||||||||
2448 | break; never executed: break; | 0 | ||||||||||||||||||
2449 | - | |||||||||||||||||||
2450 | case Qt::TouchPointReleased: never executed: case Qt::TouchPointReleased: | 0 | ||||||||||||||||||
2451 | w = touchInfo.window; | - | ||||||||||||||||||
2452 | if (!w)
| 0 | ||||||||||||||||||
2453 | continue; never executed: continue; | 0 | ||||||||||||||||||
2454 | - | |||||||||||||||||||
2455 | previousTouchPoint = touchInfo.touchPoint; | - | ||||||||||||||||||
2456 | touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); | - | ||||||||||||||||||
2457 | touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); | - | ||||||||||||||||||
2458 | touchPoint.d->startPos = previousTouchPoint.startPos(); | - | ||||||||||||||||||
2459 | touchPoint.d->lastPos = previousTouchPoint.pos(); | - | ||||||||||||||||||
2460 | touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); | - | ||||||||||||||||||
2461 | touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); | - | ||||||||||||||||||
2462 | if (touchPoint.pressure() < qreal(0.))
| 0 | ||||||||||||||||||
2463 | touchPoint.d->pressure = qreal(0.); never executed: touchPoint.d->pressure = qreal(0.); | 0 | ||||||||||||||||||
2464 | - | |||||||||||||||||||
2465 | break; never executed: break; | 0 | ||||||||||||||||||
2466 | - | |||||||||||||||||||
2467 | default: never executed: default: | 0 | ||||||||||||||||||
2468 | w = touchInfo.window; | - | ||||||||||||||||||
2469 | if (!w)
| 0 | ||||||||||||||||||
2470 | continue; never executed: continue; | 0 | ||||||||||||||||||
2471 | - | |||||||||||||||||||
2472 | previousTouchPoint = touchInfo.touchPoint; | - | ||||||||||||||||||
2473 | touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); | - | ||||||||||||||||||
2474 | touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); | - | ||||||||||||||||||
2475 | touchPoint.d->startPos = previousTouchPoint.startPos(); | - | ||||||||||||||||||
2476 | touchPoint.d->lastPos = previousTouchPoint.pos(); | - | ||||||||||||||||||
2477 | touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); | - | ||||||||||||||||||
2478 | touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); | - | ||||||||||||||||||
2479 | if (touchPoint.pressure() < qreal(0.))
| 0 | ||||||||||||||||||
2480 | touchPoint.d->pressure = qreal(1.); never executed: touchPoint.d->pressure = qreal(1.); | 0 | ||||||||||||||||||
2481 | - | |||||||||||||||||||
2482 | // Stationary points might not be delivered down to the receiving item | - | ||||||||||||||||||
2483 | // and get their position transformed, keep the old values instead. | - | ||||||||||||||||||
2484 | if (touchPoint.state() != Qt::TouchPointStationary)
| 0 | ||||||||||||||||||
2485 | touchInfo.touchPoint = touchPoint; never executed: touchInfo.touchPoint = touchPoint; | 0 | ||||||||||||||||||
2486 | break; never executed: break; | 0 | ||||||||||||||||||
2487 | } | - | ||||||||||||||||||
2488 | - | |||||||||||||||||||
2489 | Q_ASSERT(w.data() != 0); | - | ||||||||||||||||||
2490 | - | |||||||||||||||||||
2491 | // make the *scene* functions return the same as the *screen* functions | - | ||||||||||||||||||
2492 | touchPoint.d->sceneRect = touchPoint.screenRect(); | - | ||||||||||||||||||
2493 | touchPoint.d->startScenePos = touchPoint.startScreenPos(); | - | ||||||||||||||||||
2494 | touchPoint.d->lastScenePos = touchPoint.lastScreenPos(); | - | ||||||||||||||||||
2495 | - | |||||||||||||||||||
2496 | StatesAndTouchPoints &maskAndPoints = windowsNeedingEvents[w.data()]; | - | ||||||||||||||||||
2497 | maskAndPoints.first |= touchPoint.state(); | - | ||||||||||||||||||
2498 | maskAndPoints.second.append(touchPoint); | - | ||||||||||||||||||
2499 | } never executed: end of block | 0 | ||||||||||||||||||
2500 | - | |||||||||||||||||||
2501 | if (windowsNeedingEvents.isEmpty())
| 0 | ||||||||||||||||||
2502 | return; never executed: return; | 0 | ||||||||||||||||||
2503 | - | |||||||||||||||||||
2504 | QHash<QWindow *, StatesAndTouchPoints>::ConstIterator it = windowsNeedingEvents.constBegin(); | - | ||||||||||||||||||
2505 | const QHash<QWindow *, StatesAndTouchPoints>::ConstIterator end = windowsNeedingEvents.constEnd(); | - | ||||||||||||||||||
2506 | for (; it != end; ++it) {
| 0 | ||||||||||||||||||
2507 | QWindow *w = it.key(); | - | ||||||||||||||||||
2508 | - | |||||||||||||||||||
2509 | QEvent::Type eventType; | - | ||||||||||||||||||
2510 | switch (it.value().first) { | - | ||||||||||||||||||
2511 | case Qt::TouchPointPressed: never executed: case Qt::TouchPointPressed: | 0 | ||||||||||||||||||
2512 | eventType = QEvent::TouchBegin; | - | ||||||||||||||||||
2513 | break; never executed: break; | 0 | ||||||||||||||||||
2514 | case Qt::TouchPointReleased: never executed: case Qt::TouchPointReleased: | 0 | ||||||||||||||||||
2515 | eventType = QEvent::TouchEnd; | - | ||||||||||||||||||
2516 | break; never executed: break; | 0 | ||||||||||||||||||
2517 | case Qt::TouchPointStationary: never executed: case Qt::TouchPointStationary: | 0 | ||||||||||||||||||
2518 | // don't send the event if nothing changed | - | ||||||||||||||||||
2519 | continue; never executed: continue; | 0 | ||||||||||||||||||
2520 | default: never executed: default: | 0 | ||||||||||||||||||
2521 | eventType = QEvent::TouchUpdate; | - | ||||||||||||||||||
2522 | break; never executed: break; | 0 | ||||||||||||||||||
2523 | } | - | ||||||||||||||||||
2524 | - | |||||||||||||||||||
2525 | if (w->d_func()->blockedByModalWindow) {
| 0 | ||||||||||||||||||
2526 | // a modal window is blocking this window, don't allow touch events through | - | ||||||||||||||||||
2527 | - | |||||||||||||||||||
2528 | // QTBUG-37371 temporary fix; TODO: revisit in 5.4 when we have a forwarding solution | - | ||||||||||||||||||
2529 | if (eventType == QEvent::TouchEnd) {
| 0 | ||||||||||||||||||
2530 | // but don't leave dangling state: e.g. | - | ||||||||||||||||||
2531 | // QQuickWindowPrivate::itemForTouchPointId needs to be cleared. | - | ||||||||||||||||||
2532 | QTouchEvent touchEvent(QEvent::TouchCancel, | - | ||||||||||||||||||
2533 | e->device, | - | ||||||||||||||||||
2534 | e->modifiers); | - | ||||||||||||||||||
2535 | touchEvent.setTimestamp(e->timestamp); | - | ||||||||||||||||||
2536 | touchEvent.setWindow(w); | - | ||||||||||||||||||
2537 | QGuiApplication::sendSpontaneousEvent(w, &touchEvent); | - | ||||||||||||||||||
2538 | } never executed: end of block | 0 | ||||||||||||||||||
2539 | continue; never executed: continue; | 0 | ||||||||||||||||||
2540 | } | - | ||||||||||||||||||
2541 | - | |||||||||||||||||||
2542 | QTouchEvent touchEvent(eventType, | - | ||||||||||||||||||
2543 | e->device, | - | ||||||||||||||||||
2544 | e->modifiers, | - | ||||||||||||||||||
2545 | it.value().first, | - | ||||||||||||||||||
2546 | it.value().second); | - | ||||||||||||||||||
2547 | touchEvent.setTimestamp(e->timestamp); | - | ||||||||||||||||||
2548 | touchEvent.setWindow(w); | - | ||||||||||||||||||
2549 | - | |||||||||||||||||||
2550 | const int pointCount = touchEvent.touchPoints().count(); | - | ||||||||||||||||||
2551 | for (int i = 0; i < pointCount; ++i) {
| 0 | ||||||||||||||||||
2552 | QTouchEvent::TouchPoint &touchPoint = touchEvent._touchPoints[i]; | - | ||||||||||||||||||
2553 | - | |||||||||||||||||||
2554 | // preserve the sub-pixel resolution | - | ||||||||||||||||||
2555 | QRectF rect = touchPoint.screenRect(); | - | ||||||||||||||||||
2556 | const QPointF screenPos = rect.center(); | - | ||||||||||||||||||
2557 | const QPointF delta = screenPos - screenPos.toPoint(); | - | ||||||||||||||||||
2558 | - | |||||||||||||||||||
2559 | rect.moveCenter(w->mapFromGlobal(screenPos.toPoint()) + delta); | - | ||||||||||||||||||
2560 | touchPoint.d->rect = rect; | - | ||||||||||||||||||
2561 | if (touchPoint.state() == Qt::TouchPointPressed) {
| 0 | ||||||||||||||||||
2562 | touchPoint.d->startPos = w->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; | - | ||||||||||||||||||
2563 | touchPoint.d->lastPos = w->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; | - | ||||||||||||||||||
2564 | } never executed: end of block | 0 | ||||||||||||||||||
2565 | } never executed: end of block | 0 | ||||||||||||||||||
2566 | - | |||||||||||||||||||
2567 | QGuiApplication::sendSpontaneousEvent(w, &touchEvent); | - | ||||||||||||||||||
2568 | if (!e->synthetic() && !touchEvent.isAccepted() && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) {
| 0 | ||||||||||||||||||
2569 | // exclude devices which generate their own mouse events | - | ||||||||||||||||||
2570 | if (!(touchEvent.device()->capabilities() & QTouchDevice::MouseEmulation)) {
| 0 | ||||||||||||||||||
2571 | Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton;
| 0 | ||||||||||||||||||
2572 | if (b == Qt::NoButton)
| 0 | ||||||||||||||||||
2573 | self->synthesizedMousePoints.clear(); never executed: self->synthesizedMousePoints.clear(); | 0 | ||||||||||||||||||
2574 | - | |||||||||||||||||||
2575 | QList<QTouchEvent::TouchPoint> touchPoints = touchEvent.touchPoints(); | - | ||||||||||||||||||
2576 | if (eventType == QEvent::TouchBegin)
| 0 | ||||||||||||||||||
2577 | m_fakeMouseSourcePointId = touchPoints.first().id(); never executed: m_fakeMouseSourcePointId = touchPoints.first().id(); | 0 | ||||||||||||||||||
2578 | - | |||||||||||||||||||
2579 | for (int i = 0; i < touchPoints.count(); ++i) {
| 0 | ||||||||||||||||||
2580 | const QTouchEvent::TouchPoint &touchPoint = touchPoints.at(i); | - | ||||||||||||||||||
2581 | if (touchPoint.id() == m_fakeMouseSourcePointId) {
| 0 | ||||||||||||||||||
2582 | if (b != Qt::NoButton)
| 0 | ||||||||||||||||||
2583 | self->synthesizedMousePoints.insert(w, SynthesizedMouseData( never executed: self->synthesizedMousePoints.insert(w, SynthesizedMouseData( touchPoint.pos(), touchPoint.screenPos(), w)); | 0 | ||||||||||||||||||
2584 | touchPoint.pos(), touchPoint.screenPos(), w)); never executed: self->synthesizedMousePoints.insert(w, SynthesizedMouseData( touchPoint.pos(), touchPoint.screenPos(), w)); | 0 | ||||||||||||||||||
2585 | QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp, | - | ||||||||||||||||||
2586 | touchPoint.pos(), | - | ||||||||||||||||||
2587 | touchPoint.screenPos(), | - | ||||||||||||||||||
2588 | b | (buttons & ~Qt::LeftButton), | - | ||||||||||||||||||
2589 | e->modifiers, | - | ||||||||||||||||||
2590 | Qt::MouseEventSynthesizedByQt); | - | ||||||||||||||||||
2591 | fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; | - | ||||||||||||||||||
2592 | processMouseEvent(&fake); | - | ||||||||||||||||||
2593 | break; never executed: break; | 0 | ||||||||||||||||||
2594 | } | - | ||||||||||||||||||
2595 | } never executed: end of block | 0 | ||||||||||||||||||
2596 | } never executed: end of block | 0 | ||||||||||||||||||
2597 | } never executed: end of block | 0 | ||||||||||||||||||
2598 | } never executed: end of block | 0 | ||||||||||||||||||
2599 | - | |||||||||||||||||||
2600 | // Remove released points from the hash table only after the event is | - | ||||||||||||||||||
2601 | // delivered. When the receiver is a widget, QApplication will access | - | ||||||||||||||||||
2602 | // activeTouchPoints during delivery and therefore nothing can be removed | - | ||||||||||||||||||
2603 | // before sending the event. | - | ||||||||||||||||||
2604 | for (int i = 0; i < e->points.count(); ++i) {
| 0 | ||||||||||||||||||
2605 | QTouchEvent::TouchPoint touchPoint = e->points.at(i); | - | ||||||||||||||||||
2606 | if (touchPoint.state() == Qt::TouchPointReleased)
| 0 | ||||||||||||||||||
2607 | d->activeTouchPoints.remove(ActiveTouchPointsKey(e->device, touchPoint.id())); never executed: d->activeTouchPoints.remove(ActiveTouchPointsKey(e->device, touchPoint.id())); | 0 | ||||||||||||||||||
2608 | } never executed: end of block | 0 | ||||||||||||||||||
2609 | } never executed: end of block | 0 | ||||||||||||||||||
2610 | - | |||||||||||||||||||
2611 | void QGuiApplicationPrivate::reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e) | - | ||||||||||||||||||
2612 | { | - | ||||||||||||||||||
2613 | // This operation only makes sense after the QGuiApplication constructor runs | - | ||||||||||||||||||
2614 | if (QCoreApplication::startingUp())
| 0 | ||||||||||||||||||
2615 | return; never executed: return; | 0 | ||||||||||||||||||
2616 | - | |||||||||||||||||||
2617 | if (!e->screen)
| 0 | ||||||||||||||||||
2618 | return; never executed: return; | 0 | ||||||||||||||||||
2619 | - | |||||||||||||||||||
2620 | QScreen *s = e->screen.data(); | - | ||||||||||||||||||
2621 | s->d_func()->orientation = e->orientation; | - | ||||||||||||||||||
2622 | - | |||||||||||||||||||
2623 | updateFilteredScreenOrientation(s); | - | ||||||||||||||||||
2624 | } never executed: end of block | 0 | ||||||||||||||||||
2625 | - | |||||||||||||||||||
2626 | void QGuiApplicationPrivate::updateFilteredScreenOrientation(QScreen *s) | - | ||||||||||||||||||
2627 | { | - | ||||||||||||||||||
2628 | Qt::ScreenOrientation o = s->d_func()->orientation; | - | ||||||||||||||||||
2629 | if (o == Qt::PrimaryOrientation)
| 0 | ||||||||||||||||||
2630 | o = s->primaryOrientation(); never executed: o = s->primaryOrientation(); | 0 | ||||||||||||||||||
2631 | o = Qt::ScreenOrientation(o & s->orientationUpdateMask()); | - | ||||||||||||||||||
2632 | if (o == Qt::PrimaryOrientation)
| 0 | ||||||||||||||||||
2633 | return; never executed: return; | 0 | ||||||||||||||||||
2634 | if (o == s->d_func()->filteredOrientation)
| 0 | ||||||||||||||||||
2635 | return; never executed: return; | 0 | ||||||||||||||||||
2636 | s->d_func()->filteredOrientation = o; | - | ||||||||||||||||||
2637 | reportScreenOrientationChange(s); | - | ||||||||||||||||||
2638 | } never executed: end of block | 0 | ||||||||||||||||||
2639 | - | |||||||||||||||||||
2640 | void QGuiApplicationPrivate::reportScreenOrientationChange(QScreen *s) | - | ||||||||||||||||||
2641 | { | - | ||||||||||||||||||
2642 | emit s->orientationChanged(s->orientation()); | - | ||||||||||||||||||
2643 | - | |||||||||||||||||||
2644 | QScreenOrientationChangeEvent event(s, s->orientation()); | - | ||||||||||||||||||
2645 | QCoreApplication::sendEvent(QCoreApplication::instance(), &event); | - | ||||||||||||||||||
2646 | } never executed: end of block | 0 | ||||||||||||||||||
2647 | - | |||||||||||||||||||
2648 | void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e) | - | ||||||||||||||||||
2649 | { | - | ||||||||||||||||||
2650 | // This operation only makes sense after the QGuiApplication constructor runs | - | ||||||||||||||||||
2651 | if (QCoreApplication::startingUp())
| 0 | ||||||||||||||||||
2652 | return; never executed: return; | 0 | ||||||||||||||||||
2653 | - | |||||||||||||||||||
2654 | if (!e->screen)
| 0 | ||||||||||||||||||
2655 | return; never executed: return; | 0 | ||||||||||||||||||
2656 | - | |||||||||||||||||||
2657 | QScreen *s = e->screen.data(); | - | ||||||||||||||||||
2658 | - | |||||||||||||||||||
2659 | bool geometryChanged = e->geometry != s->d_func()->geometry; | - | ||||||||||||||||||
2660 | s->d_func()->geometry = e->geometry; | - | ||||||||||||||||||
2661 | - | |||||||||||||||||||
2662 | bool availableGeometryChanged = e->availableGeometry != s->d_func()->availableGeometry; | - | ||||||||||||||||||
2663 | s->d_func()->availableGeometry = e->availableGeometry; | - | ||||||||||||||||||
2664 | - | |||||||||||||||||||
2665 | if (geometryChanged) {
| 0 | ||||||||||||||||||
2666 | Qt::ScreenOrientation primaryOrientation = s->primaryOrientation(); | - | ||||||||||||||||||
2667 | s->d_func()->updatePrimaryOrientation(); | - | ||||||||||||||||||
2668 | - | |||||||||||||||||||
2669 | emit s->geometryChanged(s->geometry()); | - | ||||||||||||||||||
2670 | emit s->physicalSizeChanged(s->physicalSize()); | - | ||||||||||||||||||
2671 | emit s->physicalDotsPerInchChanged(s->physicalDotsPerInch()); | - | ||||||||||||||||||
2672 | emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); | - | ||||||||||||||||||
2673 | - | |||||||||||||||||||
2674 | if (s->primaryOrientation() != primaryOrientation)
| 0 | ||||||||||||||||||
2675 | emit s->primaryOrientationChanged(s->primaryOrientation()); never executed: s->primaryOrientationChanged(s->primaryOrientation()); | 0 | ||||||||||||||||||
2676 | - | |||||||||||||||||||
2677 | if (s->d_func()->orientation == Qt::PrimaryOrientation)
| 0 | ||||||||||||||||||
2678 | updateFilteredScreenOrientation(s); never executed: updateFilteredScreenOrientation(s); | 0 | ||||||||||||||||||
2679 | } never executed: end of block | 0 | ||||||||||||||||||
2680 | - | |||||||||||||||||||
2681 | if (availableGeometryChanged)
| 0 | ||||||||||||||||||
2682 | emit s->availableGeometryChanged(s->availableGeometry()); never executed: s->availableGeometryChanged(s->availableGeometry()); | 0 | ||||||||||||||||||
2683 | - | |||||||||||||||||||
2684 | if (geometryChanged || availableGeometryChanged) {
| 0 | ||||||||||||||||||
2685 | foreach (QScreen* sibling, s->virtualSiblings()) | - | ||||||||||||||||||
2686 | emit sibling->virtualGeometryChanged(sibling->virtualGeometry()); never executed: sibling->virtualGeometryChanged(sibling->virtualGeometry()); | 0 | ||||||||||||||||||
2687 | } never executed: end of block | 0 | ||||||||||||||||||
2688 | } never executed: end of block | 0 | ||||||||||||||||||
2689 | - | |||||||||||||||||||
2690 | void QGuiApplicationPrivate::reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e) | - | ||||||||||||||||||
2691 | { | - | ||||||||||||||||||
2692 | // This operation only makes sense after the QGuiApplication constructor runs | - | ||||||||||||||||||
2693 | if (QCoreApplication::startingUp())
| 0 | ||||||||||||||||||
2694 | return; never executed: return; | 0 | ||||||||||||||||||
2695 | - | |||||||||||||||||||
2696 | if (!e->screen)
| 0 | ||||||||||||||||||
2697 | return; never executed: return; | 0 | ||||||||||||||||||
2698 | - | |||||||||||||||||||
2699 | QScreen *s = e->screen.data(); | - | ||||||||||||||||||
2700 | s->d_func()->logicalDpi = QDpi(e->dpiX, e->dpiY); | - | ||||||||||||||||||
2701 | - | |||||||||||||||||||
2702 | emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); | - | ||||||||||||||||||
2703 | } never executed: end of block | 0 | ||||||||||||||||||
2704 | - | |||||||||||||||||||
2705 | void QGuiApplicationPrivate::reportRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e) | - | ||||||||||||||||||
2706 | { | - | ||||||||||||||||||
2707 | // This operation only makes sense after the QGuiApplication constructor runs | - | ||||||||||||||||||
2708 | if (QCoreApplication::startingUp())
| 0 | ||||||||||||||||||
2709 | return; never executed: return; | 0 | ||||||||||||||||||
2710 | - | |||||||||||||||||||
2711 | if (!e->screen)
| 0 | ||||||||||||||||||
2712 | return; never executed: return; | 0 | ||||||||||||||||||
2713 | - | |||||||||||||||||||
2714 | QScreen *s = e->screen.data(); | - | ||||||||||||||||||
2715 | qreal rate = e->rate; | - | ||||||||||||||||||
2716 | // safeguard ourselves against buggy platform behavior... | - | ||||||||||||||||||
2717 | if (rate < 1.0)
| 0 | ||||||||||||||||||
2718 | rate = 60.0; never executed: rate = 60.0; | 0 | ||||||||||||||||||
2719 | if (!qFuzzyCompare(s->d_func()->refreshRate, rate)) {
| 0 | ||||||||||||||||||
2720 | s->d_func()->refreshRate = rate; | - | ||||||||||||||||||
2721 | emit s->refreshRateChanged(s->refreshRate()); | - | ||||||||||||||||||
2722 | } never executed: end of block | 0 | ||||||||||||||||||
2723 | } never executed: end of block | 0 | ||||||||||||||||||
2724 | - | |||||||||||||||||||
2725 | void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e) | - | ||||||||||||||||||
2726 | { | - | ||||||||||||||||||
2727 | if (!e->exposed)
| 0 | ||||||||||||||||||
2728 | return; never executed: return; | 0 | ||||||||||||||||||
2729 | - | |||||||||||||||||||
2730 | QWindow *window = e->exposed.data(); | - | ||||||||||||||||||
2731 | if (!window)
| 0 | ||||||||||||||||||
2732 | return; never executed: return; | 0 | ||||||||||||||||||
2733 | QWindowPrivate *p = qt_window_private(window); | - | ||||||||||||||||||
2734 | - | |||||||||||||||||||
2735 | if (!p->receivedExpose) {
| 0 | ||||||||||||||||||
2736 | if (p->resizeEventPending) {
| 0 | ||||||||||||||||||
2737 | // as a convenience for plugins, send a resize event before the first expose event if they haven't done so | - | ||||||||||||||||||
2738 | // window->geometry() should have a valid size as soon as a handle exists. | - | ||||||||||||||||||
2739 | QResizeEvent e(window->geometry().size(), p->geometry.size()); | - | ||||||||||||||||||
2740 | QGuiApplication::sendSpontaneousEvent(window, &e); | - | ||||||||||||||||||
2741 | - | |||||||||||||||||||
2742 | p->resizeEventPending = false; | - | ||||||||||||||||||
2743 | } never executed: end of block | 0 | ||||||||||||||||||
2744 | - | |||||||||||||||||||
2745 | p->receivedExpose = true; | - | ||||||||||||||||||
2746 | } never executed: end of block | 0 | ||||||||||||||||||
2747 | - | |||||||||||||||||||
2748 | p->exposed = e->isExposed && window->screen();
| 0 | ||||||||||||||||||
2749 | - | |||||||||||||||||||
2750 | QExposeEvent exposeEvent(e->region); | - | ||||||||||||||||||
2751 | QCoreApplication::sendSpontaneousEvent(window, &exposeEvent); | - | ||||||||||||||||||
2752 | } never executed: end of block | 0 | ||||||||||||||||||
2753 | - | |||||||||||||||||||
2754 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||
2755 | - | |||||||||||||||||||
2756 | QPlatformDragQtResponse QGuiApplicationPrivate::processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) | - | ||||||||||||||||||
2757 | { | - | ||||||||||||||||||
2758 | static QPointer<QWindow> currentDragWindow; | - | ||||||||||||||||||
2759 | static Qt::DropAction lastAcceptedDropAction = Qt::IgnoreAction; | - | ||||||||||||||||||
2760 | QPlatformDrag *platformDrag = platformIntegration()->drag(); | - | ||||||||||||||||||
2761 | if (!platformDrag) {
| 0 | ||||||||||||||||||
2762 | lastAcceptedDropAction = Qt::IgnoreAction; | - | ||||||||||||||||||
2763 | return QPlatformDragQtResponse(false, lastAcceptedDropAction, QRect()); never executed: return QPlatformDragQtResponse(false, lastAcceptedDropAction, QRect()); | 0 | ||||||||||||||||||
2764 | } | - | ||||||||||||||||||
2765 | - | |||||||||||||||||||
2766 | if (!dropData) {
| 0 | ||||||||||||||||||
2767 | if (currentDragWindow.data() == w)
| 0 | ||||||||||||||||||
2768 | currentDragWindow = 0; never executed: currentDragWindow = 0; | 0 | ||||||||||||||||||
2769 | QDragLeaveEvent e; | - | ||||||||||||||||||
2770 | QGuiApplication::sendEvent(w, &e); | - | ||||||||||||||||||
2771 | lastAcceptedDropAction = Qt::IgnoreAction; | - | ||||||||||||||||||
2772 | return QPlatformDragQtResponse(false, lastAcceptedDropAction, QRect()); never executed: return QPlatformDragQtResponse(false, lastAcceptedDropAction, QRect()); | 0 | ||||||||||||||||||
2773 | } | - | ||||||||||||||||||
2774 | QDragMoveEvent me(p, supportedActions, dropData, | - | ||||||||||||||||||
2775 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - | ||||||||||||||||||
2776 | - | |||||||||||||||||||
2777 | if (w != currentDragWindow) {
| 0 | ||||||||||||||||||
2778 | lastAcceptedDropAction = Qt::IgnoreAction; | - | ||||||||||||||||||
2779 | if (currentDragWindow) {
| 0 | ||||||||||||||||||
2780 | QDragLeaveEvent e; | - | ||||||||||||||||||
2781 | QGuiApplication::sendEvent(currentDragWindow, &e); | - | ||||||||||||||||||
2782 | } never executed: end of block | 0 | ||||||||||||||||||
2783 | currentDragWindow = w; | - | ||||||||||||||||||
2784 | QDragEnterEvent e(p, supportedActions, dropData, | - | ||||||||||||||||||
2785 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - | ||||||||||||||||||
2786 | QGuiApplication::sendEvent(w, &e); | - | ||||||||||||||||||
2787 | if (e.isAccepted() && e.dropAction() != Qt::IgnoreAction)
| 0 | ||||||||||||||||||
2788 | lastAcceptedDropAction = e.dropAction(); never executed: lastAcceptedDropAction = e.dropAction(); | 0 | ||||||||||||||||||
2789 | } never executed: end of block | 0 | ||||||||||||||||||
2790 | - | |||||||||||||||||||
2791 | // Handling 'DragEnter' should suffice for the application. | - | ||||||||||||||||||
2792 | if (lastAcceptedDropAction != Qt::IgnoreAction
| 0 | ||||||||||||||||||
2793 | && (supportedActions & lastAcceptedDropAction)) {
| 0 | ||||||||||||||||||
2794 | me.setDropAction(lastAcceptedDropAction); | - | ||||||||||||||||||
2795 | me.accept(); | - | ||||||||||||||||||
2796 | } never executed: end of block | 0 | ||||||||||||||||||
2797 | QGuiApplication::sendEvent(w, &me); | - | ||||||||||||||||||
2798 | lastAcceptedDropAction = me.isAccepted() ?
| 0 | ||||||||||||||||||
2799 | me.dropAction() : Qt::IgnoreAction; | - | ||||||||||||||||||
2800 | return QPlatformDragQtResponse(me.isAccepted(), lastAcceptedDropAction, me.answerRect()); never executed: return QPlatformDragQtResponse(me.isAccepted(), lastAcceptedDropAction, me.answerRect()); | 0 | ||||||||||||||||||
2801 | } | - | ||||||||||||||||||
2802 | - | |||||||||||||||||||
2803 | QPlatformDropQtResponse QGuiApplicationPrivate::processDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) | - | ||||||||||||||||||
2804 | { | - | ||||||||||||||||||
2805 | QDropEvent de(p, supportedActions, dropData, | - | ||||||||||||||||||
2806 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - | ||||||||||||||||||
2807 | QGuiApplication::sendEvent(w, &de); | - | ||||||||||||||||||
2808 | - | |||||||||||||||||||
2809 | Qt::DropAction acceptedAction = de.isAccepted() ? de.dropAction() : Qt::IgnoreAction;
| 0 | ||||||||||||||||||
2810 | QPlatformDropQtResponse response(de.isAccepted(),acceptedAction); | - | ||||||||||||||||||
2811 | return response; never executed: return response; | 0 | ||||||||||||||||||
2812 | } | - | ||||||||||||||||||
2813 | - | |||||||||||||||||||
2814 | #endif // QT_NO_DRAGANDDROP | - | ||||||||||||||||||
2815 | - | |||||||||||||||||||
2816 | #ifndef QT_NO_CLIPBOARD | - | ||||||||||||||||||
2817 | /*! | - | ||||||||||||||||||
2818 | Returns the object for interacting with the clipboard. | - | ||||||||||||||||||
2819 | */ | - | ||||||||||||||||||
2820 | QClipboard * QGuiApplication::clipboard() | - | ||||||||||||||||||
2821 | { | - | ||||||||||||||||||
2822 | if (QGuiApplicationPrivate::qt_clipboard == 0) {
| 0 | ||||||||||||||||||
2823 | if (!qApp) {
| 0 | ||||||||||||||||||
2824 | qWarning("QGuiApplication: Must construct a QGuiApplication before accessing a QClipboard"); | - | ||||||||||||||||||
2825 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
2826 | } | - | ||||||||||||||||||
2827 | QGuiApplicationPrivate::qt_clipboard = new QClipboard(0); | - | ||||||||||||||||||
2828 | } never executed: end of block | 0 | ||||||||||||||||||
2829 | return QGuiApplicationPrivate::qt_clipboard; never executed: return QGuiApplicationPrivate::qt_clipboard; | 0 | ||||||||||||||||||
2830 | } | - | ||||||||||||||||||
2831 | #endif | - | ||||||||||||||||||
2832 | - | |||||||||||||||||||
2833 | /*! | - | ||||||||||||||||||
2834 | \since 5.4 | - | ||||||||||||||||||
2835 | \fn void QGuiApplication::paletteChanged(const QPalette &palette) | - | ||||||||||||||||||
2836 | - | |||||||||||||||||||
2837 | This signal is emitted when the \a palette of the application changes. | - | ||||||||||||||||||
2838 | - | |||||||||||||||||||
2839 | \sa palette() | - | ||||||||||||||||||
2840 | */ | - | ||||||||||||||||||
2841 | - | |||||||||||||||||||
2842 | /*! | - | ||||||||||||||||||
2843 | Returns the default application palette. | - | ||||||||||||||||||
2844 | - | |||||||||||||||||||
2845 | \sa setPalette() | - | ||||||||||||||||||
2846 | */ | - | ||||||||||||||||||
2847 | - | |||||||||||||||||||
2848 | QPalette QGuiApplication::palette() | - | ||||||||||||||||||
2849 | { | - | ||||||||||||||||||
2850 | initPalette(); | - | ||||||||||||||||||
2851 | return *QGuiApplicationPrivate::app_pal; never executed: return *QGuiApplicationPrivate::app_pal; | 0 | ||||||||||||||||||
2852 | } | - | ||||||||||||||||||
2853 | - | |||||||||||||||||||
2854 | /*! | - | ||||||||||||||||||
2855 | Changes the default application palette to \a pal. | - | ||||||||||||||||||
2856 | - | |||||||||||||||||||
2857 | \sa palette() | - | ||||||||||||||||||
2858 | */ | - | ||||||||||||||||||
2859 | void QGuiApplication::setPalette(const QPalette &pal) | - | ||||||||||||||||||
2860 | { | - | ||||||||||||||||||
2861 | if (QGuiApplicationPrivate::app_pal && pal.isCopyOf(*QGuiApplicationPrivate::app_pal))
| 0 | ||||||||||||||||||
2862 | return; never executed: return; | 0 | ||||||||||||||||||
2863 | if (!QGuiApplicationPrivate::app_pal)
| 0 | ||||||||||||||||||
2864 | QGuiApplicationPrivate::app_pal = new QPalette(pal); never executed: QGuiApplicationPrivate::app_pal = new QPalette(pal); | 0 | ||||||||||||||||||
2865 | else | - | ||||||||||||||||||
2866 | *QGuiApplicationPrivate::app_pal = pal; never executed: *QGuiApplicationPrivate::app_pal = pal; | 0 | ||||||||||||||||||
2867 | applicationResourceFlags |= ApplicationPaletteExplicitlySet; | - | ||||||||||||||||||
2868 | QCoreApplication::setAttribute(Qt::AA_SetPalette); | - | ||||||||||||||||||
2869 | emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); | - | ||||||||||||||||||
2870 | } never executed: end of block | 0 | ||||||||||||||||||
2871 | - | |||||||||||||||||||
2872 | void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) | - | ||||||||||||||||||
2873 | { | - | ||||||||||||||||||
2874 | windowGeometrySpecification.applyTo(window); | - | ||||||||||||||||||
2875 | } never executed: end of block | 0 | ||||||||||||||||||
2876 | - | |||||||||||||||||||
2877 | /*! | - | ||||||||||||||||||
2878 | Returns the default application font. | - | ||||||||||||||||||
2879 | - | |||||||||||||||||||
2880 | \sa setFont() | - | ||||||||||||||||||
2881 | */ | - | ||||||||||||||||||
2882 | QFont QGuiApplication::font() | - | ||||||||||||||||||
2883 | { | - | ||||||||||||||||||
2884 | Q_ASSERT_X(QGuiApplicationPrivate::self, "QGuiApplication::font()", "no QGuiApplication instance"); | - | ||||||||||||||||||
2885 | QMutexLocker locker(&applicationFontMutex); | - | ||||||||||||||||||
2886 | initFontUnlocked(); | - | ||||||||||||||||||
2887 | return *QGuiApplicationPrivate::app_font; never executed: return *QGuiApplicationPrivate::app_font; | 0 | ||||||||||||||||||
2888 | } | - | ||||||||||||||||||
2889 | - | |||||||||||||||||||
2890 | /*! | - | ||||||||||||||||||
2891 | Changes the default application font to \a font. | - | ||||||||||||||||||
2892 | - | |||||||||||||||||||
2893 | \sa font() | - | ||||||||||||||||||
2894 | */ | - | ||||||||||||||||||
2895 | void QGuiApplication::setFont(const QFont &font) | - | ||||||||||||||||||
2896 | { | - | ||||||||||||||||||
2897 | QMutexLocker locker(&applicationFontMutex); | - | ||||||||||||||||||
2898 | if (!QGuiApplicationPrivate::app_font)
| 0 | ||||||||||||||||||
2899 | QGuiApplicationPrivate::app_font = new QFont(font); never executed: QGuiApplicationPrivate::app_font = new QFont(font); | 0 | ||||||||||||||||||
2900 | else | - | ||||||||||||||||||
2901 | *QGuiApplicationPrivate::app_font = font; never executed: *QGuiApplicationPrivate::app_font = font; | 0 | ||||||||||||||||||
2902 | applicationResourceFlags |= ApplicationFontExplicitlySet; | - | ||||||||||||||||||
2903 | } never executed: end of block | 0 | ||||||||||||||||||
2904 | - | |||||||||||||||||||
2905 | /*! | - | ||||||||||||||||||
2906 | \fn bool QGuiApplication::isRightToLeft() | - | ||||||||||||||||||
2907 | - | |||||||||||||||||||
2908 | Returns \c true if the application's layout direction is | - | ||||||||||||||||||
2909 | Qt::RightToLeft; otherwise returns \c false. | - | ||||||||||||||||||
2910 | - | |||||||||||||||||||
2911 | \sa layoutDirection(), isLeftToRight() | - | ||||||||||||||||||
2912 | */ | - | ||||||||||||||||||
2913 | - | |||||||||||||||||||
2914 | /*! | - | ||||||||||||||||||
2915 | \fn bool QGuiApplication::isLeftToRight() | - | ||||||||||||||||||
2916 | - | |||||||||||||||||||
2917 | Returns \c true if the application's layout direction is | - | ||||||||||||||||||
2918 | Qt::LeftToRight; otherwise returns \c false. | - | ||||||||||||||||||
2919 | - | |||||||||||||||||||
2920 | \sa layoutDirection(), isRightToLeft() | - | ||||||||||||||||||
2921 | */ | - | ||||||||||||||||||
2922 | - | |||||||||||||||||||
2923 | void QGuiApplicationPrivate::notifyLayoutDirectionChange() | - | ||||||||||||||||||
2924 | { | - | ||||||||||||||||||
2925 | const QWindowList list = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
2926 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||
2927 | QEvent ev(QEvent::ApplicationLayoutDirectionChange); | - | ||||||||||||||||||
2928 | QCoreApplication::sendEvent(list.at(i), &ev); | - | ||||||||||||||||||
2929 | } never executed: end of block | 0 | ||||||||||||||||||
2930 | } never executed: end of block | 0 | ||||||||||||||||||
2931 | - | |||||||||||||||||||
2932 | void QGuiApplicationPrivate::notifyActiveWindowChange(QWindow *) | - | ||||||||||||||||||
2933 | { | - | ||||||||||||||||||
2934 | } | - | ||||||||||||||||||
2935 | - | |||||||||||||||||||
2936 | /*! | - | ||||||||||||||||||
2937 | \property QGuiApplication::windowIcon | - | ||||||||||||||||||
2938 | \brief the default window icon | - | ||||||||||||||||||
2939 | - | |||||||||||||||||||
2940 | \sa QWindow::setIcon(), {Setting the Application Icon} | - | ||||||||||||||||||
2941 | */ | - | ||||||||||||||||||
2942 | QIcon QGuiApplication::windowIcon() | - | ||||||||||||||||||
2943 | { | - | ||||||||||||||||||
2944 | return QGuiApplicationPrivate::app_icon ? *QGuiApplicationPrivate::app_icon : QIcon(); never executed: return QGuiApplicationPrivate::app_icon ? *QGuiApplicationPrivate::app_icon : QIcon();
| 0 | ||||||||||||||||||
2945 | } | - | ||||||||||||||||||
2946 | - | |||||||||||||||||||
2947 | void QGuiApplication::setWindowIcon(const QIcon &icon) | - | ||||||||||||||||||
2948 | { | - | ||||||||||||||||||
2949 | if (!QGuiApplicationPrivate::app_icon)
| 0 | ||||||||||||||||||
2950 | QGuiApplicationPrivate::app_icon = new QIcon(); never executed: QGuiApplicationPrivate::app_icon = new QIcon(); | 0 | ||||||||||||||||||
2951 | *QGuiApplicationPrivate::app_icon = icon; | - | ||||||||||||||||||
2952 | if (QGuiApplicationPrivate::platform_integration
| 0 | ||||||||||||||||||
2953 | && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::ApplicationIcon))
| 0 | ||||||||||||||||||
2954 | QGuiApplicationPrivate::platform_integration->setApplicationIcon(icon); never executed: QGuiApplicationPrivate::platform_integration->setApplicationIcon(icon); | 0 | ||||||||||||||||||
2955 | if (QGuiApplicationPrivate::is_app_running && !QGuiApplicationPrivate::is_app_closing)
| 0 | ||||||||||||||||||
2956 | QGuiApplicationPrivate::self->notifyWindowIconChanged(); never executed: QGuiApplicationPrivate::self->notifyWindowIconChanged(); | 0 | ||||||||||||||||||
2957 | } never executed: end of block | 0 | ||||||||||||||||||
2958 | - | |||||||||||||||||||
2959 | void QGuiApplicationPrivate::notifyWindowIconChanged() | - | ||||||||||||||||||
2960 | { | - | ||||||||||||||||||
2961 | QEvent ev(QEvent::ApplicationWindowIconChange); | - | ||||||||||||||||||
2962 | const QWindowList list = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
2963 | for (int i = 0; i < list.size(); ++i)
| 0 | ||||||||||||||||||
2964 | QCoreApplication::sendEvent(list.at(i), &ev); never executed: QCoreApplication::sendEvent(list.at(i), &ev); | 0 | ||||||||||||||||||
2965 | } never executed: end of block | 0 | ||||||||||||||||||
2966 | - | |||||||||||||||||||
2967 | - | |||||||||||||||||||
2968 | - | |||||||||||||||||||
2969 | /*! | - | ||||||||||||||||||
2970 | \property QGuiApplication::quitOnLastWindowClosed | - | ||||||||||||||||||
2971 | - | |||||||||||||||||||
2972 | \brief whether the application implicitly quits when the last window is | - | ||||||||||||||||||
2973 | closed. | - | ||||||||||||||||||
2974 | - | |||||||||||||||||||
2975 | The default is \c true. | - | ||||||||||||||||||
2976 | - | |||||||||||||||||||
2977 | If this property is \c true, the applications quits when the last visible | - | ||||||||||||||||||
2978 | primary window (i.e. window with no parent) is closed. | - | ||||||||||||||||||
2979 | - | |||||||||||||||||||
2980 | \sa quit(), QWindow::close() | - | ||||||||||||||||||
2981 | */ | - | ||||||||||||||||||
2982 | - | |||||||||||||||||||
2983 | void QGuiApplication::setQuitOnLastWindowClosed(bool quit) | - | ||||||||||||||||||
2984 | { | - | ||||||||||||||||||
2985 | QCoreApplication::setQuitLockEnabled(quit); | - | ||||||||||||||||||
2986 | } never executed: end of block | 0 | ||||||||||||||||||
2987 | - | |||||||||||||||||||
2988 | - | |||||||||||||||||||
2989 | - | |||||||||||||||||||
2990 | bool QGuiApplication::quitOnLastWindowClosed() | - | ||||||||||||||||||
2991 | { | - | ||||||||||||||||||
2992 | return QCoreApplication::isQuitLockEnabled(); never executed: return QCoreApplication::isQuitLockEnabled(); | 0 | ||||||||||||||||||
2993 | } | - | ||||||||||||||||||
2994 | - | |||||||||||||||||||
2995 | - | |||||||||||||||||||
2996 | /*! | - | ||||||||||||||||||
2997 | \fn void QGuiApplication::lastWindowClosed() | - | ||||||||||||||||||
2998 | - | |||||||||||||||||||
2999 | This signal is emitted from exec() when the last visible | - | ||||||||||||||||||
3000 | primary window (i.e. window with no parent) is closed. | - | ||||||||||||||||||
3001 | - | |||||||||||||||||||
3002 | By default, QGuiApplication quits after this signal is emitted. This feature | - | ||||||||||||||||||
3003 | can be turned off by setting \l quitOnLastWindowClosed to \c false. | - | ||||||||||||||||||
3004 | - | |||||||||||||||||||
3005 | \sa QWindow::close(), QWindow::isTopLevel() | - | ||||||||||||||||||
3006 | */ | - | ||||||||||||||||||
3007 | - | |||||||||||||||||||
3008 | void QGuiApplicationPrivate::emitLastWindowClosed() | - | ||||||||||||||||||
3009 | { | - | ||||||||||||||||||
3010 | if (qGuiApp && qGuiApp->d_func()->in_exec) {
| 0 | ||||||||||||||||||
3011 | emit qGuiApp->lastWindowClosed(); | - | ||||||||||||||||||
3012 | } never executed: end of block | 0 | ||||||||||||||||||
3013 | } never executed: end of block | 0 | ||||||||||||||||||
3014 | - | |||||||||||||||||||
3015 | bool QGuiApplicationPrivate::shouldQuit() | - | ||||||||||||||||||
3016 | { | - | ||||||||||||||||||
3017 | const QWindowList processedWindows; | - | ||||||||||||||||||
3018 | return shouldQuitInternal(processedWindows); never executed: return shouldQuitInternal(processedWindows); | 0 | ||||||||||||||||||
3019 | } | - | ||||||||||||||||||
3020 | - | |||||||||||||||||||
3021 | bool QGuiApplicationPrivate::shouldQuitInternal(const QWindowList &processedWindows) | - | ||||||||||||||||||
3022 | { | - | ||||||||||||||||||
3023 | /* if there is no visible top-level window left, we allow the quit */ | - | ||||||||||||||||||
3024 | QWindowList list = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
3025 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||
3026 | QWindow *w = list.at(i); | - | ||||||||||||||||||
3027 | if (processedWindows.contains(w))
| 0 | ||||||||||||||||||
3028 | continue; never executed: continue; | 0 | ||||||||||||||||||
3029 | if (w->isVisible() && !w->transientParent())
| 0 | ||||||||||||||||||
3030 | return false; never executed: return false; | 0 | ||||||||||||||||||
3031 | } never executed: end of block | 0 | ||||||||||||||||||
3032 | return true; never executed: return true; | 0 | ||||||||||||||||||
3033 | } | - | ||||||||||||||||||
3034 | - | |||||||||||||||||||
3035 | bool QGuiApplicationPrivate::tryCloseAllWindows() | - | ||||||||||||||||||
3036 | { | - | ||||||||||||||||||
3037 | return tryCloseRemainingWindows(QWindowList()); never executed: return tryCloseRemainingWindows(QWindowList()); | 0 | ||||||||||||||||||
3038 | } | - | ||||||||||||||||||
3039 | - | |||||||||||||||||||
3040 | bool QGuiApplicationPrivate::tryCloseRemainingWindows(QWindowList processedWindows) | - | ||||||||||||||||||
3041 | { | - | ||||||||||||||||||
3042 | QWindowList list = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
3043 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||
3044 | QWindow *w = list.at(i); | - | ||||||||||||||||||
3045 | if (w->isVisible() && !processedWindows.contains(w)) {
| 0 | ||||||||||||||||||
3046 | if (!w->close())
| 0 | ||||||||||||||||||
3047 | return false; never executed: return false; | 0 | ||||||||||||||||||
3048 | processedWindows.append(w); | - | ||||||||||||||||||
3049 | list = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
3050 | i = -1; | - | ||||||||||||||||||
3051 | } never executed: end of block | 0 | ||||||||||||||||||
3052 | } never executed: end of block | 0 | ||||||||||||||||||
3053 | return true; never executed: return true; | 0 | ||||||||||||||||||
3054 | } | - | ||||||||||||||||||
3055 | - | |||||||||||||||||||
3056 | /*! | - | ||||||||||||||||||
3057 | \since 5.2 | - | ||||||||||||||||||
3058 | \fn Qt::ApplicationState QGuiApplication::applicationState() | - | ||||||||||||||||||
3059 | - | |||||||||||||||||||
3060 | - | |||||||||||||||||||
3061 | Returns the current state of the application. | - | ||||||||||||||||||
3062 | - | |||||||||||||||||||
3063 | You can react to application state changes to perform actions such as | - | ||||||||||||||||||
3064 | stopping/resuming CPU-intensive tasks, freeing/loading resources or | - | ||||||||||||||||||
3065 | saving/restoring application data. | - | ||||||||||||||||||
3066 | */ | - | ||||||||||||||||||
3067 | - | |||||||||||||||||||
3068 | Qt::ApplicationState QGuiApplication::applicationState() | - | ||||||||||||||||||
3069 | { | - | ||||||||||||||||||
3070 | return QGuiApplicationPrivate::applicationState; never executed: return QGuiApplicationPrivate::applicationState; | 0 | ||||||||||||||||||
3071 | } | - | ||||||||||||||||||
3072 | - | |||||||||||||||||||
3073 | /*! | - | ||||||||||||||||||
3074 | \since 5.2 | - | ||||||||||||||||||
3075 | \fn void QGuiApplication::applicationStateChanged(Qt::ApplicationState state) | - | ||||||||||||||||||
3076 | - | |||||||||||||||||||
3077 | This signal is emitted when the \a state of the application changes. | - | ||||||||||||||||||
3078 | - | |||||||||||||||||||
3079 | \sa applicationState() | - | ||||||||||||||||||
3080 | */ | - | ||||||||||||||||||
3081 | - | |||||||||||||||||||
3082 | void QGuiApplicationPrivate::setApplicationState(Qt::ApplicationState state, bool forcePropagate) | - | ||||||||||||||||||
3083 | { | - | ||||||||||||||||||
3084 | if ((applicationState == state) && !forcePropagate)
| 0 | ||||||||||||||||||
3085 | return; never executed: return; | 0 | ||||||||||||||||||
3086 | - | |||||||||||||||||||
3087 | applicationState = state; | - | ||||||||||||||||||
3088 | - | |||||||||||||||||||
3089 | switch (state) { | - | ||||||||||||||||||
3090 | case Qt::ApplicationActive: { never executed: case Qt::ApplicationActive: | 0 | ||||||||||||||||||
3091 | QEvent appActivate(QEvent::ApplicationActivate); | - | ||||||||||||||||||
3092 | QCoreApplication::sendSpontaneousEvent(qApp, &appActivate); | - | ||||||||||||||||||
3093 | break; } never executed: break; | 0 | ||||||||||||||||||
3094 | case Qt::ApplicationInactive: { never executed: case Qt::ApplicationInactive: | 0 | ||||||||||||||||||
3095 | QEvent appDeactivate(QEvent::ApplicationDeactivate); | - | ||||||||||||||||||
3096 | QCoreApplication::sendSpontaneousEvent(qApp, &appDeactivate); | - | ||||||||||||||||||
3097 | break; } never executed: break; | 0 | ||||||||||||||||||
3098 | default: never executed: default: | 0 | ||||||||||||||||||
3099 | break; never executed: break; | 0 | ||||||||||||||||||
3100 | } | - | ||||||||||||||||||
3101 | - | |||||||||||||||||||
3102 | QApplicationStateChangeEvent event(applicationState); | - | ||||||||||||||||||
3103 | QCoreApplication::sendSpontaneousEvent(qApp, &event); | - | ||||||||||||||||||
3104 | - | |||||||||||||||||||
3105 | emit qApp->applicationStateChanged(applicationState); | - | ||||||||||||||||||
3106 | } never executed: end of block | 0 | ||||||||||||||||||
3107 | - | |||||||||||||||||||
3108 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
3109 | // ### Qt6: consider removing the feature or making it less intrusive | - | ||||||||||||||||||
3110 | /*! | - | ||||||||||||||||||
3111 | \since 5.6 | - | ||||||||||||||||||
3112 | - | |||||||||||||||||||
3113 | Returns whether QGuiApplication will use fallback session management. | - | ||||||||||||||||||
3114 | - | |||||||||||||||||||
3115 | The default is \c true. | - | ||||||||||||||||||
3116 | - | |||||||||||||||||||
3117 | If this is \c true and the session manager allows user interaction, | - | ||||||||||||||||||
3118 | QGuiApplication will try to close toplevel windows after | - | ||||||||||||||||||
3119 | commitDataRequest() has been emitted. If a window cannot be closed, session | - | ||||||||||||||||||
3120 | shutdown will be canceled and the application will keep running. | - | ||||||||||||||||||
3121 | - | |||||||||||||||||||
3122 | Fallback session management only benefits applications that have an | - | ||||||||||||||||||
3123 | "are you sure you want to close this window?" feature or other logic that | - | ||||||||||||||||||
3124 | prevents closing a toplevel window depending on certain conditions, and | - | ||||||||||||||||||
3125 | that do nothing to explicitly implement session management. In applications | - | ||||||||||||||||||
3126 | that \e do implement session management using the proper session management | - | ||||||||||||||||||
3127 | API, fallback session management interferes and may break session | - | ||||||||||||||||||
3128 | management logic. | - | ||||||||||||||||||
3129 | - | |||||||||||||||||||
3130 | \warning If all windows \e are closed due to fallback session management | - | ||||||||||||||||||
3131 | and quitOnLastWindowClosed() is \c true, the application will quit before | - | ||||||||||||||||||
3132 | it is explicitly instructed to quit through the platform's session | - | ||||||||||||||||||
3133 | management protocol. That violation of protocol may prevent the platform | - | ||||||||||||||||||
3134 | session manager from saving application state. | - | ||||||||||||||||||
3135 | - | |||||||||||||||||||
3136 | \sa setFallbackSessionManagementEnabled(), | - | ||||||||||||||||||
3137 | QSessionManager::allowsInteraction(), saveStateRequest(), | - | ||||||||||||||||||
3138 | commitDataRequest(), {Session Management} | - | ||||||||||||||||||
3139 | */ | - | ||||||||||||||||||
3140 | bool QGuiApplication::isFallbackSessionManagementEnabled() | - | ||||||||||||||||||
3141 | { | - | ||||||||||||||||||
3142 | return QGuiApplicationPrivate::is_fallback_session_management_enabled; never executed: return QGuiApplicationPrivate::is_fallback_session_management_enabled; | 0 | ||||||||||||||||||
3143 | } | - | ||||||||||||||||||
3144 | - | |||||||||||||||||||
3145 | /*! | - | ||||||||||||||||||
3146 | \since 5.6 | - | ||||||||||||||||||
3147 | - | |||||||||||||||||||
3148 | Sets whether QGuiApplication will use fallback session management to | - | ||||||||||||||||||
3149 | \a enabled. | - | ||||||||||||||||||
3150 | - | |||||||||||||||||||
3151 | \sa isFallbackSessionManagementEnabled() | - | ||||||||||||||||||
3152 | */ | - | ||||||||||||||||||
3153 | void QGuiApplication::setFallbackSessionManagementEnabled(bool enabled) | - | ||||||||||||||||||
3154 | { | - | ||||||||||||||||||
3155 | QGuiApplicationPrivate::is_fallback_session_management_enabled = enabled; | - | ||||||||||||||||||
3156 | } never executed: end of block | 0 | ||||||||||||||||||
3157 | #endif // QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
3158 | - | |||||||||||||||||||
3159 | /*! | - | ||||||||||||||||||
3160 | \since 4.2 | - | ||||||||||||||||||
3161 | \fn void QGuiApplication::commitDataRequest(QSessionManager &manager) | - | ||||||||||||||||||
3162 | - | |||||||||||||||||||
3163 | This signal deals with \l{Session Management}{session management}. It is | - | ||||||||||||||||||
3164 | emitted when the QSessionManager wants the application to commit all its | - | ||||||||||||||||||
3165 | data. | - | ||||||||||||||||||
3166 | - | |||||||||||||||||||
3167 | Usually this means saving all open files, after getting permission from | - | ||||||||||||||||||
3168 | the user. Furthermore you may want to provide a means by which the user | - | ||||||||||||||||||
3169 | can cancel the shutdown. | - | ||||||||||||||||||
3170 | - | |||||||||||||||||||
3171 | You should not exit the application within this signal. Instead, | - | ||||||||||||||||||
3172 | the session manager may or may not do this afterwards, depending on the | - | ||||||||||||||||||
3173 | context. | - | ||||||||||||||||||
3174 | - | |||||||||||||||||||
3175 | \warning Within this signal, no user interaction is possible, \e | - | ||||||||||||||||||
3176 | unless you ask the \a manager for explicit permission. See | - | ||||||||||||||||||
3177 | QSessionManager::allowsInteraction() and | - | ||||||||||||||||||
3178 | QSessionManager::allowsErrorInteraction() for details and example | - | ||||||||||||||||||
3179 | usage. | - | ||||||||||||||||||
3180 | - | |||||||||||||||||||
3181 | \note You should use Qt::DirectConnection when connecting to this signal. | - | ||||||||||||||||||
3182 | - | |||||||||||||||||||
3183 | \sa setFallbackSessionManagementEnabled(), isSessionRestored(), | - | ||||||||||||||||||
3184 | sessionId(), saveStateRequest(), {Session Management} | - | ||||||||||||||||||
3185 | */ | - | ||||||||||||||||||
3186 | - | |||||||||||||||||||
3187 | /*! | - | ||||||||||||||||||
3188 | \since 4.2 | - | ||||||||||||||||||
3189 | \fn void QGuiApplication::saveStateRequest(QSessionManager &manager) | - | ||||||||||||||||||
3190 | - | |||||||||||||||||||
3191 | This signal deals with \l{Session Management}{session management}. It is | - | ||||||||||||||||||
3192 | invoked when the \l{QSessionManager}{session manager} wants the application | - | ||||||||||||||||||
3193 | to preserve its state for a future session. | - | ||||||||||||||||||
3194 | - | |||||||||||||||||||
3195 | For example, a text editor would create a temporary file that includes the | - | ||||||||||||||||||
3196 | current contents of its edit buffers, the location of the cursor and other | - | ||||||||||||||||||
3197 | aspects of the current editing session. | - | ||||||||||||||||||
3198 | - | |||||||||||||||||||
3199 | You should never exit the application within this signal. Instead, the | - | ||||||||||||||||||
3200 | session manager may or may not do this afterwards, depending on the | - | ||||||||||||||||||
3201 | context. Futhermore, most session managers will very likely request a saved | - | ||||||||||||||||||
3202 | state immediately after the application has been started. This permits the | - | ||||||||||||||||||
3203 | session manager to learn about the application's restart policy. | - | ||||||||||||||||||
3204 | - | |||||||||||||||||||
3205 | \warning Within this signal, no user interaction is possible, \e | - | ||||||||||||||||||
3206 | unless you ask the \a manager for explicit permission. See | - | ||||||||||||||||||
3207 | QSessionManager::allowsInteraction() and | - | ||||||||||||||||||
3208 | QSessionManager::allowsErrorInteraction() for details. | - | ||||||||||||||||||
3209 | - | |||||||||||||||||||
3210 | \note You should use Qt::DirectConnection when connecting to this signal. | - | ||||||||||||||||||
3211 | - | |||||||||||||||||||
3212 | \sa isSessionRestored(), sessionId(), commitDataRequest(), {Session Management} | - | ||||||||||||||||||
3213 | */ | - | ||||||||||||||||||
3214 | - | |||||||||||||||||||
3215 | /*! | - | ||||||||||||||||||
3216 | \fn bool QGuiApplication::isSessionRestored() const | - | ||||||||||||||||||
3217 | - | |||||||||||||||||||
3218 | Returns \c true if the application has been restored from an earlier | - | ||||||||||||||||||
3219 | \l{Session Management}{session}; otherwise returns \c false. | - | ||||||||||||||||||
3220 | - | |||||||||||||||||||
3221 | \sa sessionId(), commitDataRequest(), saveStateRequest() | - | ||||||||||||||||||
3222 | */ | - | ||||||||||||||||||
3223 | - | |||||||||||||||||||
3224 | /*! | - | ||||||||||||||||||
3225 | \since 5.0 | - | ||||||||||||||||||
3226 | \fn bool QGuiApplication::isSavingSession() const | - | ||||||||||||||||||
3227 | - | |||||||||||||||||||
3228 | Returns \c true if the application is currently saving the | - | ||||||||||||||||||
3229 | \l{Session Management}{session}; otherwise returns \c false. | - | ||||||||||||||||||
3230 | - | |||||||||||||||||||
3231 | This is \c true when commitDataRequest() and saveStateRequest() are emitted, | - | ||||||||||||||||||
3232 | but also when the windows are closed afterwards by session management. | - | ||||||||||||||||||
3233 | - | |||||||||||||||||||
3234 | \sa sessionId(), commitDataRequest(), saveStateRequest() | - | ||||||||||||||||||
3235 | */ | - | ||||||||||||||||||
3236 | - | |||||||||||||||||||
3237 | /*! | - | ||||||||||||||||||
3238 | \fn QString QGuiApplication::sessionId() const | - | ||||||||||||||||||
3239 | - | |||||||||||||||||||
3240 | Returns the current \l{Session Management}{session's} identifier. | - | ||||||||||||||||||
3241 | - | |||||||||||||||||||
3242 | If the application has been restored from an earlier session, this | - | ||||||||||||||||||
3243 | identifier is the same as it was in that previous session. The session | - | ||||||||||||||||||
3244 | identifier is guaranteed to be unique both for different applications | - | ||||||||||||||||||
3245 | and for different instances of the same application. | - | ||||||||||||||||||
3246 | - | |||||||||||||||||||
3247 | \sa isSessionRestored(), sessionKey(), commitDataRequest(), saveStateRequest() | - | ||||||||||||||||||
3248 | */ | - | ||||||||||||||||||
3249 | - | |||||||||||||||||||
3250 | /*! | - | ||||||||||||||||||
3251 | \fn QString QGuiApplication::sessionKey() const | - | ||||||||||||||||||
3252 | - | |||||||||||||||||||
3253 | Returns the session key in the current \l{Session Management}{session}. | - | ||||||||||||||||||
3254 | - | |||||||||||||||||||
3255 | If the application has been restored from an earlier session, this key is | - | ||||||||||||||||||
3256 | the same as it was when the previous session ended. | - | ||||||||||||||||||
3257 | - | |||||||||||||||||||
3258 | The session key changes every time the session is saved. If the shutdown process | - | ||||||||||||||||||
3259 | is cancelled, another session key will be used when shutting down again. | - | ||||||||||||||||||
3260 | - | |||||||||||||||||||
3261 | \sa isSessionRestored(), sessionId(), commitDataRequest(), saveStateRequest() | - | ||||||||||||||||||
3262 | */ | - | ||||||||||||||||||
3263 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
3264 | bool QGuiApplication::isSessionRestored() const | - | ||||||||||||||||||
3265 | { | - | ||||||||||||||||||
3266 | Q_D(const QGuiApplication); | - | ||||||||||||||||||
3267 | return d->is_session_restored; never executed: return d->is_session_restored; | 0 | ||||||||||||||||||
3268 | } | - | ||||||||||||||||||
3269 | - | |||||||||||||||||||
3270 | QString QGuiApplication::sessionId() const | - | ||||||||||||||||||
3271 | { | - | ||||||||||||||||||
3272 | Q_D(const QGuiApplication); | - | ||||||||||||||||||
3273 | return d->session_manager->sessionId(); never executed: return d->session_manager->sessionId(); | 0 | ||||||||||||||||||
3274 | } | - | ||||||||||||||||||
3275 | - | |||||||||||||||||||
3276 | QString QGuiApplication::sessionKey() const | - | ||||||||||||||||||
3277 | { | - | ||||||||||||||||||
3278 | Q_D(const QGuiApplication); | - | ||||||||||||||||||
3279 | return d->session_manager->sessionKey(); never executed: return d->session_manager->sessionKey(); | 0 | ||||||||||||||||||
3280 | } | - | ||||||||||||||||||
3281 | - | |||||||||||||||||||
3282 | bool QGuiApplication::isSavingSession() const | - | ||||||||||||||||||
3283 | { | - | ||||||||||||||||||
3284 | Q_D(const QGuiApplication); | - | ||||||||||||||||||
3285 | return d->is_saving_session; never executed: return d->is_saving_session; | 0 | ||||||||||||||||||
3286 | } | - | ||||||||||||||||||
3287 | - | |||||||||||||||||||
3288 | void QGuiApplicationPrivate::commitData() | - | ||||||||||||||||||
3289 | { | - | ||||||||||||||||||
3290 | Q_Q(QGuiApplication); | - | ||||||||||||||||||
3291 | is_saving_session = true; | - | ||||||||||||||||||
3292 | - | |||||||||||||||||||
3293 | emit q->commitDataRequest(*session_manager); | - | ||||||||||||||||||
3294 | if (is_fallback_session_management_enabled && session_manager->allowsInteraction()
| 0 | ||||||||||||||||||
3295 | && !tryCloseAllWindows()) {
| 0 | ||||||||||||||||||
3296 | session_manager->cancel(); | - | ||||||||||||||||||
3297 | } never executed: end of block | 0 | ||||||||||||||||||
3298 | - | |||||||||||||||||||
3299 | is_saving_session = false; | - | ||||||||||||||||||
3300 | } never executed: end of block | 0 | ||||||||||||||||||
3301 | - | |||||||||||||||||||
3302 | - | |||||||||||||||||||
3303 | void QGuiApplicationPrivate::saveState() | - | ||||||||||||||||||
3304 | { | - | ||||||||||||||||||
3305 | Q_Q(QGuiApplication); | - | ||||||||||||||||||
3306 | is_saving_session = true; | - | ||||||||||||||||||
3307 | emit q->saveStateRequest(*session_manager); | - | ||||||||||||||||||
3308 | is_saving_session = false; | - | ||||||||||||||||||
3309 | } never executed: end of block | 0 | ||||||||||||||||||
3310 | #endif //QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
3311 | - | |||||||||||||||||||
3312 | /*! | - | ||||||||||||||||||
3313 | \since 5.2 | - | ||||||||||||||||||
3314 | - | |||||||||||||||||||
3315 | Function that can be used to sync Qt state with the Window Systems state. | - | ||||||||||||||||||
3316 | - | |||||||||||||||||||
3317 | This function will first empty Qts events by calling QCoreApplication::processEvents(), | - | ||||||||||||||||||
3318 | then the platform plugin will sync up with the windowsystem, and finally Qts events | - | ||||||||||||||||||
3319 | will be delived by another call to QCoreApplication::processEvents(); | - | ||||||||||||||||||
3320 | - | |||||||||||||||||||
3321 | This function is timeconsuming and its use is discouraged. | - | ||||||||||||||||||
3322 | */ | - | ||||||||||||||||||
3323 | void QGuiApplication::sync() | - | ||||||||||||||||||
3324 | { | - | ||||||||||||||||||
3325 | QCoreApplication::processEvents(); | - | ||||||||||||||||||
3326 | if (QGuiApplicationPrivate::platform_integration
| 0 | ||||||||||||||||||
3327 | && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) {
| 0 | ||||||||||||||||||
3328 | QGuiApplicationPrivate::platform_integration->sync(); | - | ||||||||||||||||||
3329 | QCoreApplication::processEvents(); | - | ||||||||||||||||||
3330 | QWindowSystemInterface::flushWindowSystemEvents(); | - | ||||||||||||||||||
3331 | } never executed: end of block | 0 | ||||||||||||||||||
3332 | } never executed: end of block | 0 | ||||||||||||||||||
3333 | - | |||||||||||||||||||
3334 | /*! | - | ||||||||||||||||||
3335 | \property QGuiApplication::layoutDirection | - | ||||||||||||||||||
3336 | \brief the default layout direction for this application | - | ||||||||||||||||||
3337 | - | |||||||||||||||||||
3338 | On system start-up, the default layout direction depends on the | - | ||||||||||||||||||
3339 | application's language. | - | ||||||||||||||||||
3340 | - | |||||||||||||||||||
3341 | The notifier signal was introduced in Qt 5.4. | - | ||||||||||||||||||
3342 | - | |||||||||||||||||||
3343 | \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft() | - | ||||||||||||||||||
3344 | */ | - | ||||||||||||||||||
3345 | - | |||||||||||||||||||
3346 | void QGuiApplication::setLayoutDirection(Qt::LayoutDirection direction) | - | ||||||||||||||||||
3347 | { | - | ||||||||||||||||||
3348 | if (layout_direction == direction || direction == Qt::LayoutDirectionAuto)
| 0 | ||||||||||||||||||
3349 | return; never executed: return; | 0 | ||||||||||||||||||
3350 | - | |||||||||||||||||||
3351 | layout_direction = direction; | - | ||||||||||||||||||
3352 | - | |||||||||||||||||||
3353 | if (qGuiApp) {
| 0 | ||||||||||||||||||
3354 | emit qGuiApp->layoutDirectionChanged(direction); | - | ||||||||||||||||||
3355 | QGuiApplicationPrivate::self->notifyLayoutDirectionChange(); | - | ||||||||||||||||||
3356 | } never executed: end of block | 0 | ||||||||||||||||||
3357 | } never executed: end of block | 0 | ||||||||||||||||||
3358 | - | |||||||||||||||||||
3359 | Qt::LayoutDirection QGuiApplication::layoutDirection() | - | ||||||||||||||||||
3360 | { | - | ||||||||||||||||||
3361 | // layout_direction is only ever Qt::LayoutDirectionAuto if setLayoutDirection | - | ||||||||||||||||||
3362 | // was never called, or called with Qt::LayoutDirectionAuto (which is a no-op). | - | ||||||||||||||||||
3363 | // In that case we return the default LeftToRight. | - | ||||||||||||||||||
3364 | return layout_direction == Qt::LayoutDirectionAuto ? Qt::LeftToRight : layout_direction; never executed: return layout_direction == Qt::LayoutDirectionAuto ? Qt::LeftToRight : layout_direction;
| 0 | ||||||||||||||||||
3365 | } | - | ||||||||||||||||||
3366 | - | |||||||||||||||||||
3367 | /*! | - | ||||||||||||||||||
3368 | \fn QCursor *QGuiApplication::overrideCursor() | - | ||||||||||||||||||
3369 | - | |||||||||||||||||||
3370 | Returns the active application override cursor. | - | ||||||||||||||||||
3371 | - | |||||||||||||||||||
3372 | This function returns 0 if no application cursor has been defined (i.e. the | - | ||||||||||||||||||
3373 | internal cursor stack is empty). | - | ||||||||||||||||||
3374 | - | |||||||||||||||||||
3375 | \sa setOverrideCursor(), restoreOverrideCursor() | - | ||||||||||||||||||
3376 | */ | - | ||||||||||||||||||
3377 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
3378 | QCursor *QGuiApplication::overrideCursor() | - | ||||||||||||||||||
3379 | { | - | ||||||||||||||||||
3380 | CHECK_QAPP_INSTANCE(Q_NULLPTR) never executed: end of block never executed: return nullptr;
| 0 | ||||||||||||||||||
3381 | return qGuiApp->d_func()->cursor_list.isEmpty() ? 0 : &qGuiApp->d_func()->cursor_list.first(); never executed: return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->cursor_list.isEmpty() ? 0 : &(static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->cursor_list.first();
| 0 | ||||||||||||||||||
3382 | } | - | ||||||||||||||||||
3383 | - | |||||||||||||||||||
3384 | /*! | - | ||||||||||||||||||
3385 | Changes the currently active application override cursor to \a cursor. | - | ||||||||||||||||||
3386 | - | |||||||||||||||||||
3387 | This function has no effect if setOverrideCursor() was not called. | - | ||||||||||||||||||
3388 | - | |||||||||||||||||||
3389 | \sa setOverrideCursor(), overrideCursor(), restoreOverrideCursor(), | - | ||||||||||||||||||
3390 | QWidget::setCursor() | - | ||||||||||||||||||
3391 | */ | - | ||||||||||||||||||
3392 | void QGuiApplication::changeOverrideCursor(const QCursor &cursor) | - | ||||||||||||||||||
3393 | { | - | ||||||||||||||||||
3394 | CHECK_QAPP_INSTANCE() never executed: return ; never executed: end of block
| 0 | ||||||||||||||||||
3395 | if (qGuiApp->d_func()->cursor_list.isEmpty())
| 0 | ||||||||||||||||||
3396 | return; never executed: return; | 0 | ||||||||||||||||||
3397 | qGuiApp->d_func()->cursor_list.removeFirst(); | - | ||||||||||||||||||
3398 | setOverrideCursor(cursor); | - | ||||||||||||||||||
3399 | } never executed: end of block | 0 | ||||||||||||||||||
3400 | #endif | - | ||||||||||||||||||
3401 | - | |||||||||||||||||||
3402 | - | |||||||||||||||||||
3403 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
3404 | static inline void applyCursor(QWindow *w, QCursor c) | - | ||||||||||||||||||
3405 | { | - | ||||||||||||||||||
3406 | if (const QScreen *screen = w->screen())
| 0 | ||||||||||||||||||
3407 | if (QPlatformCursor *cursor = screen->handle()->cursor())
| 0 | ||||||||||||||||||
3408 | cursor->changeCursor(&c, w); never executed: cursor->changeCursor(&c, w); | 0 | ||||||||||||||||||
3409 | } never executed: end of block | 0 | ||||||||||||||||||
3410 | - | |||||||||||||||||||
3411 | static inline void unsetCursor(QWindow *w) | - | ||||||||||||||||||
3412 | { | - | ||||||||||||||||||
3413 | if (const QScreen *screen = w->screen())
| 0 | ||||||||||||||||||
3414 | if (QPlatformCursor *cursor = screen->handle()->cursor())
| 0 | ||||||||||||||||||
3415 | cursor->changeCursor(0, w); never executed: cursor->changeCursor(0, w); | 0 | ||||||||||||||||||
3416 | } never executed: end of block | 0 | ||||||||||||||||||
3417 | - | |||||||||||||||||||
3418 | static inline void applyCursor(const QList<QWindow *> &l, const QCursor &c) | - | ||||||||||||||||||
3419 | { | - | ||||||||||||||||||
3420 | for (int i = 0; i < l.size(); ++i) {
| 0 | ||||||||||||||||||
3421 | QWindow *w = l.at(i); | - | ||||||||||||||||||
3422 | if (w->handle() && w->type() != Qt::Desktop)
| 0 | ||||||||||||||||||
3423 | applyCursor(w, c); never executed: applyCursor(w, c); | 0 | ||||||||||||||||||
3424 | } never executed: end of block | 0 | ||||||||||||||||||
3425 | } never executed: end of block | 0 | ||||||||||||||||||
3426 | - | |||||||||||||||||||
3427 | static inline void applyWindowCursor(const QList<QWindow *> &l) | - | ||||||||||||||||||
3428 | { | - | ||||||||||||||||||
3429 | for (int i = 0; i < l.size(); ++i) {
| 0 | ||||||||||||||||||
3430 | QWindow *w = l.at(i); | - | ||||||||||||||||||
3431 | if (w->handle() && w->type() != Qt::Desktop) {
| 0 | ||||||||||||||||||
3432 | if (qt_window_private(w)->hasCursor) {
| 0 | ||||||||||||||||||
3433 | applyCursor(w, w->cursor()); | - | ||||||||||||||||||
3434 | } else { never executed: end of block | 0 | ||||||||||||||||||
3435 | unsetCursor(w); | - | ||||||||||||||||||
3436 | } never executed: end of block | 0 | ||||||||||||||||||
3437 | } | - | ||||||||||||||||||
3438 | } never executed: end of block | 0 | ||||||||||||||||||
3439 | } never executed: end of block | 0 | ||||||||||||||||||
3440 | - | |||||||||||||||||||
3441 | /*! | - | ||||||||||||||||||
3442 | \fn void QGuiApplication::setOverrideCursor(const QCursor &cursor) | - | ||||||||||||||||||
3443 | - | |||||||||||||||||||
3444 | Sets the application override cursor to \a cursor. | - | ||||||||||||||||||
3445 | - | |||||||||||||||||||
3446 | Application override cursors are intended for showing the user that the | - | ||||||||||||||||||
3447 | application is in a special state, for example during an operation that | - | ||||||||||||||||||
3448 | might take some time. | - | ||||||||||||||||||
3449 | - | |||||||||||||||||||
3450 | This cursor will be displayed in all the application's widgets until | - | ||||||||||||||||||
3451 | restoreOverrideCursor() or another setOverrideCursor() is called. | - | ||||||||||||||||||
3452 | - | |||||||||||||||||||
3453 | Application cursors are stored on an internal stack. setOverrideCursor() | - | ||||||||||||||||||
3454 | pushes the cursor onto the stack, and restoreOverrideCursor() pops the | - | ||||||||||||||||||
3455 | active cursor off the stack. changeOverrideCursor() changes the curently | - | ||||||||||||||||||
3456 | active application override cursor. | - | ||||||||||||||||||
3457 | - | |||||||||||||||||||
3458 | Every setOverrideCursor() must eventually be followed by a corresponding | - | ||||||||||||||||||
3459 | restoreOverrideCursor(), otherwise the stack will never be emptied. | - | ||||||||||||||||||
3460 | - | |||||||||||||||||||
3461 | Example: | - | ||||||||||||||||||
3462 | \snippet code/src_gui_kernel_qguiapplication_x11.cpp 0 | - | ||||||||||||||||||
3463 | - | |||||||||||||||||||
3464 | \sa overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(), | - | ||||||||||||||||||
3465 | QWidget::setCursor() | - | ||||||||||||||||||
3466 | */ | - | ||||||||||||||||||
3467 | void QGuiApplication::setOverrideCursor(const QCursor &cursor) | - | ||||||||||||||||||
3468 | { | - | ||||||||||||||||||
3469 | CHECK_QAPP_INSTANCE() never executed: return ; never executed: end of block
| 0 | ||||||||||||||||||
3470 | qGuiApp->d_func()->cursor_list.prepend(cursor); | - | ||||||||||||||||||
3471 | applyCursor(QGuiApplicationPrivate::window_list, cursor); | - | ||||||||||||||||||
3472 | } never executed: end of block | 0 | ||||||||||||||||||
3473 | - | |||||||||||||||||||
3474 | /*! | - | ||||||||||||||||||
3475 | \fn void QGuiApplication::restoreOverrideCursor() | - | ||||||||||||||||||
3476 | - | |||||||||||||||||||
3477 | Undoes the last setOverrideCursor(). | - | ||||||||||||||||||
3478 | - | |||||||||||||||||||
3479 | If setOverrideCursor() has been called twice, calling | - | ||||||||||||||||||
3480 | restoreOverrideCursor() will activate the first cursor set. Calling this | - | ||||||||||||||||||
3481 | function a second time restores the original widgets' cursors. | - | ||||||||||||||||||
3482 | - | |||||||||||||||||||
3483 | \sa setOverrideCursor(), overrideCursor() | - | ||||||||||||||||||
3484 | */ | - | ||||||||||||||||||
3485 | void QGuiApplication::restoreOverrideCursor() | - | ||||||||||||||||||
3486 | { | - | ||||||||||||||||||
3487 | CHECK_QAPP_INSTANCE() never executed: return ; never executed: end of block
| 0 | ||||||||||||||||||
3488 | if (qGuiApp->d_func()->cursor_list.isEmpty())
| 0 | ||||||||||||||||||
3489 | return; never executed: return; | 0 | ||||||||||||||||||
3490 | qGuiApp->d_func()->cursor_list.removeFirst(); | - | ||||||||||||||||||
3491 | if (qGuiApp->d_func()->cursor_list.size() > 0) {
| 0 | ||||||||||||||||||
3492 | QCursor c(qGuiApp->d_func()->cursor_list.value(0)); | - | ||||||||||||||||||
3493 | applyCursor(QGuiApplicationPrivate::window_list, c); | - | ||||||||||||||||||
3494 | } else { never executed: end of block | 0 | ||||||||||||||||||
3495 | applyWindowCursor(QGuiApplicationPrivate::window_list); | - | ||||||||||||||||||
3496 | } never executed: end of block | 0 | ||||||||||||||||||
3497 | } | - | ||||||||||||||||||
3498 | #endif// QT_NO_CURSOR | - | ||||||||||||||||||
3499 | - | |||||||||||||||||||
3500 | /*! | - | ||||||||||||||||||
3501 | Returns the application's style hints. | - | ||||||||||||||||||
3502 | - | |||||||||||||||||||
3503 | The style hints encapsulate a set of platform dependent properties | - | ||||||||||||||||||
3504 | such as double click intervals, full width selection and others. | - | ||||||||||||||||||
3505 | - | |||||||||||||||||||
3506 | The hints can be used to integrate tighter with the underlying platform. | - | ||||||||||||||||||
3507 | - | |||||||||||||||||||
3508 | \sa QStyleHints | - | ||||||||||||||||||
3509 | */ | - | ||||||||||||||||||
3510 | QStyleHints *QGuiApplication::styleHints() | - | ||||||||||||||||||
3511 | { | - | ||||||||||||||||||
3512 | if (!QGuiApplicationPrivate::styleHints)
| 0 | ||||||||||||||||||
3513 | QGuiApplicationPrivate::styleHints = new QStyleHints(); never executed: QGuiApplicationPrivate::styleHints = new QStyleHints(); | 0 | ||||||||||||||||||
3514 | return QGuiApplicationPrivate::styleHints; never executed: return QGuiApplicationPrivate::styleHints; | 0 | ||||||||||||||||||
3515 | } | - | ||||||||||||||||||
3516 | - | |||||||||||||||||||
3517 | /*! | - | ||||||||||||||||||
3518 | Sets whether Qt should use the system's standard colors, fonts, etc., to | - | ||||||||||||||||||
3519 | \a on. By default, this is \c true. | - | ||||||||||||||||||
3520 | - | |||||||||||||||||||
3521 | This function must be called before creating the QGuiApplication object, like | - | ||||||||||||||||||
3522 | this: | - | ||||||||||||||||||
3523 | - | |||||||||||||||||||
3524 | \snippet code/src_gui_kernel_qguiapplication.cpp 0 | - | ||||||||||||||||||
3525 | - | |||||||||||||||||||
3526 | \sa desktopSettingsAware() | - | ||||||||||||||||||
3527 | */ | - | ||||||||||||||||||
3528 | void QGuiApplication::setDesktopSettingsAware(bool on) | - | ||||||||||||||||||
3529 | { | - | ||||||||||||||||||
3530 | QGuiApplicationPrivate::obey_desktop_settings = on; | - | ||||||||||||||||||
3531 | } never executed: end of block | 0 | ||||||||||||||||||
3532 | - | |||||||||||||||||||
3533 | /*! | - | ||||||||||||||||||
3534 | Returns \c true if Qt is set to use the system's standard colors, fonts, etc.; | - | ||||||||||||||||||
3535 | otherwise returns \c false. The default is \c true. | - | ||||||||||||||||||
3536 | - | |||||||||||||||||||
3537 | \sa setDesktopSettingsAware() | - | ||||||||||||||||||
3538 | */ | - | ||||||||||||||||||
3539 | bool QGuiApplication::desktopSettingsAware() | - | ||||||||||||||||||
3540 | { | - | ||||||||||||||||||
3541 | return QGuiApplicationPrivate::obey_desktop_settings; never executed: return QGuiApplicationPrivate::obey_desktop_settings; | 0 | ||||||||||||||||||
3542 | } | - | ||||||||||||||||||
3543 | - | |||||||||||||||||||
3544 | /*! | - | ||||||||||||||||||
3545 | returns the input method. | - | ||||||||||||||||||
3546 | - | |||||||||||||||||||
3547 | The input method returns properties about the state and position of | - | ||||||||||||||||||
3548 | the virtual keyboard. It also provides information about the position of the | - | ||||||||||||||||||
3549 | current focused input element. | - | ||||||||||||||||||
3550 | - | |||||||||||||||||||
3551 | \sa QInputMethod | - | ||||||||||||||||||
3552 | */ | - | ||||||||||||||||||
3553 | QInputMethod *QGuiApplication::inputMethod() | - | ||||||||||||||||||
3554 | { | - | ||||||||||||||||||
3555 | CHECK_QAPP_INSTANCE(Q_NULLPTR) never executed: end of block never executed: return nullptr;
| 0 | ||||||||||||||||||
3556 | if (!qGuiApp->d_func()->inputMethod)
| 0 | ||||||||||||||||||
3557 | qGuiApp->d_func()->inputMethod = new QInputMethod(); never executed: (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->inputMethod = new QInputMethod(); | 0 | ||||||||||||||||||
3558 | return qGuiApp->d_func()->inputMethod; never executed: return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->inputMethod; | 0 | ||||||||||||||||||
3559 | } | - | ||||||||||||||||||
3560 | - | |||||||||||||||||||
3561 | /*! | - | ||||||||||||||||||
3562 | \fn void QGuiApplication::fontDatabaseChanged() | - | ||||||||||||||||||
3563 | - | |||||||||||||||||||
3564 | This signal is emitted when application fonts are loaded or removed. | - | ||||||||||||||||||
3565 | - | |||||||||||||||||||
3566 | \sa QFontDatabase::addApplicationFont(), | - | ||||||||||||||||||
3567 | QFontDatabase::addApplicationFontFromData(), | - | ||||||||||||||||||
3568 | QFontDatabase::removeAllApplicationFonts(), | - | ||||||||||||||||||
3569 | QFontDatabase::removeApplicationFont() | - | ||||||||||||||||||
3570 | */ | - | ||||||||||||||||||
3571 | - | |||||||||||||||||||
3572 | QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) | - | ||||||||||||||||||
3573 | { | - | ||||||||||||||||||
3574 | Q_UNUSED(cshape); | - | ||||||||||||||||||
3575 | return QPixmap(); never executed: return QPixmap(); | 0 | ||||||||||||||||||
3576 | } | - | ||||||||||||||||||
3577 | - | |||||||||||||||||||
3578 | void QGuiApplicationPrivate::notifyThemeChanged() | - | ||||||||||||||||||
3579 | { | - | ||||||||||||||||||
3580 | if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet) &&
| 0 | ||||||||||||||||||
3581 | !QCoreApplication::testAttribute(Qt::AA_SetPalette)) {
| 0 | ||||||||||||||||||
3582 | clearPalette(); | - | ||||||||||||||||||
3583 | initPalette(); | - | ||||||||||||||||||
3584 | } never executed: end of block | 0 | ||||||||||||||||||
3585 | if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) {
| 0 | ||||||||||||||||||
3586 | QMutexLocker locker(&applicationFontMutex); | - | ||||||||||||||||||
3587 | clearFontUnlocked(); | - | ||||||||||||||||||
3588 | initFontUnlocked(); | - | ||||||||||||||||||
3589 | } never executed: end of block | 0 | ||||||||||||||||||
3590 | } never executed: end of block | 0 | ||||||||||||||||||
3591 | - | |||||||||||||||||||
3592 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||
3593 | void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag) | - | ||||||||||||||||||
3594 | { | - | ||||||||||||||||||
3595 | Q_UNUSED(drag) | - | ||||||||||||||||||
3596 | - | |||||||||||||||||||
3597 | } never executed: end of block | 0 | ||||||||||||||||||
3598 | #endif | - | ||||||||||||||||||
3599 | - | |||||||||||||||||||
3600 | const QDrawHelperGammaTables *QGuiApplicationPrivate::gammaTables() | - | ||||||||||||||||||
3601 | { | - | ||||||||||||||||||
3602 | QDrawHelperGammaTables *result = m_gammaTables.load(); | - | ||||||||||||||||||
3603 | if (!result){
| 0 | ||||||||||||||||||
3604 | QDrawHelperGammaTables *tables = new QDrawHelperGammaTables(fontSmoothingGamma); | - | ||||||||||||||||||
3605 | if (!m_gammaTables.testAndSetRelease(0, tables))
| 0 | ||||||||||||||||||
3606 | delete tables; never executed: delete tables; | 0 | ||||||||||||||||||
3607 | result = m_gammaTables.load(); | - | ||||||||||||||||||
3608 | } never executed: end of block | 0 | ||||||||||||||||||
3609 | return result; never executed: return result; | 0 | ||||||||||||||||||
3610 | } | - | ||||||||||||||||||
3611 | - | |||||||||||||||||||
3612 | void QGuiApplicationPrivate::_q_updateFocusObject(QObject *object) | - | ||||||||||||||||||
3613 | { | - | ||||||||||||||||||
3614 | Q_Q(QGuiApplication); | - | ||||||||||||||||||
3615 | - | |||||||||||||||||||
3616 | QPlatformInputContext *inputContext = platformIntegration()->inputContext(); | - | ||||||||||||||||||
3617 | bool enabled = false; | - | ||||||||||||||||||
3618 | if (object && inputContext) {
| 0 | ||||||||||||||||||
3619 | QInputMethodQueryEvent query(Qt::ImEnabled | Qt::ImHints); | - | ||||||||||||||||||
3620 | QGuiApplication::sendEvent(object, &query); | - | ||||||||||||||||||
3621 | enabled = query.value(Qt::ImEnabled).toBool(); | - | ||||||||||||||||||
3622 | if (enabled) {
| 0 | ||||||||||||||||||
3623 | static const bool supportsHiddenText = inputContext->hasCapability(QPlatformInputContext::HiddenTextCapability); | - | ||||||||||||||||||
3624 | const Qt::InputMethodHints hints = static_cast<Qt::InputMethodHints>(query.value(Qt::ImHints).toInt()); | - | ||||||||||||||||||
3625 | if ((hints & Qt::ImhHiddenText) && !supportsHiddenText)
| 0 | ||||||||||||||||||
3626 | enabled = false; never executed: enabled = false; | 0 | ||||||||||||||||||
3627 | } never executed: end of block | 0 | ||||||||||||||||||
3628 | } never executed: end of block | 0 | ||||||||||||||||||
3629 | - | |||||||||||||||||||
3630 | QPlatformInputContextPrivate::setInputMethodAccepted(enabled); | - | ||||||||||||||||||
3631 | if (inputContext)
| 0 | ||||||||||||||||||
3632 | inputContext->setFocusObject(object); never executed: inputContext->setFocusObject(object); | 0 | ||||||||||||||||||
3633 | emit q->focusObjectChanged(object); | - | ||||||||||||||||||
3634 | } never executed: end of block | 0 | ||||||||||||||||||
3635 | - | |||||||||||||||||||
3636 | enum { | - | ||||||||||||||||||
3637 | MouseCapsMask = 0xFF, | - | ||||||||||||||||||
3638 | MouseSourceMaskDst = 0xFF00, | - | ||||||||||||||||||
3639 | MouseSourceMaskSrc = MouseCapsMask, | - | ||||||||||||||||||
3640 | MouseSourceShift = 8, | - | ||||||||||||||||||
3641 | MouseFlagsCapsMask = 0xFF0000, | - | ||||||||||||||||||
3642 | MouseFlagsShift = 16 | - | ||||||||||||||||||
3643 | }; | - | ||||||||||||||||||
3644 | - | |||||||||||||||||||
3645 | int QGuiApplicationPrivate::mouseEventCaps(QMouseEvent *event) | - | ||||||||||||||||||
3646 | { | - | ||||||||||||||||||
3647 | return event->caps & MouseCapsMask; never executed: return event->caps & MouseCapsMask; | 0 | ||||||||||||||||||
3648 | } | - | ||||||||||||||||||
3649 | - | |||||||||||||||||||
3650 | QVector2D QGuiApplicationPrivate::mouseEventVelocity(QMouseEvent *event) | - | ||||||||||||||||||
3651 | { | - | ||||||||||||||||||
3652 | return event->velocity; never executed: return event->velocity; | 0 | ||||||||||||||||||
3653 | } | - | ||||||||||||||||||
3654 | - | |||||||||||||||||||
3655 | void QGuiApplicationPrivate::setMouseEventCapsAndVelocity(QMouseEvent *event, int caps, const QVector2D &velocity) | - | ||||||||||||||||||
3656 | { | - | ||||||||||||||||||
3657 | Q_ASSERT(caps <= MouseCapsMask); | - | ||||||||||||||||||
3658 | event->caps &= ~MouseCapsMask; | - | ||||||||||||||||||
3659 | event->caps |= caps & MouseCapsMask; | - | ||||||||||||||||||
3660 | event->velocity = velocity; | - | ||||||||||||||||||
3661 | } never executed: end of block | 0 | ||||||||||||||||||
3662 | - | |||||||||||||||||||
3663 | Qt::MouseEventSource QGuiApplicationPrivate::mouseEventSource(const QMouseEvent *event) | - | ||||||||||||||||||
3664 | { | - | ||||||||||||||||||
3665 | return Qt::MouseEventSource((event->caps & MouseSourceMaskDst) >> MouseSourceShift); never executed: return Qt::MouseEventSource((event->caps & MouseSourceMaskDst) >> MouseSourceShift); | 0 | ||||||||||||||||||
3666 | } | - | ||||||||||||||||||
3667 | - | |||||||||||||||||||
3668 | void QGuiApplicationPrivate::setMouseEventSource(QMouseEvent *event, Qt::MouseEventSource source) | - | ||||||||||||||||||
3669 | { | - | ||||||||||||||||||
3670 | // Mouse event synthesization status is encoded in the caps field because | - | ||||||||||||||||||
3671 | // QTouchDevice::CapabilityFlag uses only 6 bits from it. | - | ||||||||||||||||||
3672 | int value = source; | - | ||||||||||||||||||
3673 | Q_ASSERT(value <= MouseSourceMaskSrc); | - | ||||||||||||||||||
3674 | event->caps &= ~MouseSourceMaskDst; | - | ||||||||||||||||||
3675 | event->caps |= (value & MouseSourceMaskSrc) << MouseSourceShift; | - | ||||||||||||||||||
3676 | } never executed: end of block | 0 | ||||||||||||||||||
3677 | - | |||||||||||||||||||
3678 | Qt::MouseEventFlags QGuiApplicationPrivate::mouseEventFlags(const QMouseEvent *event) | - | ||||||||||||||||||
3679 | { | - | ||||||||||||||||||
3680 | return Qt::MouseEventFlags((event->caps & MouseFlagsCapsMask) >> MouseFlagsShift); never executed: return Qt::MouseEventFlags((event->caps & MouseFlagsCapsMask) >> MouseFlagsShift); | 0 | ||||||||||||||||||
3681 | } | - | ||||||||||||||||||
3682 | - | |||||||||||||||||||
3683 | void QGuiApplicationPrivate::setMouseEventFlags(QMouseEvent *event, Qt::MouseEventFlags flags) | - | ||||||||||||||||||
3684 | { | - | ||||||||||||||||||
3685 | // use the 0x00FF0000 byte from caps (containing up to 7 mouse event flags) | - | ||||||||||||||||||
3686 | unsigned int value = flags; | - | ||||||||||||||||||
3687 | Q_ASSERT(value <= Qt::MouseEventFlagMask); | - | ||||||||||||||||||
3688 | event->caps &= ~MouseFlagsCapsMask; | - | ||||||||||||||||||
3689 | event->caps |= (value & Qt::MouseEventFlagMask) << MouseFlagsShift; | - | ||||||||||||||||||
3690 | } never executed: end of block | 0 | ||||||||||||||||||
3691 | - | |||||||||||||||||||
3692 | QInputDeviceManager *QGuiApplicationPrivate::inputDeviceManager() | - | ||||||||||||||||||
3693 | { | - | ||||||||||||||||||
3694 | Q_ASSERT(QGuiApplication::instance()); | - | ||||||||||||||||||
3695 | - | |||||||||||||||||||
3696 | if (!m_inputDeviceManager)
| 0 | ||||||||||||||||||
3697 | m_inputDeviceManager = new QInputDeviceManager(QGuiApplication::instance()); never executed: m_inputDeviceManager = new QInputDeviceManager(QGuiApplication::instance()); | 0 | ||||||||||||||||||
3698 | - | |||||||||||||||||||
3699 | return m_inputDeviceManager; never executed: return m_inputDeviceManager; | 0 | ||||||||||||||||||
3700 | } | - | ||||||||||||||||||
3701 | - | |||||||||||||||||||
3702 | #include "moc_qguiapplication.cpp" | - | ||||||||||||||||||
3703 | - | |||||||||||||||||||
3704 | QT_END_NAMESPACE | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |