Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | __attribute__((visibility("default"))) bool qt_is_gui_used = true; | - |
23 | | - |
24 | Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton; | - |
25 | Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; | - |
26 | | - |
27 | QPointF QGuiApplicationPrivate::lastCursorPosition(0.0, 0.0); | - |
28 | | - |
29 | bool QGuiApplicationPrivate::tabletState = false; | - |
30 | QWindow *QGuiApplicationPrivate::tabletPressTarget = 0; | - |
31 | QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; | - |
32 | | - |
33 | QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; | - |
34 | QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; | - |
35 | | - |
36 | QList<QObject *> QGuiApplicationPrivate::generic_plugin_list; | - |
37 | | - |
38 | enum ApplicationResourceFlags | - |
39 | { | - |
40 | ApplicationPaletteExplicitlySet = 0x1, | - |
41 | ApplicationFontExplicitlySet = 0x2 | - |
42 | }; | - |
43 | | - |
44 | static unsigned applicationResourceFlags = 0; | - |
45 | | - |
46 | QString *QGuiApplicationPrivate::platform_name = 0; | - |
47 | QString *QGuiApplicationPrivate::displayName = 0; | - |
48 | | - |
49 | QPalette *QGuiApplicationPrivate::app_pal = 0; | - |
50 | | - |
51 | Qt::MouseButtons QGuiApplicationPrivate::buttons = Qt::NoButton; | - |
52 | ulong QGuiApplicationPrivate::mousePressTime = 0; | - |
53 | Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton; | - |
54 | int QGuiApplicationPrivate::mousePressX = 0; | - |
55 | int QGuiApplicationPrivate::mousePressY = 0; | - |
56 | int QGuiApplicationPrivate::mouse_double_click_distance = 5; | - |
57 | | - |
58 | static Qt::LayoutDirection layout_direction = Qt::LeftToRight; | - |
59 | static bool force_reverse = false; | - |
60 | | - |
61 | QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0; | - |
62 | QTouchDevice *QGuiApplicationPrivate::m_fakeTouchDevice = 0; | - |
63 | int QGuiApplicationPrivate::m_fakeMouseSourcePointId = 0; | - |
64 | | - |
65 | | - |
66 | QClipboard *QGuiApplicationPrivate::qt_clipboard = 0; | - |
67 | | - |
68 | | - |
69 | QList<QScreen *> QGuiApplicationPrivate::screen_list; | - |
70 | | - |
71 | QWindowList QGuiApplicationPrivate::window_list; | - |
72 | QWindow *QGuiApplicationPrivate::focus_window = 0; | - |
73 | | - |
74 | static QBasicMutex applicationFontMutex; | - |
75 | QFont *QGuiApplicationPrivate::app_font = 0; | - |
76 | bool QGuiApplicationPrivate::obey_desktop_settings = true; | - |
77 | bool QGuiApplicationPrivate::noGrab = false; | - |
78 | | - |
79 | static qreal fontSmoothingGamma = 1.7; | - |
80 | | - |
81 | extern void qRegisterGuiVariant(); | - |
82 | extern void qInitDrawhelperAsm(); | - |
83 | extern void qInitImageConversions(); | - |
84 | | - |
85 | static bool qt_detectRTLLanguage() | - |
86 | { | - |
87 | return force_reverse ^ | - |
88 | (QCoreApplication::tr("QT_LAYOUT_DIRECTION", | - |
89 | "Translate this string to the string 'LTR' in left-to-right" | - |
90 | " languages or to 'RTL' in right-to-left languages (such as Hebrew" | - |
91 | " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); | - |
92 | } | - |
93 | | - |
94 | static void initPalette() | - |
95 | { | - |
96 | if (!QGuiApplicationPrivate::app_pal) | - |
97 | if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) | - |
98 | QGuiApplicationPrivate::app_pal = new QPalette(*themePalette); | - |
99 | if (!QGuiApplicationPrivate::app_pal) | - |
100 | QGuiApplicationPrivate::app_pal = new QPalette(Qt::black); | - |
101 | } | - |
102 | | - |
103 | static inline void clearPalette() | - |
104 | { | - |
105 | delete QGuiApplicationPrivate::app_pal; | - |
106 | QGuiApplicationPrivate::app_pal = 0; | - |
107 | } | - |
108 | | - |
109 | static void initFontUnlocked() | - |
110 | { | - |
111 | if (!QGuiApplicationPrivate::app_font) { | - |
112 | if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) | - |
113 | if (const QFont *font = theme->font(QPlatformTheme::SystemFont)) | - |
114 | QGuiApplicationPrivate::app_font = new QFont(*font); | - |
115 | } | - |
116 | if (!QGuiApplicationPrivate::app_font) | - |
117 | QGuiApplicationPrivate::app_font = | - |
118 | new QFont(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFont()); | - |
119 | } | - |
120 | | - |
121 | static inline void clearFontUnlocked() | - |
122 | { | - |
123 | delete QGuiApplicationPrivate::app_font; | - |
124 | QGuiApplicationPrivate::app_font = 0; | - |
125 | } | - |
126 | QGuiApplication::QGuiApplication(int &argc, char **argv, int flags) | - |
127 | | - |
128 | : QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags)) | - |
129 | { | - |
130 | d_func()->init(); | - |
131 | | - |
132 | QCoreApplicationPrivate::eventDispatcher->startingUp(); | - |
133 | } | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | QGuiApplication::QGuiApplication(QGuiApplicationPrivate &p) | - |
139 | : QCoreApplication(p) | - |
140 | { | - |
141 | d_func()->init(); } | - |
142 | | - |
143 | | - |
144 | | - |
145 | | - |
146 | QGuiApplication::~QGuiApplication() | - |
147 | { | - |
148 | QGuiApplicationPrivate * const d = d_func(); | - |
149 | | - |
150 | d->eventDispatcher->closingDown(); | - |
151 | d->eventDispatcher = 0; | - |
152 | | - |
153 | | - |
154 | delete QGuiApplicationPrivate::qt_clipboard; | - |
155 | QGuiApplicationPrivate::qt_clipboard = 0; | - |
156 | | - |
157 | | - |
158 | | - |
159 | delete d->session_manager; | - |
160 | d->session_manager = 0; | - |
161 | | - |
162 | | - |
163 | clearPalette(); | - |
164 | | - |
165 | | - |
166 | d->cursor_list.clear(); | - |
167 | | - |
168 | | - |
169 | delete QGuiApplicationPrivate::platform_name; | - |
170 | QGuiApplicationPrivate::platform_name = 0; | - |
171 | delete QGuiApplicationPrivate::displayName; | - |
172 | QGuiApplicationPrivate::displayName = 0; | - |
173 | } | - |
174 | | - |
175 | QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags) | - |
176 | : QCoreApplicationPrivate(argc, argv, flags), | - |
177 | styleHints(0), | - |
178 | inputMethod(0), | - |
179 | lastTouchType(QEvent::TouchEnd) | - |
180 | { | - |
181 | self = this; | - |
182 | application_type = QCoreApplicationPrivate::Gui; | - |
183 | | - |
184 | is_session_restored = false; | - |
185 | is_saving_session = false; | - |
186 | | - |
187 | } | - |
188 | void QGuiApplication::setApplicationDisplayName(const QString &name) | - |
189 | { | - |
190 | if (!QGuiApplicationPrivate::displayName) | - |
191 | QGuiApplicationPrivate::displayName = new QString; | - |
192 | *QGuiApplicationPrivate::displayName = name; | - |
193 | } | - |
194 | | - |
195 | QString QGuiApplication::applicationDisplayName() | - |
196 | { | - |
197 | return QGuiApplicationPrivate::displayName ? *QGuiApplicationPrivate::displayName : applicationName(); | - |
198 | } | - |
199 | QWindow *QGuiApplication::modalWindow() | - |
200 | { | - |
201 | if (QGuiApplicationPrivate::self->modalWindowList.isEmpty()) | - |
202 | return 0; | - |
203 | return QGuiApplicationPrivate::self->modalWindowList.first(); | - |
204 | } | - |
205 | | - |
206 | void QGuiApplicationPrivate::updateBlockedStatus(QWindow *window) | - |
207 | { | - |
208 | bool shouldBeBlocked = false; | - |
209 | if ((window->type() & Qt::Popup) != Qt::Popup && !self->modalWindowList.isEmpty()) | - |
210 | shouldBeBlocked = self->isWindowBlocked(window); | - |
211 | | - |
212 | if (shouldBeBlocked != window->d_func()->blockedByModalWindow) { | - |
213 | QEvent e(shouldBeBlocked ? QEvent::WindowBlocked : QEvent::WindowUnblocked); | - |
214 | | - |
215 | window->d_func()->blockedByModalWindow = shouldBeBlocked; | - |
216 | QGuiApplication::sendEvent(window, &e); | - |
217 | } | - |
218 | } | - |
219 | | - |
220 | void QGuiApplicationPrivate::showModalWindow(QWindow *modal) | - |
221 | { | - |
222 | self->modalWindowList.prepend(modal); | - |
223 | | - |
224 | | - |
225 | if (currentMouseWindow && (currentMouseWindow->type() & Qt::Popup) != Qt::Popup) { | - |
226 | bool shouldBeBlocked = self->isWindowBlocked(currentMouseWindow); | - |
227 | if (shouldBeBlocked) { | - |
228 | | - |
229 | self->modalWindowList.removeFirst(); | - |
230 | QEvent e(QEvent::Leave); | - |
231 | QGuiApplication::sendEvent(currentMouseWindow, &e); | - |
232 | currentMouseWindow = 0; | - |
233 | self->modalWindowList.prepend(modal); | - |
234 | } | - |
235 | } | - |
236 | | - |
237 | QWindowList windows = QGuiApplication::topLevelWindows(); | - |
238 | for (int i = 0; i < windows.count(); ++i) { | - |
239 | QWindow *window = windows.at(i); | - |
240 | if (!window->d_func()->blockedByModalWindow) | - |
241 | updateBlockedStatus(window); | - |
242 | } | - |
243 | | - |
244 | updateBlockedStatus(modal); | - |
245 | } | - |
246 | | - |
247 | void QGuiApplicationPrivate::hideModalWindow(QWindow *window) | - |
248 | { | - |
249 | self->modalWindowList.removeAll(window); | - |
250 | | - |
251 | QWindowList windows = QGuiApplication::topLevelWindows(); | - |
252 | for (int i = 0; i < windows.count(); ++i) { | - |
253 | QWindow *window = windows.at(i); | - |
254 | if (window->d_func()->blockedByModalWindow) | - |
255 | updateBlockedStatus(window); | - |
256 | } | - |
257 | } | - |
258 | | - |
259 | | - |
260 | | - |
261 | | - |
262 | | - |
263 | | - |
264 | bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const | - |
265 | { | - |
266 | QWindow *unused = 0; | - |
267 | if (!blockingWindow) | - |
268 | blockingWindow = &unused; | - |
269 | | - |
270 | if (modalWindowList.isEmpty()) { | - |
271 | *blockingWindow = 0; | - |
272 | return false; | - |
273 | } | - |
274 | | - |
275 | for (int i = 0; i < modalWindowList.count(); ++i) { | - |
276 | QWindow *modalWindow = modalWindowList.at(i); | - |
277 | | - |
278 | { | - |
279 | | - |
280 | QWindow *w = window; | - |
281 | while (w) { | - |
282 | if (w == modalWindow) { | - |
283 | *blockingWindow = 0; | - |
284 | return false; | - |
285 | } | - |
286 | QWindow *p = w->parent(); | - |
287 | if (!p) | - |
288 | p = w->transientParent(); | - |
289 | w = p; | - |
290 | } | - |
291 | } | - |
292 | | - |
293 | Qt::WindowModality windowModality = modalWindow->modality(); | - |
294 | switch (windowModality) { | - |
295 | case Qt::ApplicationModal: | - |
296 | { | - |
297 | if (modalWindow != window) { | - |
298 | *blockingWindow = modalWindow; | - |
299 | return true; | - |
300 | } | - |
301 | break; | - |
302 | } | - |
303 | case Qt::WindowModal: | - |
304 | { | - |
305 | QWindow *w = window; | - |
306 | do { | - |
307 | QWindow *m = modalWindow; | - |
308 | do { | - |
309 | if (m == w) { | - |
310 | *blockingWindow = m; | - |
311 | return true; | - |
312 | } | - |
313 | QWindow *p = m->parent(); | - |
314 | if (!p) | - |
315 | p = m->transientParent(); | - |
316 | m = p; | - |
317 | } while (m); | - |
318 | QWindow *p = w->parent(); | - |
319 | if (!p) | - |
320 | p = w->transientParent(); | - |
321 | w = p; | - |
322 | } while (w); | - |
323 | break; | - |
324 | } | - |
325 | default: | - |
326 | qt_noop(); | - |
327 | break; | - |
328 | } | - |
329 | } | - |
330 | *blockingWindow = 0; | - |
331 | return false; | - |
332 | } | - |
333 | | - |
334 | | - |
335 | | - |
336 | | - |
337 | | - |
338 | QWindow *QGuiApplication::focusWindow() | - |
339 | { | - |
340 | return QGuiApplicationPrivate::focus_window; | - |
341 | } | - |
342 | QObject *QGuiApplication::focusObject() | - |
343 | { | - |
344 | if (focusWindow()) | - |
345 | return focusWindow()->focusObject(); | - |
346 | return 0; | - |
347 | } | - |
348 | QWindowList QGuiApplication::allWindows() | - |
349 | { | - |
350 | return QGuiApplicationPrivate::window_list; | - |
351 | } | - |
352 | QWindowList QGuiApplication::topLevelWindows() | - |
353 | { | - |
354 | const QWindowList &list = QGuiApplicationPrivate::window_list; | - |
355 | QWindowList topLevelWindows; | - |
356 | for (int i = 0; i < list.size(); i++) { | - |
357 | if (!list.at(i)->parent()) { | - |
358 | | - |
359 | | - |
360 | const bool embedded = list.at(i)->handle() && list.at(i)->handle()->isEmbedded(0); | - |
361 | if (!embedded) | - |
362 | topLevelWindows.prepend(list.at(i)); | - |
363 | } | - |
364 | } | - |
365 | return topLevelWindows; | - |
366 | } | - |
367 | | - |
368 | | - |
369 | | - |
370 | | - |
371 | | - |
372 | | - |
373 | QScreen *QGuiApplication::primaryScreen() | - |
374 | { | - |
375 | if (QGuiApplicationPrivate::screen_list.isEmpty()) | - |
376 | return 0; | - |
377 | return QGuiApplicationPrivate::screen_list.at(0); | - |
378 | } | - |
379 | | - |
380 | | - |
381 | | - |
382 | | - |
383 | | - |
384 | QList<QScreen *> QGuiApplication::screens() | - |
385 | { | - |
386 | return QGuiApplicationPrivate::screen_list; | - |
387 | } | - |
388 | qreal QGuiApplication::devicePixelRatio() const | - |
389 | { | - |
390 | | - |
391 | static qreal topDevicePixelRatio = 0.0; | - |
392 | if (!qFuzzyIsNull(topDevicePixelRatio)) { | - |
393 | return topDevicePixelRatio; | - |
394 | } | - |
395 | | - |
396 | topDevicePixelRatio = 1.0; | - |
397 | for (QForeachContainer<__typeof__(QGuiApplicationPrivate::screen_list)> _container_(QGuiApplicationPrivate::screen_list); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QScreen *screen = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
398 | topDevicePixelRatio = qMax(topDevicePixelRatio, screen->devicePixelRatio()); | - |
399 | } | - |
400 | | - |
401 | return topDevicePixelRatio; | - |
402 | } | - |
403 | | - |
404 | | - |
405 | | - |
406 | | - |
407 | QWindow *QGuiApplication::topLevelAt(const QPoint &pos) | - |
408 | { | - |
409 | QList<QScreen *> screens = QGuiApplication::screens(); | - |
410 | QList<QScreen *>::const_iterator screen = screens.constBegin(); | - |
411 | QList<QScreen *>::const_iterator end = screens.constEnd(); | - |
412 | | - |
413 | while (screen != end) { | - |
414 | if ((*screen)->geometry().contains(pos)) | - |
415 | return (*screen)->handle()->topLevelAt(pos); | - |
416 | ++screen; | - |
417 | } | - |
418 | return 0; | - |
419 | } | - |
420 | QString QGuiApplication::platformName() | - |
421 | { | - |
422 | return QGuiApplicationPrivate::platform_name ? | - |
423 | *QGuiApplicationPrivate::platform_name : QString(); | - |
424 | } | - |
425 | | - |
426 | static void init_platform(const QString &pluginArgument, const QString &platformPluginPath) | - |
427 | { | - |
428 | | - |
429 | QStringList arguments = pluginArgument.split(QLatin1Char(':')); | - |
430 | const QString name = arguments.takeFirst().toLower(); | - |
431 | | - |
432 | | - |
433 | QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, platformPluginPath); | - |
434 | if (QGuiApplicationPrivate::platform_integration) { | - |
435 | QGuiApplicationPrivate::platform_name = new QString(name); | - |
436 | } else { | - |
437 | QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath); | - |
438 | QString fatalMessage = | - |
439 | QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name); | - |
440 | for (QForeachContainer<__typeof__(keys)> _container_(keys); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QString &key = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
441 | fatalMessage.append(key + QLatin1Char('\n')); | - |
442 | } | - |
443 | QMessageLogger("kernel/qguiapplication.cpp", 781782, __PRETTY_FUNCTION__).fatal("%s", fatalMessage.toLocal8Bit().constData()); | - |
444 | return; | - |
445 | } | - |
446 | | - |
447 | | - |
448 | | - |
449 | const QStringList themeNames = QGuiApplicationPrivate::platform_integration->themeNames(); | - |
450 | for (QForeachContainer<__typeof__(themeNames)> _container_(themeNames); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QString &themeName = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
451 | QGuiApplicationPrivate::platform_theme = QPlatformThemeFactory::create(themeName, platformPluginPath); | - |
452 | if (QGuiApplicationPrivate::platform_theme) | - |
453 | break; | - |
454 | } | - |
455 | | - |
456 | | - |
457 | | - |
458 | if (!QGuiApplicationPrivate::platform_theme) { | - |
459 | for (QForeachContainer<__typeof__(themeNames)> _container_(themeNames); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QString &themeName = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
460 | QGuiApplicationPrivate::platform_theme = QGuiApplicationPrivate::platform_integration->createPlatformTheme(themeName); | - |
461 | if (QGuiApplicationPrivate::platform_theme) | - |
462 | break; | - |
463 | } | - |
464 | | - |
465 | } | - |
466 | | - |
467 | | - |
468 | if (!QGuiApplicationPrivate::platform_theme) | - |
469 | QGuiApplicationPrivate::platform_theme = new QPlatformTheme; | - |
470 | | - |
471 | | - |
472 | | - |
473 | | - |
474 | if (!arguments.isEmpty()) { | - |
475 | if (QObject *nativeInterface = QGuiApplicationPrivate::platform_integration->nativeInterface()) { | - |
476 | for (QForeachContainer<__typeof__(arguments)> _container_(arguments); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QString &argument = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
477 | const int equalsPos = argument.indexOf(QLatin1Char('=')); | - |
478 | const QByteArray name = | - |
479 | equalsPos != -1 ? argument.left(equalsPos).toUtf8() : argument.toUtf8(); | - |
480 | const QVariant value = | - |
481 | equalsPos != -1 ? QVariant(argument.mid(equalsPos + 1)) : QVariant(true); | - |
482 | nativeInterface->setProperty(name.constData(), value); | - |
483 | } | - |
484 | } | - |
485 | } | - |
486 | | - |
487 | | - |
488 | fontSmoothingGamma = QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal(); | - |
489 | } | - |
490 | | - |
491 | static void init_plugins(const QList<QByteArray> &pluginList) | - |
492 | { | - |
493 | for (int i = 0; i < pluginList.count(); ++i) { | - |
494 | QByteArray pluginSpec = pluginList.at(i); | - |
495 | int colonPos = pluginSpec.indexOf(':'); | - |
496 | QObject *plugin; | - |
497 | if (colonPos < 0) | - |
498 | plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString()); | - |
499 | else | - |
500 | plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)), | - |
501 | QLatin1String(pluginSpec.mid(colonPos+1))); | - |
502 | if (plugin) | - |
503 | QGuiApplicationPrivate::generic_plugin_list.append(plugin); | - |
504 | } | - |
505 | } | - |
506 | | - |
507 | void QGuiApplicationPrivate::createPlatformIntegration() | - |
508 | { | - |
509 | | - |
510 | | - |
511 | | - |
512 | QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); | - |
513 | | - |
514 | | - |
515 | QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH")); | - |
516 | | - |
517 | | - |
518 | QByteArray platformName; | - |
519 | | - |
520 | platformName = "xcb"; | - |
521 | | - |
522 | QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM"); | - |
523 | if (!platformNameEnv.isEmpty()) { partially evaluated: !platformNameEnv.isEmpty() no Evaluation Count:0 | yes Evaluation Count:289 |
| 0-289 |
524 | platformName = platformNameEnv; | - |
525 | } | 0 |
526 | | - |
527 | | - |
528 | | - |
529 | int j = argc ? 1 : 0; evaluated: argc yes Evaluation Count:221 | yes Evaluation Count:68 |
| 68-221 |
530 | for (int i=1; i<argc; i++) { evaluated: i<argc yes Evaluation Count:8 | yes Evaluation Count:289 |
| 8-289 |
531 | if (argv[i] && *argv[i] != '-') { partially evaluated: argv[i] yes Evaluation Count:8 | no Evaluation Count:0 |
evaluated: *argv[i] != '-' yes Evaluation Count:3 | yes Evaluation Count:5 |
| 0-8 |
532 | argv[j++] = argv[i]; | - |
533 | continue; executed: continue; Execution Count:3 | 3 |
534 | } | - |
535 | QByteArray arg = argv[i]; | - |
536 | if (arg == "-platformpluginpath") { partially evaluated: arg == "-platformpluginpath" no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
537 | if (++i < argc) never evaluated: ++i < argc | 0 |
538 | platformPluginPath = QLatin1String(argv[i]); never executed: platformPluginPath = QLatin1String(argv[i]); | 0 |
539 | } else if (arg == "-platform") { partially evaluated: arg == "-platform" no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
540 | if (++i < argc) never evaluated: ++i < argc | 0 |
541 | platformName = argv[i]; never executed: platformName = argv[i]; | 0 |
542 | } else { | 0 |
543 | argv[j++] = argv[i]; | - |
544 | } executed: } Execution Count:5 | 5 |
545 | } | - |
546 | | - |
547 | if (j < argc) { partially evaluated: j < argc no Evaluation Count:0 | yes Evaluation Count:289 |
| 0-289 |
548 | argv[j] = 0; | - |
549 | argc = j; | - |
550 | } | 0 |
551 | | - |
552 | init_platform(QLatin1String(platformName), platformPluginPath); | - |
553 | | - |
554 | } executed: } Execution Count:289 | 289 |
555 | | - |
556 | void QGuiApplicationPrivate::createEventDispatcher() | - |
557 | { | - |
558 | if (platform_integration == 0) | - |
559 | createPlatformIntegration(); | - |
560 | | - |
561 | if (!eventDispatcher) { | - |
562 | QAbstractEventDispatcher *eventDispatcher = platform_integration->guiThreadEventDispatcher(); | - |
563 | setEventDispatcher(eventDispatcher); | - |
564 | } | - |
565 | } | - |
566 | | - |
567 | void QGuiApplicationPrivate::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) | - |
568 | { | - |
569 | QGuiApplication * const q = q_func(); | - |
570 | | - |
571 | if (!QCoreApplicationPrivate::eventDispatcher) { | - |
572 | QCoreApplicationPrivate::eventDispatcher = eventDispatcher; | - |
573 | QCoreApplicationPrivate::eventDispatcher->setParent(q); | - |
574 | threadData->eventDispatcher = eventDispatcher; | - |
575 | } | - |
576 | | - |
577 | } | - |
578 | void QGuiApplicationPrivate::init() | - |
579 | { | - |
580 | bool doGrabUnderDebugger = false; | - |
581 | QList<QByteArray> pluginList; | - |
582 | | - |
583 | | - |
584 | int j = argc ? 1 : 0; | - |
585 | for (int i=1; i<argc; i++) { | - |
586 | if (argv[i] && *argv[i] != '-') { | - |
587 | argv[j++] = argv[i]; | - |
588 | continue; | - |
589 | } | - |
590 | QByteArray arg = argv[i]; | - |
591 | if (arg == "-plugin") { | - |
592 | if (++i < argc) | - |
593 | pluginList << argv[i]; | - |
594 | } else if (arg == "-reverse") { | - |
595 | force_reverse = true; | - |
596 | QGuiApplication::setLayoutDirection(Qt::RightToLeft); | - |
597 | } else if (arg == "-nograb") { | - |
598 | QGuiApplicationPrivate::noGrab = true; | - |
599 | } else if (arg == "-dograb") { | - |
600 | doGrabUnderDebugger = true; | - |
601 | | - |
602 | } else if (arg == "-session" && i < argc-1) { | - |
603 | ++i; | - |
604 | if (argv[i] && *argv[i]) { | - |
605 | session_id = QString::fromLatin1(argv[i]); | - |
606 | int p = session_id.indexOf(QLatin1Char('_')); | - |
607 | if (p >= 0) { | - |
608 | session_key = session_id.mid(p +1); | - |
609 | session_id = session_id.left(p); | - |
610 | } | - |
611 | is_session_restored = true; | - |
612 | } | - |
613 | | - |
614 | } else { | - |
615 | argv[j++] = argv[i]; | - |
616 | } | - |
617 | } | - |
618 | | - |
619 | if (j < argc) { | - |
620 | argv[j] = 0; | - |
621 | argc = j; | - |
622 | } | - |
623 | (void)doGrabUnderDebugger; | - |
624 | | - |
625 | | - |
626 | | - |
627 | for (QForeachContainer<__typeof__(qgetenv("QT_QPA_GENERIC_PLUGINS").split(','))> _container_(qgetenv("QT_QPA_GENERIC_PLUGINS").split(',')); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QByteArray &plugin = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
628 | pluginList << plugin; | - |
629 | | - |
630 | if (platform_integration == 0) | - |
631 | createPlatformIntegration(); | - |
632 | | - |
633 | | - |
634 | qInitDrawhelperAsm(); | - |
635 | | - |
636 | qInitImageConversions(); | - |
637 | | - |
638 | QFont::initialize(); | - |
639 | | - |
640 | | - |
641 | QCursorData::initialize(); | - |
642 | | - |
643 | | - |
644 | | - |
645 | qRegisterGuiVariant(); | - |
646 | | - |
647 | QWindowSystemInterfacePrivate::eventTime.start(); | - |
648 | | - |
649 | is_app_running = true; | - |
650 | init_plugins(pluginList); | - |
651 | QWindowSystemInterface::flushWindowSystemEvents(); | - |
652 | | - |
653 | QGuiApplication * const q = q_func(); | - |
654 | | - |
655 | | - |
656 | | - |
657 | session_manager = new QSessionManager(q, session_id, session_key); | - |
658 | | - |
659 | | - |
660 | } | - |
661 | | - |
662 | extern void qt_cleanupFontDatabase(); | - |
663 | | - |
664 | QGuiApplicationPrivate::~QGuiApplicationPrivate() | - |
665 | { | - |
666 | is_app_closing = true; | - |
667 | is_app_running = false; | - |
668 | | - |
669 | for (int i = 0; i < generic_plugin_list.count(); ++i) | - |
670 | delete generic_plugin_list.at(i); | - |
671 | generic_plugin_list.clear(); | - |
672 | | - |
673 | clearFontUnlocked(); | - |
674 | | - |
675 | QFont::cleanup(); | - |
676 | | - |
677 | | - |
678 | QCursorData::cleanup(); | - |
679 | | - |
680 | | - |
681 | layout_direction = Qt::LeftToRight; | - |
682 | | - |
683 | cleanupThreadData(); | - |
684 | | - |
685 | delete styleHints; | - |
686 | delete inputMethod; | - |
687 | | - |
688 | qt_cleanupFontDatabase(); | - |
689 | | - |
690 | QPixmapCache::clear(); | - |
691 | | - |
692 | delete platform_theme; | - |
693 | platform_theme = 0; | - |
694 | delete platform_integration; | - |
695 | platform_integration = 0; | - |
696 | delete m_gammaTables.load(); | - |
697 | } | - |
698 | Qt::KeyboardModifiers QGuiApplication::keyboardModifiers() | - |
699 | { | - |
700 | return QGuiApplicationPrivate::modifier_buttons; | - |
701 | } | - |
702 | Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers() | - |
703 | { | - |
704 | QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); | - |
705 | return pi->queryKeyboardModifiers(); | - |
706 | } | - |
707 | Qt::MouseButtons QGuiApplication::mouseButtons() | - |
708 | { | - |
709 | return QGuiApplicationPrivate::mouse_buttons; | - |
710 | } | - |
711 | | - |
712 | | - |
713 | | - |
714 | | - |
715 | | - |
716 | QPlatformNativeInterface *QGuiApplication::platformNativeInterface() | - |
717 | { | - |
718 | QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); | - |
719 | return pi ? pi->nativeInterface() : 0; | - |
720 | } | - |
721 | int QGuiApplication::exec() | - |
722 | { | - |
723 | | - |
724 | QAccessible::setRootObject((static_cast<QGuiApplication *>(QCoreApplication::instance()))); | - |
725 | | - |
726 | return QCoreApplication::exec(); | - |
727 | } | - |
728 | | - |
729 | | - |
730 | | - |
731 | bool QGuiApplication::notify(QObject *object, QEvent *event) | - |
732 | { | - |
733 | | - |
734 | if (event->type() == QEvent::KeyPress) { | - |
735 | | - |
736 | QWindow *w = qobject_cast<QWindow *>(object); | - |
737 | QObject *focus = w ? w->focusObject() : 0; | - |
738 | if (!focus) | - |
739 | focus = object; | - |
740 | if (QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(focus, static_cast<QKeyEvent *>(event))) | - |
741 | return true; | - |
742 | } | - |
743 | | - |
744 | | - |
745 | if (object->isWindowType()) | - |
746 | QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(object), event); | - |
747 | return QCoreApplication::notify(object, event); | - |
748 | } | - |
749 | | - |
750 | | - |
751 | | - |
752 | bool QGuiApplication::event(QEvent *e) | - |
753 | { | - |
754 | if(e->type() == QEvent::LanguageChange) { | - |
755 | setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight); | - |
756 | } | - |
757 | return QCoreApplication::event(e); | - |
758 | } | - |
759 | | - |
760 | | - |
761 | | - |
762 | | - |
763 | bool QGuiApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) | - |
764 | { | - |
765 | return QCoreApplication::compressEvent(event, receiver, postedEvents); | - |
766 | } | - |
767 | | - |
768 | void QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event) | - |
769 | { | - |
770 | if (!window) | - |
771 | return; | - |
772 | QPlatformWindow *platformWindow = window->handle(); | - |
773 | if (!platformWindow) | - |
774 | return; | - |
775 | | - |
776 | if (event->spontaneous()) | - |
777 | return; | - |
778 | | - |
779 | platformWindow->windowEvent(event); | - |
780 | } | - |
781 | | - |
782 | bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result) | - |
783 | { | - |
784 | return window->nativeEvent(eventType, message, result); | - |
785 | } | - |
786 | | - |
787 | void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e) | - |
788 | { | - |
789 | switch(e->type) { | - |
790 | case QWindowSystemInterfacePrivate::FrameStrutMouse: | - |
791 | case QWindowSystemInterfacePrivate::Mouse: | - |
792 | QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e)); | - |
793 | break; | - |
794 | case QWindowSystemInterfacePrivate::Wheel: | - |
795 | QGuiApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterfacePrivate::WheelEvent *>(e)); | - |
796 | break; | - |
797 | case QWindowSystemInterfacePrivate::Key: | - |
798 | QGuiApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e)); | - |
799 | break; | - |
800 | case QWindowSystemInterfacePrivate::Touch: | - |
801 | QGuiApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e)); | - |
802 | break; | - |
803 | case QWindowSystemInterfacePrivate::GeometryChange: | - |
804 | QGuiApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e)); | - |
805 | break; | - |
806 | case QWindowSystemInterfacePrivate::Enter: | - |
807 | QGuiApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e)); | - |
808 | break; | - |
809 | case QWindowSystemInterfacePrivate::Leave: | - |
810 | QGuiApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e)); | - |
811 | break; | - |
812 | case QWindowSystemInterfacePrivate::ActivatedWindow: | - |
813 | QGuiApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e)); | - |
814 | break; | - |
815 | case QWindowSystemInterfacePrivate::WindowStateChanged: | - |
816 | QGuiApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e)); | - |
817 | break; | - |
818 | case QWindowSystemInterfacePrivate::Close: | - |
819 | QGuiApplicationPrivate::processCloseEvent( | - |
820 | static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e)); | - |
821 | break; | - |
822 | case QWindowSystemInterfacePrivate::ScreenOrientation: | - |
823 | QGuiApplicationPrivate::reportScreenOrientationChange( | - |
824 | static_cast<QWindowSystemInterfacePrivate::ScreenOrientationEvent *>(e)); | - |
825 | break; | - |
826 | case QWindowSystemInterfacePrivate::ScreenGeometry: | - |
827 | QGuiApplicationPrivate::reportGeometryChange( | - |
828 | static_cast<QWindowSystemInterfacePrivate::ScreenGeometryEvent *>(e)); | - |
829 | break; | - |
830 | case QWindowSystemInterfacePrivate::ScreenAvailableGeometry: | - |
831 | QGuiApplicationPrivate::reportAvailableGeometryChange( | - |
832 | static_cast<QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *>(e)); | - |
833 | break; | - |
834 | case QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInch: | - |
835 | QGuiApplicationPrivate::reportLogicalDotsPerInchChange( | - |
836 | static_cast<QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *>(e)); | - |
837 | break; | - |
838 | case QWindowSystemInterfacePrivate::ScreenRefreshRate: | - |
839 | QGuiApplicationPrivate::reportRefreshRateChange( | - |
840 | static_cast<QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *>(e)); | - |
841 | break; | - |
842 | case QWindowSystemInterfacePrivate::ThemeChange: | - |
843 | QGuiApplicationPrivate::processThemeChanged( | - |
844 | static_cast<QWindowSystemInterfacePrivate::ThemeChangeEvent *>(e)); | - |
845 | break; | - |
846 | case QWindowSystemInterfacePrivate::Expose: | - |
847 | QGuiApplicationPrivate::processExposeEvent(static_cast<QWindowSystemInterfacePrivate::ExposeEvent *>(e)); | - |
848 | break; | - |
849 | case QWindowSystemInterfacePrivate::Tablet: | - |
850 | QGuiApplicationPrivate::processTabletEvent( | - |
851 | static_cast<QWindowSystemInterfacePrivate::TabletEvent *>(e)); | - |
852 | break; | - |
853 | case QWindowSystemInterfacePrivate::TabletEnterProximity: | - |
854 | QGuiApplicationPrivate::processTabletEnterProximityEvent( | - |
855 | static_cast<QWindowSystemInterfacePrivate::TabletEnterProximityEvent *>(e)); | - |
856 | break; | - |
857 | case QWindowSystemInterfacePrivate::TabletLeaveProximity: | - |
858 | QGuiApplicationPrivate::processTabletLeaveProximityEvent( | - |
859 | static_cast<QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *>(e)); | - |
860 | break; | - |
861 | case QWindowSystemInterfacePrivate::PlatformPanel: | - |
862 | QGuiApplicationPrivate::processPlatformPanelEvent( | - |
863 | static_cast<QWindowSystemInterfacePrivate::PlatformPanelEvent *>(e)); | - |
864 | break; | - |
865 | case QWindowSystemInterfacePrivate::FileOpen: | - |
866 | QGuiApplicationPrivate::processFileOpenEvent( | - |
867 | static_cast<QWindowSystemInterfacePrivate::FileOpenEvent *>(e)); | - |
868 | break; | - |
869 | | - |
870 | case QWindowSystemInterfacePrivate::ContextMenu: | - |
871 | QGuiApplicationPrivate::processContextMenuEvent( | - |
872 | static_cast<QWindowSystemInterfacePrivate::ContextMenuEvent *>(e)); | - |
873 | break; | - |
874 | | - |
875 | default: | - |
876 | QMessageLogger("kernel/qguiapplication.cpp", 13411333, __PRETTY_FUNCTION__).warning() << "Unknown user input event type:" << e->type; | - |
877 | break; | - |
878 | } | - |
879 | } | - |
880 | | - |
881 | void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e) | - |
882 | { | - |
883 | QEvent::Type type; | - |
884 | | - |
885 | Qt::MouseButtons stateChange = e->buttons ^ buttons; | - |
886 | const bool frameStrut = e->type == QWindowSystemInterfacePrivate::FrameStrutMouse; | - |
887 | if (e->globalPos != QGuiApplicationPrivate::lastCursorPosition && (stateChange != Qt::NoButton)) { | - |
888 | QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent = | - |
889 | new QWindowSystemInterfacePrivate::MouseEvent(e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers); | - |
890 | QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); | - |
891 | stateChange = Qt::NoButton; | - |
892 | } | - |
893 | | - |
894 | QWindow *window = e->window.data(); | - |
895 | modifier_buttons = e->modifiers; | - |
896 | | - |
897 | QPointF localPoint = e->localPos; | - |
898 | QPointF globalPoint = e->globalPos; | - |
899 | | - |
900 | if (e->nullWindow) { | - |
901 | window = QGuiApplication::topLevelAt(globalPoint.toPoint()); | - |
902 | if (window) { | - |
903 | QPointF delta = globalPoint - globalPoint.toPoint(); | - |
904 | localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; | - |
905 | } | - |
906 | } | - |
907 | | - |
908 | Qt::MouseButton button = Qt::NoButton; | - |
909 | bool doubleClick = false; | - |
910 | | - |
911 | if (QGuiApplicationPrivate::lastCursorPosition != globalPoint) { | - |
912 | type = frameStrut ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove; | - |
913 | QGuiApplicationPrivate::lastCursorPosition = globalPoint; | - |
914 | if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance|| | - |
915 | qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance) | - |
916 | mousePressButton = Qt::NoButton; | - |
917 | } else { | - |
918 | for (int check = Qt::LeftButton; | - |
919 | check <= int(Qt::MaxMouseButton); | - |
920 | check = check << 1) { | - |
921 | if (check & stateChange) { | - |
922 | button = Qt::MouseButton(check); | - |
923 | break; | - |
924 | } | - |
925 | } | - |
926 | if (button == Qt::NoButton) { | - |
927 | | - |
928 | return; | - |
929 | } | - |
930 | mouse_buttons = buttons = e->buttons; | - |
931 | if (button & e->buttons) { | - |
932 | ulong doubleClickInterval = static_cast<ulong>((static_cast<QGuiApplication *>(QCoreApplication::instance()))->styleHints()->mouseDoubleClickInterval()); | - |
933 | doubleClick = e->timestamp - mousePressTime < doubleClickInterval && button == mousePressButton; | - |
934 | type = frameStrut ? QEvent::NonClientAreaMouseButtonPress : QEvent::MouseButtonPress; | - |
935 | mousePressTime = e->timestamp; | - |
936 | mousePressButton = button; | - |
937 | const QPoint point = QGuiApplicationPrivate::lastCursorPosition.toPoint(); | - |
938 | mousePressX = point.x(); | - |
939 | mousePressY = point.y(); | - |
940 | } else { | - |
941 | type = frameStrut ? QEvent::NonClientAreaMouseButtonRelease : QEvent::MouseButtonRelease; | - |
942 | } | - |
943 | } | - |
944 | | - |
945 | if (!window) | - |
946 | return; | - |
947 | | - |
948 | if (window->d_func()->blockedByModalWindow) { | - |
949 | | - |
950 | return; | - |
951 | } | - |
952 | | - |
953 | QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, buttons, e->modifiers); | - |
954 | ev.setTimestamp(e->timestamp); | - |
955 | | - |
956 | if (const QScreen *screen = window->screen()) | - |
957 | if (QPlatformCursor *cursor = screen->handle()->cursor()) | - |
958 | cursor->pointerEvent(ev); | - |
959 | | - |
960 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - |
961 | if (!e->synthetic && !ev.isAccepted() | - |
962 | && !frameStrut | - |
963 | && (static_cast<QGuiApplication *>(QCoreApplication::instance()))->testAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents)) { | - |
964 | if (!m_fakeTouchDevice) { | - |
965 | m_fakeTouchDevice = new QTouchDevice; | - |
966 | QWindowSystemInterface::registerTouchDevice(m_fakeTouchDevice); | - |
967 | } | - |
968 | QList<QWindowSystemInterface::TouchPoint> points; | - |
969 | QWindowSystemInterface::TouchPoint point; | - |
970 | point.id = 1; | - |
971 | point.area = QRectF(globalPoint.x() - 2, globalPoint.y() - 2, 4, 4); | - |
972 | | - |
973 | | - |
974 | | - |
975 | | - |
976 | if (type == QEvent::MouseButtonPress && button == Qt::LeftButton) { | - |
977 | point.state = Qt::TouchPointPressed; | - |
978 | } else if (type == QEvent::MouseButtonRelease && button == Qt::LeftButton) { | - |
979 | point.state = Qt::TouchPointReleased; | - |
980 | } else if (type == QEvent::MouseMove && (buttons & Qt::LeftButton)) { | - |
981 | point.state = Qt::TouchPointMoved; | - |
982 | } else { | - |
983 | return; | - |
984 | } | - |
985 | | - |
986 | points << point; | - |
987 | | - |
988 | QEvent::Type type; | - |
989 | QList<QTouchEvent::TouchPoint> touchPoints = QWindowSystemInterfacePrivate::convertTouchPoints(points, &type); | - |
990 | | - |
991 | QWindowSystemInterfacePrivate::TouchEvent fake(window, e->timestamp, type, m_fakeTouchDevice, touchPoints, e->modifiers); | - |
992 | fake.synthetic = true; | - |
993 | processTouchEvent(&fake); | - |
994 | } | - |
995 | if (doubleClick) { | - |
996 | mousePressButton = Qt::NoButton; | - |
997 | const QEvent::Type doubleClickType = frameStrut ? QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick; | - |
998 | QMouseEvent dblClickEvent(doubleClickType, localPoint, localPoint, globalPoint, | - |
999 | button, buttons, e->modifiers); | - |
1000 | dblClickEvent.setTimestamp(e->timestamp); | - |
1001 | QGuiApplication::sendSpontaneousEvent(window, &dblClickEvent); | - |
1002 | } | - |
1003 | } | - |
1004 | | - |
1005 | void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e) | - |
1006 | { | - |
1007 | | - |
1008 | QWindow *window = e->window.data(); | - |
1009 | QPointF globalPoint = e->globalPos; | - |
1010 | QPointF localPoint = e->localPos; | - |
1011 | | - |
1012 | if (e->nullWindow) { | - |
1013 | window = QGuiApplication::topLevelAt(globalPoint.toPoint()); | - |
1014 | if (window) { | - |
1015 | QPointF delta = globalPoint - globalPoint.toPoint(); | - |
1016 | localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; | - |
1017 | } | - |
1018 | } | - |
1019 | | - |
1020 | if (!window) | - |
1021 | return; | - |
1022 | | - |
1023 | QGuiApplicationPrivate::lastCursorPosition = globalPoint; | - |
1024 | modifier_buttons = e->modifiers; | - |
1025 | | - |
1026 | if (window->d_func()->blockedByModalWindow) { | - |
1027 | | - |
1028 | return; | - |
1029 | } | - |
1030 | | - |
1031 | QWheelEvent ev(localPoint, globalPoint, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation, buttons, e->modifiers); | - |
1032 | ev.setTimestamp(e->timestamp); | - |
1033 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - |
1034 | | - |
1035 | } | - |
1036 | | - |
1037 | | - |
1038 | | - |
1039 | void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e) | - |
1040 | { | - |
1041 | QWindow *window = e->window.data(); | - |
1042 | modifier_buttons = e->modifiers; | - |
1043 | if (e->nullWindow) | - |
1044 | window = QGuiApplication::focusWindow(); | - |
1045 | if (!window) | - |
1046 | return; | - |
1047 | if (window->d_func()->blockedByModalWindow) { | - |
1048 | | - |
1049 | return; | - |
1050 | } | - |
1051 | | - |
1052 | QKeyEvent ev(e->keyType, e->key, e->modifiers, | - |
1053 | e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, | - |
1054 | e->unicode, e->repeat, e->repeatCount); | - |
1055 | ev.setTimestamp(e->timestamp); | - |
1056 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - |
1057 | } | - |
1058 | | - |
1059 | void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e) | - |
1060 | { | - |
1061 | if (!e->enter) | - |
1062 | return; | - |
1063 | if (e->enter.data()->d_func()->blockedByModalWindow) { | - |
1064 | | - |
1065 | return; | - |
1066 | } | - |
1067 | | - |
1068 | currentMouseWindow = e->enter; | - |
1069 | | - |
1070 | QEnterEvent event(e->localPos, e->localPos, e->globalPos); | - |
1071 | QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event); | - |
1072 | } | - |
1073 | | - |
1074 | void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e) | - |
1075 | { | - |
1076 | if (!e->leave) | - |
1077 | return; | - |
1078 | if (e->leave.data()->d_func()->blockedByModalWindow) { | - |
1079 | | - |
1080 | return; | - |
1081 | } | - |
1082 | | - |
1083 | currentMouseWindow = 0; | - |
1084 | | - |
1085 | QEvent event(QEvent::Leave); | - |
1086 | QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event); | - |
1087 | } | - |
1088 | | - |
1089 | void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e) | - |
1090 | { | - |
1091 | QWindow *previous = QGuiApplicationPrivate::focus_window; | - |
1092 | QWindow *newFocus = e->activated.data(); | - |
1093 | | - |
1094 | if (previous == newFocus) | - |
1095 | return; | - |
1096 | | - |
1097 | QObject *previousFocusObject = previous ? previous->focusObject() : 0; | - |
1098 | | - |
1099 | if (previous) { | - |
1100 | QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); | - |
1101 | QCoreApplication::sendSpontaneousEvent(previous, &focusAboutToChange); | - |
1102 | } | - |
1103 | | - |
1104 | QGuiApplicationPrivate::focus_window = newFocus; | - |
1105 | | - |
1106 | if (previous) { | - |
1107 | QFocusEvent focusOut(QEvent::FocusOut); | - |
1108 | QCoreApplication::sendSpontaneousEvent(previous, &focusOut); | - |
1109 | QObject::disconnect(previous, "2""focusObjectChanged(QObject*)", | - |
1110 | (static_cast<QGuiApplication *>(QCoreApplication::instance())), "1""_q_updateFocusObject(QObject*)"); | - |
1111 | } else { | - |
1112 | QEvent appActivate(QEvent::ApplicationActivate); | - |
1113 | (static_cast<QGuiApplication *>(QCoreApplication::instance()))->sendSpontaneousEvent((static_cast<QGuiApplication *>(QCoreApplication::instance())), &appActivate); | - |
1114 | } | - |
1115 | | - |
1116 | if (QGuiApplicationPrivate::focus_window) { | - |
1117 | QFocusEvent focusIn(QEvent::FocusIn); | - |
1118 | QCoreApplication::sendSpontaneousEvent(QGuiApplicationPrivate::focus_window, &focusIn); | - |
1119 | QObject::connect(QGuiApplicationPrivate::focus_window, "2""focusObjectChanged(QObject*)", | - |
1120 | (static_cast<QGuiApplication *>(QCoreApplication::instance())), "1""_q_updateFocusObject(QObject*)"); | - |
1121 | } else { | - |
1122 | QEvent appActivate(QEvent::ApplicationDeactivate); | - |
1123 | (static_cast<QGuiApplication *>(QCoreApplication::instance()))->sendSpontaneousEvent((static_cast<QGuiApplication *>(QCoreApplication::instance())), &appActivate); | - |
1124 | } | - |
1125 | | - |
1126 | if (self) { | - |
1127 | self->notifyActiveWindowChange(previous); | - |
1128 | | - |
1129 | if (previousFocusObject != (static_cast<QGuiApplication *>(QCoreApplication::instance()))->focusObject()) | - |
1130 | self->_q_updateFocusObject((static_cast<QGuiApplication *>(QCoreApplication::instance()))->focusObject()); | - |
1131 | } | - |
1132 | | - |
1133 | (static_cast<QGuiApplication *>(QCoreApplication::instance()))->focusWindowChanged(newFocus); | - |
1134 | } | - |
1135 | | - |
1136 | void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse) | - |
1137 | { | - |
1138 | if (QWindow *window = wse->window.data()) { | - |
1139 | QWindowStateChangeEvent e(window->windowState()); | - |
1140 | window->d_func()->windowState = wse->newState; | - |
1141 | QGuiApplication::sendSpontaneousEvent(window, &e); | - |
1142 | } | - |
1143 | } | - |
1144 | | - |
1145 | void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce) | - |
1146 | { | - |
1147 | if (self) | - |
1148 | self->notifyThemeChanged(); | - |
1149 | if (QWindow *window = tce->window.data()) { | - |
1150 | QEvent e(QEvent::ThemeChange); | - |
1151 | QGuiApplication::sendSpontaneousEvent(window, &e); | - |
1152 | } | - |
1153 | } | - |
1154 | | - |
1155 | void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e) | - |
1156 | { | - |
1157 | if (e->tlw.isNull()) | - |
1158 | return; | - |
1159 | | - |
1160 | QWindow *window = e->tlw.data(); | - |
1161 | if (!window) | - |
1162 | return; | - |
1163 | | - |
1164 | QRect newRect = e->newGeometry; | - |
1165 | QRect cr = window->d_func()->geometry; | - |
1166 | | - |
1167 | bool isResize = cr.size() != newRect.size(); | - |
1168 | bool isMove = cr.topLeft() != newRect.topLeft(); | - |
1169 | | - |
1170 | window->d_func()->geometry = newRect; | - |
1171 | | - |
1172 | if (isResize || window->d_func()->resizeEventPending) { | - |
1173 | QResizeEvent e(newRect.size(), cr.size()); | - |
1174 | QGuiApplication::sendSpontaneousEvent(window, &e); | - |
1175 | | - |
1176 | window->d_func()->resizeEventPending = false; | - |
1177 | | - |
1178 | if (cr.width() != newRect.width()) | - |
1179 | window->widthChanged(newRect.width()); | - |
1180 | if (cr.height() != newRect.height()) | - |
1181 | window->heightChanged(newRect.height()); | - |
1182 | } | - |
1183 | | - |
1184 | if (isMove) { | - |
1185 | | - |
1186 | QMoveEvent e(newRect.topLeft(), cr.topLeft()); | - |
1187 | QGuiApplication::sendSpontaneousEvent(window, &e); | - |
1188 | | - |
1189 | if (cr.x() != newRect.x()) | - |
1190 | window->xChanged(newRect.x()); | - |
1191 | if (cr.y() != newRect.y()) | - |
1192 | window->yChanged(newRect.y()); | - |
1193 | } | - |
1194 | } | - |
1195 | | - |
1196 | void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e) | - |
1197 | { | - |
1198 | if (e->window.isNull()) | - |
1199 | return; | - |
1200 | if (e->window.data()->d_func()->blockedByModalWindow) { | - |
1201 | | - |
1202 | return; | - |
1203 | } | - |
1204 | | - |
1205 | QCloseEvent event; | - |
1206 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &event); | - |
1207 | } | - |
1208 | | - |
1209 | void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e) | - |
1210 | { | - |
1211 | if (e->fileName.isEmpty()) | - |
1212 | return; | - |
1213 | | - |
1214 | QFileOpenEvent event(e->fileName); | - |
1215 | QGuiApplication::sendSpontaneousEvent((static_cast<QGuiApplication *>(QCoreApplication::instance())), &event); | - |
1216 | } | - |
1217 | | - |
1218 | void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e) | - |
1219 | { | - |
1220 | | - |
1221 | QEvent::Type type = QEvent::TabletMove; | - |
1222 | if (e->down != tabletState) { | - |
1223 | type = e->down ? QEvent::TabletPress : QEvent::TabletRelease; | - |
1224 | tabletState = e->down; | - |
1225 | } | - |
1226 | | - |
1227 | QWindow *window = e->window.data(); | - |
1228 | modifier_buttons = e->modifiers; | - |
1229 | | - |
1230 | bool localValid = true; | - |
1231 | | - |
1232 | | - |
1233 | | - |
1234 | if (type == QEvent::TabletPress) { | - |
1235 | if (e->nullWindow) { | - |
1236 | window = QGuiApplication::topLevelAt(e->global.toPoint()); | - |
1237 | localValid = false; | - |
1238 | } | - |
1239 | if (!window) | - |
1240 | return; | - |
1241 | tabletPressTarget = window; | - |
1242 | } else { | - |
1243 | if (e->nullWindow) { | - |
1244 | window = tabletPressTarget; | - |
1245 | localValid = false; | - |
1246 | } | - |
1247 | if (type == QEvent::TabletRelease) | - |
1248 | tabletPressTarget = 0; | - |
1249 | if (!window) | - |
1250 | return; | - |
1251 | } | - |
1252 | QPointF local = e->local; | - |
1253 | if (!localValid) { | - |
1254 | QPointF delta = e->global - e->global.toPoint(); | - |
1255 | local = window->mapFromGlobal(e->global.toPoint()) + delta; | - |
1256 | } | - |
1257 | QTabletEvent ev(type, local, e->global, | - |
1258 | e->device, e->pointerType, e->pressure, e->xTilt, e->yTilt, | - |
1259 | e->tangentialPressure, e->rotation, e->z, | - |
1260 | e->modifiers, e->uid); | - |
1261 | ev.setTimestamp(e->timestamp); | - |
1262 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - |
1263 | | - |
1264 | | - |
1265 | | - |
1266 | } | - |
1267 | | - |
1268 | void QGuiApplicationPrivate::processTabletEnterProximityEvent(QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e) | - |
1269 | { | - |
1270 | | - |
1271 | QTabletEvent ev(QEvent::TabletEnterProximity, QPointF(), QPointF(), | - |
1272 | e->device, e->pointerType, 0, 0, 0, | - |
1273 | 0, 0, 0, | - |
1274 | Qt::NoModifier, e->uid); | - |
1275 | ev.setTimestamp(e->timestamp); | - |
1276 | QGuiApplication::sendSpontaneousEvent((static_cast<QGuiApplication *>(QCoreApplication::instance())), &ev); | - |
1277 | | - |
1278 | | - |
1279 | | - |
1280 | } | - |
1281 | | - |
1282 | void QGuiApplicationPrivate::processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e) | - |
1283 | { | - |
1284 | | - |
1285 | QTabletEvent ev(QEvent::TabletLeaveProximity, QPointF(), QPointF(), | - |
1286 | e->device, e->pointerType, 0, 0, 0, | - |
1287 | 0, 0, 0, | - |
1288 | Qt::NoModifier, e->uid); | - |
1289 | ev.setTimestamp(e->timestamp); | - |
1290 | QGuiApplication::sendSpontaneousEvent((static_cast<QGuiApplication *>(QCoreApplication::instance())), &ev); | - |
1291 | | - |
1292 | | - |
1293 | | - |
1294 | } | - |
1295 | | - |
1296 | void QGuiApplicationPrivate::processPlatformPanelEvent(QWindowSystemInterfacePrivate::PlatformPanelEvent *e) | - |
1297 | { | - |
1298 | if (!e->window) | - |
1299 | return; | - |
1300 | | - |
1301 | if (e->window->d_func()->blockedByModalWindow) { | - |
1302 | | - |
1303 | return; | - |
1304 | } | - |
1305 | | - |
1306 | QEvent ev(QEvent::PlatformPanel); | - |
1307 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &ev); | - |
1308 | } | - |
1309 | | - |
1310 | | - |
1311 | void QGuiApplicationPrivate::processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e) | - |
1312 | { | - |
1313 | | - |
1314 | | - |
1315 | if (!e->window || e->mouseTriggered || e->window->d_func()->blockedByModalWindow) | - |
1316 | return; | - |
1317 | | - |
1318 | QContextMenuEvent ev(QContextMenuEvent::Keyboard, e->pos, e->globalPos, e->modifiers); | - |
1319 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &ev); | - |
1320 | } | - |
1321 | | - |
1322 | | - |
1323 | __attribute__((visibility("default"))) uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k) | - |
1324 | { | - |
1325 | return qHash(k.device) + k.touchPointId; | - |
1326 | } | - |
1327 | | - |
1328 | __attribute__((visibility("default"))) bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a, | - |
1329 | const QGuiApplicationPrivate::ActiveTouchPointsKey &b) | - |
1330 | { | - |
1331 | return a.device == b.device | - |
1332 | && a.touchPointId == b.touchPointId; | - |
1333 | } | - |
1334 | | - |
1335 | void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e) | - |
1336 | { | - |
1337 | QGuiApplicationPrivate *d = self; | - |
1338 | modifier_buttons = e->modifiers; | - |
1339 | | - |
1340 | if (e->touchType == QEvent::TouchCancel) { | - |
1341 | | - |
1342 | | - |
1343 | QTouchEvent touchEvent(QEvent::TouchCancel, e->device, e->modifiers); | - |
1344 | touchEvent.setTimestamp(e->timestamp); | - |
1345 | QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it | - |
1346 | = self->activeTouchPoints.constBegin(), ite = self->activeTouchPoints.constEnd(); | - |
1347 | QSet<QWindow *> windowsNeedingCancel; | - |
1348 | while (it != ite) { | - |
1349 | QWindow *w = it->window.data(); | - |
1350 | if (w) | - |
1351 | windowsNeedingCancel.insert(w); | - |
1352 | ++it; | - |
1353 | } | - |
1354 | for (QSet<QWindow *>::const_iterator winIt = windowsNeedingCancel.constBegin(), | - |
1355 | winItEnd = windowsNeedingCancel.constEnd(); winIt != winItEnd; ++winIt) { | - |
1356 | touchEvent.setWindow(*winIt); | - |
1357 | QGuiApplication::sendSpontaneousEvent(*winIt, &touchEvent); | - |
1358 | } | - |
1359 | if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic) { | - |
1360 | for (QHash<QWindow *, SynthesizedMouseData>::const_iterator synthIt = self->synthesizedMousePoints.constBegin(), | - |
1361 | synthItEnd = self->synthesizedMousePoints.constEnd(); synthIt != synthItEnd; ++synthIt) { | - |
1362 | if (!synthIt->window) | - |
1363 | continue; | - |
1364 | QWindowSystemInterfacePrivate::MouseEvent fake(synthIt->window.data(), | - |
1365 | e->timestamp, | - |
1366 | synthIt->pos, | - |
1367 | synthIt->screenPos, | - |
1368 | Qt::NoButton, | - |
1369 | e->modifiers); | - |
1370 | fake.synthetic = true; | - |
1371 | processMouseEvent(&fake); | - |
1372 | } | - |
1373 | self->synthesizedMousePoints.clear(); | - |
1374 | } | - |
1375 | self->activeTouchPoints.clear(); | - |
1376 | self->lastTouchType = e->touchType; | - |
1377 | return; | - |
1378 | } | - |
1379 | | - |
1380 | | - |
1381 | if (self->lastTouchType == QEvent::TouchCancel && e->touchType != QEvent::TouchBegin) | - |
1382 | return; | - |
1383 | | - |
1384 | self->lastTouchType = e->touchType; | - |
1385 | | - |
1386 | QWindow *window = e->window.data(); | - |
1387 | typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints; | - |
1388 | QHash<QWindow *, StatesAndTouchPoints> windowsNeedingEvents; | - |
1389 | | - |
1390 | for (int i = 0; i < e->points.count(); ++i) { | - |
1391 | QTouchEvent::TouchPoint touchPoint = e->points.at(i); | - |
1392 | | - |
1393 | | - |
1394 | | - |
1395 | touchPoint.d = touchPoint.d->detach(); | - |
1396 | | - |
1397 | | - |
1398 | QPointer<QWindow> w; | - |
1399 | QTouchEvent::TouchPoint previousTouchPoint; | - |
1400 | ActiveTouchPointsKey touchInfoKey(e->device, touchPoint.id()); | - |
1401 | ActiveTouchPointsValue &touchInfo = d->activeTouchPoints[touchInfoKey]; | - |
1402 | switch (touchPoint.state()) { | - |
1403 | case Qt::TouchPointPressed: | - |
1404 | if (e->device->type() == QTouchDevice::TouchPad) { | - |
1405 | | - |
1406 | w = d->activeTouchPoints.isEmpty() | - |
1407 | ? QPointer<QWindow>() | - |
1408 | : d->activeTouchPoints.constBegin().value().window; | - |
1409 | } | - |
1410 | | - |
1411 | if (!w) { | - |
1412 | | - |
1413 | if (!window) | - |
1414 | window = QGuiApplication::topLevelAt(touchPoint.screenPos().toPoint()); | - |
1415 | if (!window) | - |
1416 | continue; | - |
1417 | w = window; | - |
1418 | } | - |
1419 | | - |
1420 | touchInfo.window = w; | - |
1421 | touchPoint.d->startScreenPos = touchPoint.screenPos(); | - |
1422 | touchPoint.d->lastScreenPos = touchPoint.screenPos(); | - |
1423 | touchPoint.d->startNormalizedPos = touchPoint.normalizedPos(); | - |
1424 | touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos(); | - |
1425 | if (touchPoint.pressure() < qreal(0.)) | - |
1426 | touchPoint.d->pressure = qreal(1.); | - |
1427 | | - |
1428 | touchInfo.touchPoint = touchPoint; | - |
1429 | break; | - |
1430 | | - |
1431 | case Qt::TouchPointReleased: | - |
1432 | w = touchInfo.window; | - |
1433 | if (!w) | - |
1434 | continue; | - |
1435 | | - |
1436 | previousTouchPoint = touchInfo.touchPoint; | - |
1437 | touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); | - |
1438 | touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); | - |
1439 | touchPoint.d->startPos = previousTouchPoint.startPos(); | - |
1440 | touchPoint.d->lastPos = previousTouchPoint.pos(); | - |
1441 | touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); | - |
1442 | touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); | - |
1443 | if (touchPoint.pressure() < qreal(0.)) | - |
1444 | touchPoint.d->pressure = qreal(0.); | - |
1445 | | - |
1446 | break; | - |
1447 | | - |
1448 | default: | - |
1449 | w = touchInfo.window; | - |
1450 | if (!w) | - |
1451 | continue; | - |
1452 | | - |
1453 | previousTouchPoint = touchInfo.touchPoint; | - |
1454 | touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); | - |
1455 | touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); | - |
1456 | touchPoint.d->startPos = previousTouchPoint.startPos(); | - |
1457 | touchPoint.d->lastPos = previousTouchPoint.pos(); | - |
1458 | touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); | - |
1459 | touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); | - |
1460 | if (touchPoint.pressure() < qreal(0.)) | - |
1461 | touchPoint.d->pressure = qreal(1.); | - |
1462 | | - |
1463 | | - |
1464 | | - |
1465 | if (touchPoint.state() != Qt::TouchPointStationary) | - |
1466 | touchInfo.touchPoint = touchPoint; | - |
1467 | break; | - |
1468 | } | - |
1469 | | - |
1470 | qt_noop(); | - |
1471 | | - |
1472 | | - |
1473 | touchPoint.d->sceneRect = touchPoint.screenRect(); | - |
1474 | touchPoint.d->startScenePos = touchPoint.startScreenPos(); | - |
1475 | touchPoint.d->lastScenePos = touchPoint.lastScreenPos(); | - |
1476 | | - |
1477 | StatesAndTouchPoints &maskAndPoints = windowsNeedingEvents[w.data()]; | - |
1478 | maskAndPoints.first |= touchPoint.state(); | - |
1479 | maskAndPoints.second.append(touchPoint); | - |
1480 | } | - |
1481 | | - |
1482 | if (windowsNeedingEvents.isEmpty()) | - |
1483 | return; | - |
1484 | | - |
1485 | QHash<QWindow *, StatesAndTouchPoints>::ConstIterator it = windowsNeedingEvents.constBegin(); | - |
1486 | const QHash<QWindow *, StatesAndTouchPoints>::ConstIterator end = windowsNeedingEvents.constEnd(); | - |
1487 | for (; it != end; ++it) { | - |
1488 | QWindow *w = it.key(); | - |
1489 | | - |
1490 | QEvent::Type eventType; | - |
1491 | switch (it.value().first) { | - |
1492 | case Qt::TouchPointPressed: | - |
1493 | eventType = QEvent::TouchBegin; | - |
1494 | break; | - |
1495 | case Qt::TouchPointReleased: | - |
1496 | eventType = QEvent::TouchEnd; | - |
1497 | break; | - |
1498 | case Qt::TouchPointStationary: | - |
1499 | | - |
1500 | continue; | - |
1501 | default: | - |
1502 | eventType = QEvent::TouchUpdate; | - |
1503 | break; | - |
1504 | } | - |
1505 | | - |
1506 | if (w->d_func()->blockedByModalWindow) { | - |
1507 | | - |
1508 | continue; | - |
1509 | } | - |
1510 | | - |
1511 | QTouchEvent touchEvent(eventType, | - |
1512 | e->device, | - |
1513 | e->modifiers, | - |
1514 | it.value().first, | - |
1515 | it.value().second); | - |
1516 | touchEvent.setTimestamp(e->timestamp); | - |
1517 | touchEvent.setWindow(w); | - |
1518 | | - |
1519 | const int pointCount = touchEvent.touchPoints().count(); | - |
1520 | for (int i = 0; i < pointCount; ++i) { | - |
1521 | QTouchEvent::TouchPoint &touchPoint = touchEvent._touchPoints[i]; | - |
1522 | | - |
1523 | | - |
1524 | QRectF rect = touchPoint.screenRect(); | - |
1525 | const QPointF screenPos = rect.center(); | - |
1526 | const QPointF delta = screenPos - screenPos.toPoint(); | - |
1527 | | - |
1528 | rect.moveCenter(w->mapFromGlobal(screenPos.toPoint()) + delta); | - |
1529 | touchPoint.d->rect = rect; | - |
1530 | if (touchPoint.state() == Qt::TouchPointPressed) { | - |
1531 | touchPoint.d->startPos = w->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; | - |
1532 | touchPoint.d->lastPos = w->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; | - |
1533 | } | - |
1534 | } | - |
1535 | | - |
1536 | QGuiApplication::sendSpontaneousEvent(w, &touchEvent); | - |
1537 | if (!e->synthetic && !touchEvent.isAccepted() && (static_cast<QGuiApplication *>(QCoreApplication::instance()))->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) { | - |
1538 | | - |
1539 | if (touchEvent.device()->type() != QTouchDevice::TouchPad) { | - |
1540 | Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton; | - |
1541 | if (b == Qt::NoButton) | - |
1542 | self->synthesizedMousePoints.clear(); | - |
1543 | | - |
1544 | QList<QTouchEvent::TouchPoint> touchPoints = touchEvent.touchPoints(); | - |
1545 | if (eventType == QEvent::TouchBegin) | - |
1546 | m_fakeMouseSourcePointId = touchPoints.first().id(); | - |
1547 | | - |
1548 | for (int i = 0; i < touchPoints.count(); ++i) { | - |
1549 | const QTouchEvent::TouchPoint &touchPoint = touchPoints.at(i); | - |
1550 | if (touchPoint.id() == m_fakeMouseSourcePointId) { | - |
1551 | if (b != Qt::NoButton) | - |
1552 | self->synthesizedMousePoints.insert(w, SynthesizedMouseData( | - |
1553 | touchPoint.pos(), touchPoint.screenPos(), w)); | - |
1554 | QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp, | - |
1555 | touchPoint.pos(), | - |
1556 | touchPoint.screenPos(), | - |
1557 | b, e->modifiers); | - |
1558 | fake.synthetic = true; | - |
1559 | processMouseEvent(&fake); | - |
1560 | break; | - |
1561 | } | - |
1562 | } | - |
1563 | } | - |
1564 | } | - |
1565 | } | - |
1566 | | - |
1567 | | - |
1568 | | - |
1569 | | - |
1570 | | - |
1571 | for (int i = 0; i < e->points.count(); ++i) { | - |
1572 | QTouchEvent::TouchPoint touchPoint = e->points.at(i); | - |
1573 | if (touchPoint.state() == Qt::TouchPointReleased) | - |
1574 | d->activeTouchPoints.remove(ActiveTouchPointsKey(e->device, touchPoint.id())); | - |
1575 | } | - |
1576 | } | - |
1577 | | - |
1578 | void QGuiApplicationPrivate::reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e) | - |
1579 | { | - |
1580 | | - |
1581 | if (QCoreApplication::startingUp()) | - |
1582 | return; | - |
1583 | | - |
1584 | if (!e->screen) | - |
1585 | return; | - |
1586 | | - |
1587 | QScreen *s = e->screen.data(); | - |
1588 | s->d_func()->orientation = e->orientation; | - |
1589 | | - |
1590 | updateFilteredScreenOrientation(s); | - |
1591 | } | - |
1592 | | - |
1593 | void QGuiApplicationPrivate::updateFilteredScreenOrientation(QScreen *s) | - |
1594 | { | - |
1595 | Qt::ScreenOrientation o = s->d_func()->orientation; | - |
1596 | if (o == Qt::PrimaryOrientation) | - |
1597 | o = s->primaryOrientation(); | - |
1598 | o = Qt::ScreenOrientation(o & s->orientationUpdateMask()); | - |
1599 | if (o == Qt::PrimaryOrientation) | - |
1600 | return; | - |
1601 | if (o == s->d_func()->filteredOrientation) | - |
1602 | return; | - |
1603 | s->d_func()->filteredOrientation = o; | - |
1604 | reportScreenOrientationChange(s); | - |
1605 | } | - |
1606 | | - |
1607 | void QGuiApplicationPrivate::reportScreenOrientationChange(QScreen *s) | - |
1608 | { | - |
1609 | s->orientationChanged(s->orientation()); | - |
1610 | | - |
1611 | QScreenOrientationChangeEvent event(s, s->orientation()); | - |
1612 | QCoreApplication::sendEvent(QCoreApplication::instance(), &event); | - |
1613 | } | - |
1614 | | - |
1615 | void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e) | - |
1616 | { | - |
1617 | | - |
1618 | if (QCoreApplication::startingUp()) | - |
1619 | return; | - |
1620 | | - |
1621 | if (!e->screen) | - |
1622 | return; | - |
1623 | | - |
1624 | QScreen *s = e->screen.data(); | - |
1625 | s->d_func()->geometry = e->geometry; | - |
1626 | | - |
1627 | Qt::ScreenOrientation primaryOrientation = s->primaryOrientation(); | - |
1628 | s->d_func()->updatePrimaryOrientation(); | - |
1629 | | - |
1630 | s->geometryChanged(s->geometry()); | - |
1631 | s->physicalSizeChanged(s->physicalSize()); | - |
1632 | s->physicalDotsPerInchChanged(s->physicalDotsPerInch()); | - |
1633 | s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); | - |
1634 | for (QForeachContainer<__typeof__(s->virtualSiblings())> _container_(s->virtualSiblings()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QScreen* sibling = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
1635 | sibling->virtualGeometryChanged(sibling->virtualGeometry()); | - |
1636 | | - |
1637 | if (s->primaryOrientation() != primaryOrientation) | - |
1638 | s->primaryOrientationChanged(s->primaryOrientation()); | - |
1639 | | - |
1640 | if (s->d_func()->orientation == Qt::PrimaryOrientation) | - |
1641 | updateFilteredScreenOrientation(s); | - |
1642 | } | - |
1643 | | - |
1644 | void QGuiApplicationPrivate::reportAvailableGeometryChange( | - |
1645 | QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e) | - |
1646 | { | - |
1647 | | - |
1648 | if (QCoreApplication::startingUp()) | - |
1649 | return; | - |
1650 | | - |
1651 | if (!e->screen) | - |
1652 | return; | - |
1653 | | - |
1654 | QScreen *s = e->screen.data(); | - |
1655 | s->d_func()->availableGeometry = e->availableGeometry; | - |
1656 | | - |
1657 | for (QForeachContainer<__typeof__(s->virtualSiblings())> _container_(s->virtualSiblings()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QScreen* sibling = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
1658 | sibling->virtualGeometryChanged(sibling->virtualGeometry()); | - |
1659 | } | - |
1660 | | - |
1661 | void QGuiApplicationPrivate::reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e) | - |
1662 | { | - |
1663 | | - |
1664 | if (QCoreApplication::startingUp()) | - |
1665 | return; | - |
1666 | | - |
1667 | if (!e->screen) | - |
1668 | return; | - |
1669 | | - |
1670 | QScreen *s = e->screen.data(); | - |
1671 | s->d_func()->logicalDpi = QDpi(e->dpiX, e->dpiY); | - |
1672 | | - |
1673 | s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); | - |
1674 | } | - |
1675 | | - |
1676 | void QGuiApplicationPrivate::reportRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e) | - |
1677 | { | - |
1678 | | - |
1679 | if (QCoreApplication::startingUp()) | - |
1680 | return; | - |
1681 | | - |
1682 | if (!e->screen) | - |
1683 | return; | - |
1684 | | - |
1685 | QScreen *s = e->screen.data(); | - |
1686 | s->d_func()->refreshRate = e->rate; | - |
1687 | | - |
1688 | s->refreshRateChanged(s->refreshRate()); | - |
1689 | } | - |
1690 | | - |
1691 | void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e) | - |
1692 | { | - |
1693 | if (!e->exposed) | - |
1694 | return; | - |
1695 | | - |
1696 | QWindow *window = e->exposed.data(); | - |
1697 | QWindowPrivate *p = qt_window_private(window); | - |
1698 | | - |
1699 | if (!p->receivedExpose) { | - |
1700 | if (p->resizeEventPending) { | - |
1701 | | - |
1702 | QSize size = p->geometry.size(); | - |
1703 | QResizeEvent e(size, size); | - |
1704 | QGuiApplication::sendSpontaneousEvent(window, &e); | - |
1705 | | - |
1706 | p->resizeEventPending = false; | - |
1707 | } | - |
1708 | | - |
1709 | p->receivedExpose = true; | - |
1710 | } | - |
1711 | | - |
1712 | p->exposed = e->isExposed; | - |
1713 | | - |
1714 | QExposeEvent exposeEvent(e->region); | - |
1715 | QCoreApplication::sendSpontaneousEvent(window, &exposeEvent); | - |
1716 | } | - |
1717 | | - |
1718 | | - |
1719 | | - |
1720 | QPlatformDragQtResponse QGuiApplicationPrivate::processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) | - |
1721 | { | - |
1722 | static QPointer<QWindow> currentDragWindow; | - |
1723 | static Qt::DropAction lastAcceptedDropAction = Qt::IgnoreAction; | - |
1724 | QPlatformDrag *platformDrag = platformIntegration()->drag(); | - |
1725 | if (!platformDrag) { | - |
1726 | lastAcceptedDropAction = Qt::IgnoreAction; | - |
1727 | return QPlatformDragQtResponse(false, lastAcceptedDropAction, QRect()); | - |
1728 | } | - |
1729 | | - |
1730 | if (!dropData) { | - |
1731 | if (currentDragWindow.data() == w) | - |
1732 | currentDragWindow = 0; | - |
1733 | QDragLeaveEvent e; | - |
1734 | QGuiApplication::sendEvent(w, &e); | - |
1735 | lastAcceptedDropAction = Qt::IgnoreAction; | - |
1736 | return QPlatformDragQtResponse(false, lastAcceptedDropAction, QRect()); | - |
1737 | } | - |
1738 | QDragMoveEvent me(p, supportedActions, dropData, | - |
1739 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - |
1740 | | - |
1741 | if (w != currentDragWindow) { | - |
1742 | lastAcceptedDropAction = Qt::IgnoreAction; | - |
1743 | if (currentDragWindow) { | - |
1744 | QDragLeaveEvent e; | - |
1745 | QGuiApplication::sendEvent(currentDragWindow, &e); | - |
1746 | } | - |
1747 | currentDragWindow = w; | - |
1748 | QDragEnterEvent e(p, supportedActions, dropData, | - |
1749 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - |
1750 | QGuiApplication::sendEvent(w, &e); | - |
1751 | if (e.isAccepted() && e.dropAction() != Qt::IgnoreAction) | - |
1752 | lastAcceptedDropAction = e.dropAction(); | - |
1753 | } | - |
1754 | | - |
1755 | | - |
1756 | if (lastAcceptedDropAction != Qt::IgnoreAction | - |
1757 | && (supportedActions & lastAcceptedDropAction)) { | - |
1758 | me.setDropAction(lastAcceptedDropAction); | - |
1759 | me.accept(); | - |
1760 | } | - |
1761 | QGuiApplication::sendEvent(w, &me); | - |
1762 | lastAcceptedDropAction = me.isAccepted() ? | - |
1763 | me.dropAction() : Qt::IgnoreAction; | - |
1764 | return QPlatformDragQtResponse(me.isAccepted(), lastAcceptedDropAction, me.answerRect()); | - |
1765 | } | - |
1766 | | - |
1767 | QPlatformDropQtResponse QGuiApplicationPrivate::processDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) | - |
1768 | { | - |
1769 | QDropEvent de(p, supportedActions, dropData, | - |
1770 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - |
1771 | QGuiApplication::sendEvent(w, &de); | - |
1772 | | - |
1773 | Qt::DropAction acceptedAction = de.isAccepted() ? de.dropAction() : Qt::IgnoreAction; | - |
1774 | QPlatformDropQtResponse response(de.isAccepted(),acceptedAction); | - |
1775 | return response; | - |
1776 | } | - |
1777 | | - |
1778 | | - |
1779 | | - |
1780 | | - |
1781 | | - |
1782 | | - |
1783 | | - |
1784 | QClipboard * QGuiApplication::clipboard() | - |
1785 | { | - |
1786 | if (QGuiApplicationPrivate::qt_clipboard == 0) { | - |
1787 | if (!(static_cast<QGuiApplication *>(QCoreApplication::instance()))) { | - |
1788 | QMessageLogger("kernel/qguiapplication.cpp", 22532245, __PRETTY_FUNCTION__).warning("QGuiApplication: Must construct a QGuiApplication before accessing a QClipboard"); | - |
1789 | return 0; | - |
1790 | } | - |
1791 | QGuiApplicationPrivate::qt_clipboard = new QClipboard(0); | - |
1792 | } | - |
1793 | return QGuiApplicationPrivate::qt_clipboard; | - |
1794 | } | - |
1795 | QPalette QGuiApplication::palette() | - |
1796 | { | - |
1797 | initPalette(); | - |
1798 | return *QGuiApplicationPrivate::app_pal; | - |
1799 | } | - |
1800 | | - |
1801 | | - |
1802 | | - |
1803 | | - |
1804 | | - |
1805 | | - |
1806 | void QGuiApplication::setPalette(const QPalette &pal) | - |
1807 | { | - |
1808 | if (QGuiApplicationPrivate::app_pal && pal.isCopyOf(*QGuiApplicationPrivate::app_pal)) | - |
1809 | return; | - |
1810 | if (!QGuiApplicationPrivate::app_pal) | - |
1811 | QGuiApplicationPrivate::app_pal = new QPalette(pal); | - |
1812 | else | - |
1813 | *QGuiApplicationPrivate::app_pal = pal; | - |
1814 | applicationResourceFlags |= ApplicationPaletteExplicitlySet; | - |
1815 | } | - |
1816 | | - |
1817 | | - |
1818 | | - |
1819 | | - |
1820 | | - |
1821 | | - |
1822 | QFont QGuiApplication::font() | - |
1823 | { | - |
1824 | qt_noop(); | - |
1825 | QMutexLocker locker(&applicationFontMutex); | - |
1826 | initFontUnlocked(); | - |
1827 | return *QGuiApplicationPrivate::app_font; executed: return *QGuiApplicationPrivate::app_font; Execution Count:1200852 | 1200852 |
1828 | } | - |
1829 | | - |
1830 | | - |
1831 | | - |
1832 | | - |
1833 | | - |
1834 | | - |
1835 | void QGuiApplication::setFont(const QFont &font) | - |
1836 | { | - |
1837 | QMutexLocker locker(&applicationFontMutex); | - |
1838 | if (!QGuiApplicationPrivate::app_font) | - |
1839 | QGuiApplicationPrivate::app_font = new QFont(font); | - |
1840 | else | - |
1841 | *QGuiApplicationPrivate::app_font = font; | - |
1842 | applicationResourceFlags |= ApplicationFontExplicitlySet; | - |
1843 | } | - |
1844 | void QGuiApplicationPrivate::notifyLayoutDirectionChange() | - |
1845 | { | - |
1846 | } | - |
1847 | | - |
1848 | void QGuiApplicationPrivate::notifyActiveWindowChange(QWindow *) | - |
1849 | { | - |
1850 | } | - |
1851 | void QGuiApplication::setQuitOnLastWindowClosed(bool quit) | - |
1852 | { | - |
1853 | QCoreApplication::setQuitLockEnabled(quit); | - |
1854 | } | - |
1855 | | - |
1856 | | - |
1857 | | - |
1858 | bool QGuiApplication::quitOnLastWindowClosed() | - |
1859 | { | - |
1860 | return QCoreApplication::isQuitLockEnabled(); | - |
1861 | } | - |
1862 | void QGuiApplicationPrivate::emitLastWindowClosed() | - |
1863 | { | - |
1864 | if ((static_cast<QGuiApplication *>(QCoreApplication::instance())) && (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->in_exec) { | - |
1865 | (static_cast<QGuiApplication *>(QCoreApplication::instance()))->lastWindowClosed(); | - |
1866 | } | - |
1867 | } | - |
1868 | | - |
1869 | bool QGuiApplicationPrivate::shouldQuit() | - |
1870 | { | - |
1871 | | - |
1872 | QWindowList list = QGuiApplication::topLevelWindows(); | - |
1873 | for (int i = 0; i < list.size(); ++i) { | - |
1874 | QWindow *w = list.at(i); | - |
1875 | if (w->isVisible() && !w->transientParent()) | - |
1876 | return false; | - |
1877 | } | - |
1878 | return true; | - |
1879 | } | - |
1880 | bool QGuiApplication::isSessionRestored() const | - |
1881 | { | - |
1882 | const QGuiApplicationPrivate * const d = d_func(); | - |
1883 | return d->is_session_restored; | - |
1884 | } | - |
1885 | | - |
1886 | QString QGuiApplication::sessionId() const | - |
1887 | { | - |
1888 | const QGuiApplicationPrivate * const d = d_func(); | - |
1889 | return d->session_id; | - |
1890 | } | - |
1891 | | - |
1892 | QString QGuiApplication::sessionKey() const | - |
1893 | { | - |
1894 | const QGuiApplicationPrivate * const d = d_func(); | - |
1895 | return d->session_key; | - |
1896 | } | - |
1897 | | - |
1898 | bool QGuiApplication::isSavingSession() const | - |
1899 | { | - |
1900 | const QGuiApplicationPrivate * const d = d_func(); | - |
1901 | return d->is_saving_session; | - |
1902 | } | - |
1903 | | - |
1904 | void QGuiApplicationPrivate::commitData(QSessionManager& manager) | - |
1905 | { | - |
1906 | QGuiApplication * const q = q_func(); | - |
1907 | is_saving_session = true; | - |
1908 | q->commitDataRequest(manager); | - |
1909 | if (manager.allowsInteraction()) { | - |
1910 | QWindowList done; | - |
1911 | QWindowList list = QGuiApplication::topLevelWindows(); | - |
1912 | bool cancelled = false; | - |
1913 | for (int i = 0; !cancelled && i < list.size(); ++i) { | - |
1914 | QWindow* w = list.at(i); | - |
1915 | if (w->isVisible() && !done.contains(w)) { | - |
1916 | cancelled = !w->close(); | - |
1917 | if (!cancelled) | - |
1918 | done.append(w); | - |
1919 | list = QGuiApplication::topLevelWindows(); | - |
1920 | i = -1; | - |
1921 | } | - |
1922 | } | - |
1923 | if (cancelled) | - |
1924 | manager.cancel(); | - |
1925 | } | - |
1926 | is_saving_session = false; | - |
1927 | } | - |
1928 | | - |
1929 | | - |
1930 | void QGuiApplicationPrivate::saveState(QSessionManager &manager) | - |
1931 | { | - |
1932 | QGuiApplication * const q = q_func(); | - |
1933 | is_saving_session = true; | - |
1934 | q->saveStateRequest(manager); | - |
1935 | is_saving_session = false; | - |
1936 | } | - |
1937 | void QGuiApplication::setLayoutDirection(Qt::LayoutDirection direction) | - |
1938 | { | - |
1939 | if (layout_direction == direction || direction == Qt::LayoutDirectionAuto) | - |
1940 | return; | - |
1941 | | - |
1942 | layout_direction = direction; | - |
1943 | | - |
1944 | QGuiApplicationPrivate::self->notifyLayoutDirectionChange(); | - |
1945 | } | - |
1946 | | - |
1947 | Qt::LayoutDirection QGuiApplication::layoutDirection() | - |
1948 | { | - |
1949 | return layout_direction; | - |
1950 | } | - |
1951 | QCursor *QGuiApplication::overrideCursor() | - |
1952 | { | - |
1953 | return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->cursor_list.isEmpty() ? 0 : &(static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->cursor_list.first(); | - |
1954 | } | - |
1955 | void QGuiApplication::changeOverrideCursor(const QCursor &cursor) | - |
1956 | { | - |
1957 | if ((static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->cursor_list.isEmpty()) | - |
1958 | return; | - |
1959 | (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->cursor_list.removeFirst(); | - |
1960 | setOverrideCursor(cursor); | - |
1961 | } | - |
1962 | | - |
1963 | | - |
1964 | | - |
1965 | | - |
1966 | static inline void applyCursor(QWindow *w, QCursor c) | - |
1967 | { | - |
1968 | if (const QScreen *screen = w->screen()) | - |
1969 | if (QPlatformCursor *cursor = screen->handle()->cursor()) | - |
1970 | cursor->changeCursor(&c, w); | - |
1971 | } | - |
1972 | | - |
1973 | static inline void applyCursor(const QList<QWindow *> &l, const QCursor &c) | - |
1974 | { | - |
1975 | for (int i = 0; i < l.size(); ++i) { | - |
1976 | QWindow *w = l.at(i); | - |
1977 | if (w->handle() && w->type() != Qt::Desktop) | - |
1978 | applyCursor(w, c); | - |
1979 | } | - |
1980 | } | - |
1981 | | - |
1982 | static inline void applyWindowCursor(const QList<QWindow *> &l) | - |
1983 | { | - |
1984 | for (int i = 0; i < l.size(); ++i) { | - |
1985 | QWindow *w = l.at(i); | - |
1986 | if (w->handle() && w->type() != Qt::Desktop) | - |
1987 | applyCursor(w, w->cursor()); | - |
1988 | } | - |
1989 | } | - |
1990 | void QGuiApplication::setOverrideCursor(const QCursor &cursor) | - |
1991 | { | - |
1992 | (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->cursor_list.prepend(cursor); | - |
1993 | applyCursor(QGuiApplicationPrivate::window_list, cursor); | - |
1994 | } | - |
1995 | void QGuiApplication::restoreOverrideCursor() | - |
1996 | { | - |
1997 | if ((static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->cursor_list.isEmpty()) | - |
1998 | return; | - |
1999 | (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->cursor_list.removeFirst(); | - |
2000 | if ((static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->cursor_list.size() > 0) { | - |
2001 | QCursor c((static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->cursor_list.value(0)); | - |
2002 | applyCursor(QGuiApplicationPrivate::window_list, c); | - |
2003 | } else { | - |
2004 | applyWindowCursor(QGuiApplicationPrivate::window_list); | - |
2005 | } | - |
2006 | } | - |
2007 | QStyleHints *QGuiApplication::styleHints() | - |
2008 | { | - |
2009 | if (!(static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->styleHints) | - |
2010 | (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->styleHints = new QStyleHints(); | - |
2011 | return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->styleHints; | - |
2012 | } | - |
2013 | void QGuiApplication::setDesktopSettingsAware(bool on) | - |
2014 | { | - |
2015 | QGuiApplicationPrivate::obey_desktop_settings = on; | - |
2016 | } | - |
2017 | | - |
2018 | | - |
2019 | | - |
2020 | | - |
2021 | | - |
2022 | | - |
2023 | | - |
2024 | bool QGuiApplication::desktopSettingsAware() | - |
2025 | { | - |
2026 | return QGuiApplicationPrivate::obey_desktop_settings; | - |
2027 | } | - |
2028 | QInputMethod *QGuiApplication::inputMethod() | - |
2029 | { | - |
2030 | if (!(static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->inputMethod) | - |
2031 | (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->inputMethod = new QInputMethod(); | - |
2032 | return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->d_func()->inputMethod; | - |
2033 | } | - |
2034 | static const char * const move_xpm[] = { | - |
2035 | "11 20 3 1", | - |
2036 | ". c None", | - |
2037 | "a c #FFFFFF", | - |
2038 | "X c #000000", | - |
2039 | "aa.........", | - |
2040 | "aXa........", | - |
2041 | "aXXa.......", | - |
2042 | "aXXXa......", | - |
2043 | "aXXXXa.....", | - |
2044 | "aXXXXXa....", | - |
2045 | "aXXXXXXa...", | - |
2046 | "aXXXXXXXa..", | - |
2047 | "aXXXXXXXXa.", | - |
2048 | "aXXXXXXXXXa", | - |
2049 | "aXXXXXXaaaa", | - |
2050 | "aXXXaXXa...", | - |
2051 | "aXXaaXXa...", | - |
2052 | "aXa..aXXa..", | - |
2053 | "aa...aXXa..", | - |
2054 | "a.....aXXa.", | - |
2055 | "......aXXa.", | - |
2056 | ".......aXXa", | - |
2057 | ".......aXXa", | - |
2058 | "........aa."}; | - |
2059 | | - |
2060 | | - |
2061 | | - |
2062 | static const char * const copy_xpm[] = { | - |
2063 | "24 30 3 1", | - |
2064 | ". c None", | - |
2065 | "a c #000000", | - |
2066 | "X c #FFFFFF", | - |
2067 | "XX......................", | - |
2068 | "XaX.....................", | - |
2069 | "XaaX....................", | - |
2070 | "XaaaX...................", | - |
2071 | "XaaaaX..................", | - |
2072 | "XaaaaaX.................", | - |
2073 | "XaaaaaaX................", | - |
2074 | "XaaaaaaaX...............", | - |
2075 | "XaaaaaaaaX..............", | - |
2076 | "XaaaaaaaaaX.............", | - |
2077 | "XaaaaaaXXXX.............", | - |
2078 | "XaaaXaaX................", | - |
2079 | "XaaXXaaX................", | - |
2080 | "XaX..XaaX...............", | - |
2081 | "XX...XaaX...............", | - |
2082 | "X.....XaaX..............", | - |
2083 | "......XaaX..............", | - |
2084 | ".......XaaX.............", | - |
2085 | ".......XaaX.............", | - |
2086 | "........XX...aaaaaaaaaaa", | - |
2087 | ".............aXXXXXXXXXa", | - |
2088 | ".............aXXXXXXXXXa", | - |
2089 | ".............aXXXXaXXXXa", | - |
2090 | ".............aXXXXaXXXXa", | - |
2091 | ".............aXXaaaaaXXa", | - |
2092 | ".............aXXXXaXXXXa", | - |
2093 | ".............aXXXXaXXXXa", | - |
2094 | ".............aXXXXXXXXXa", | - |
2095 | ".............aXXXXXXXXXa", | - |
2096 | ".............aaaaaaaaaaa"}; | - |
2097 | | - |
2098 | | - |
2099 | static const char * const link_xpm[] = { | - |
2100 | "24 30 3 1", | - |
2101 | ". c None", | - |
2102 | "a c #000000", | - |
2103 | "X c #FFFFFF", | - |
2104 | "XX......................", | - |
2105 | "XaX.....................", | - |
2106 | "XaaX....................", | - |
2107 | "XaaaX...................", | - |
2108 | "XaaaaX..................", | - |
2109 | "XaaaaaX.................", | - |
2110 | "XaaaaaaX................", | - |
2111 | "XaaaaaaaX...............", | - |
2112 | "XaaaaaaaaX..............", | - |
2113 | "XaaaaaaaaaX.............", | - |
2114 | "XaaaaaaXXXX.............", | - |
2115 | "XaaaXaaX................", | - |
2116 | "XaaXXaaX................", | - |
2117 | "XaX..XaaX...............", | - |
2118 | "XX...XaaX...............", | - |
2119 | "X.....XaaX..............", | - |
2120 | "......XaaX..............", | - |
2121 | ".......XaaX.............", | - |
2122 | ".......XaaX.............", | - |
2123 | "........XX...aaaaaaaaaaa", | - |
2124 | ".............aXXXXXXXXXa", | - |
2125 | ".............aXXXaaaaXXa", | - |
2126 | ".............aXXXXaaaXXa", | - |
2127 | ".............aXXXaaaaXXa", | - |
2128 | ".............aXXaaaXaXXa", | - |
2129 | ".............aXXaaXXXXXa", | - |
2130 | ".............aXXaXXXXXXa", | - |
2131 | ".............aXXXaXXXXXa", | - |
2132 | ".............aXXXXXXXXXa", | - |
2133 | ".............aaaaaaaaaaa"}; | - |
2134 | | - |
2135 | QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) | - |
2136 | { | - |
2137 | (void)cshape;; | - |
2138 | return QPixmap(); | - |
2139 | } | - |
2140 | | - |
2141 | void QGuiApplicationPrivate::notifyThemeChanged() | - |
2142 | { | - |
2143 | if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet)) { | - |
2144 | clearPalette(); | - |
2145 | initPalette(); | - |
2146 | } | - |
2147 | if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { | - |
2148 | QMutexLocker locker(&applicationFontMutex); | - |
2149 | clearFontUnlocked(); | - |
2150 | initFontUnlocked(); | - |
2151 | } | - |
2152 | } | - |
2153 | | - |
2154 | | - |
2155 | void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag) | - |
2156 | { | - |
2157 | (void)drag; | - |
2158 | | - |
2159 | } | - |
2160 | | - |
2161 | | - |
2162 | const QDrawHelperGammaTables *QGuiApplicationPrivate::gammaTables() | - |
2163 | { | - |
2164 | QDrawHelperGammaTables *result = m_gammaTables.load(); | - |
2165 | if (!result){ | - |
2166 | QDrawHelperGammaTables *tables = new QDrawHelperGammaTables(fontSmoothingGamma); | - |
2167 | if (!m_gammaTables.testAndSetRelease(0, tables)) | - |
2168 | delete tables; | - |
2169 | result = m_gammaTables.load(); | - |
2170 | } | - |
2171 | return result; | - |
2172 | } | - |
2173 | | - |
2174 | void QGuiApplicationPrivate::_q_updateFocusObject(QObject *object) | - |
2175 | { | - |
2176 | QGuiApplication * const q = q_func(); | - |
2177 | | - |
2178 | bool enabled = false; | - |
2179 | if (object) { | - |
2180 | QInputMethodQueryEvent query(Qt::ImEnabled); | - |
2181 | QGuiApplication::sendEvent(object, &query); | - |
2182 | enabled = query.value(Qt::ImEnabled).toBool(); | - |
2183 | } | - |
2184 | | - |
2185 | QPlatformInputContextPrivate::setInputMethodAccepted(enabled); | - |
2186 | QPlatformInputContext *inputContext = platformIntegration()->inputContext(); | - |
2187 | if (inputContext) | - |
2188 | inputContext->setFocusObject(object); | - |
2189 | q->focusObjectChanged(object); | - |
2190 | } | - |
2191 | | - |
2192 | int QGuiApplicationPrivate::mouseEventCaps(QMouseEvent *event) | - |
2193 | { | - |
2194 | return event->caps; | - |
2195 | } | - |
2196 | | - |
2197 | QVector2D QGuiApplicationPrivate::mouseEventVelocity(QMouseEvent *event) | - |
2198 | { | - |
2199 | return event->velocity; | - |
2200 | } | - |
2201 | | - |
2202 | void QGuiApplicationPrivate::setMouseEventCapsAndVelocity(QMouseEvent *event, int caps, const QVector2D &velocity) | - |
2203 | { | - |
2204 | event->caps = caps; | - |
2205 | event->velocity = velocity; | - |
2206 | } | - |
2207 | | - |
2208 | void QGuiApplicationPrivate::setMouseEventCapsAndVelocity(QMouseEvent *event, QMouseEvent *other) | - |
2209 | { | - |
2210 | event->caps = other->caps; | - |
2211 | event->velocity = other->velocity; | - |
2212 | } | - |
2213 | | - |
2214 | | - |
2215 | | - |
2216 | | - |
2217 | | - |
| | |