qwindow.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qwindow.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12QWindow::QWindow(QScreen *targetScreen)-
13 : QObject(*new QWindowPrivate(), 0)-
14 , QSurface(QSurface::Window)-
15{-
16 QWindowPrivate * const d = d_func();-
17 d->connectToScreen(targetScreen ? targetScreen : QGuiApplication::primaryScreen());-
18 d->init();-
19}-
20QWindow::QWindow(QWindow *parent)-
21 : QObject(*new QWindowPrivate(), parent)-
22 , QSurface(QSurface::Window)-
23{-
24 QWindowPrivate * const d = d_func();-
25 d->parentWindow = parent;-
26 if (!parent)-
27 d->connectToScreen(QGuiApplication::primaryScreen());-
28 d->init();-
29}-
30QWindow::QWindow(QWindowPrivate &dd, QWindow *parent)-
31 : QObject(dd, parent)-
32 , QSurface(QSurface::Window)-
33{-
34 QWindowPrivate * const d = d_func();-
35 d->parentWindow = parent;-
36 if (!parent)-
37 d->connectToScreen(QGuiApplication::primaryScreen());-
38 d->init();-
39}-
40-
41-
42-
43-
44QWindow::~QWindow()-
45{-
46 destroy();-
47 QGuiApplicationPrivate::window_list.removeAll(this);-
48 if (!QGuiApplicationPrivate::is_app_closing)-
49 QGuiApplicationPrivate::instance()->modalWindowList.removeOne(this);-
50}-
51-
52void QWindowPrivate::init()-
53{-
54 QWindow * const q = q_func();-
55-
56-
57-
58 if (!(__builtin_expect(!!(!
__builtin_expe...creen), false)Description
TRUEnever evaluated
FALSEnever evaluated
parentWindow && !topLevelScreen)), false)
__builtin_expe...creen), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
59 QMessageLogger(__FILE__, 218224, __PRETTY_FUNCTION__).fatal("Cannot create window: no screens available");-
60 exit(1);
never executed: exit(1);
0
61 }-
62 QGuiApplicationPrivate::window_list.prepend(q);-
63-
64 requestedFormat = QSurfaceFormat::defaultFormat();-
65}
never executed: end of block
0
66QWindow::Visibility QWindow::visibility() const-
67{-
68 const QWindowPrivate * const d = d_func();-
69 return d->visibility;-
70}-
71-
72void QWindow::setVisibility(Visibility v)-
73{-
74 switch (v) {-
75 case Hidden:-
76 hide();-
77 break;-
78 case AutomaticVisibility:-
79 show();-
80 break;-
81 case Windowed:-
82 showNormal();-
83 break;-
84 case Minimized:-
85 showMinimized();-
86 break;-
87 case Maximized:-
88 showMaximized();-
89 break;-
90 case FullScreen:-
91 showFullScreen();-
92 break;-
93 default:-
94 ((!(false)) ? qt_assert("false",__FILE__,303309) : qt_noop());-
95 break;-
96 }-
97}-
98-
99void QWindowPrivate::updateVisibility()-
100{-
101 QWindow * const q = q_func();-
102-
103 QWindow::Visibility old = visibility;-
104-
105 if (visible) {-
106 switch (windowState) {-
107 case Qt::WindowMinimized:-
108 visibility = QWindow::Minimized;-
109 break;-
110 case Qt::WindowMaximized:-
111 visibility = QWindow::Maximized;-
112 break;-
113 case Qt::WindowFullScreen:-
114 visibility = QWindow::FullScreen;-
115 break;-
116 case Qt::WindowNoState:-
117 visibility = QWindow::Windowed;-
118 break;-
119 default:-
120 ((!(false)) ? qt_assert("false",__FILE__,329335) : qt_noop());-
121 break;-
122 }-
123 } else {-
124 visibility = QWindow::Hidden;-
125 }-
126-
127 if (visibility != old)-
128 q->visibilityChanged(visibility);-
129}-
130-
131inline bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const-
132{-
133 const QWindow * const q = q_func();-
134 const QScreen *oldScreen = q->screen();-
135 return oldScreen != newScreen && (platformWindow || !oldScreen)-
136 && !(oldScreen && oldScreen->virtualSiblings().contains(newScreen));-
137}-
138-
139inline void QWindowPrivate::disconnectFromScreen()-
140{-
141 if (topLevelScreen)-
142 topLevelScreen = 0;-
143}-
144-
145void QWindowPrivate::connectToScreen(QScreen *screen)-
146{-
147 disconnectFromScreen();-
148 topLevelScreen = screen;-
149}-
150-
151void QWindowPrivate::emitScreenChangedRecursion(QScreen *newScreen)-
152{-
153 QWindow * const q = q_func();-
154 q->screenChanged(newScreen);-
155 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(q->children())>::type> _container_((q->children())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QObject *child = *_container_.i; _container_.control; _container_.control = 0): q->children()) {-
156 if (child->isWindowType()
child->isWindowType()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
157 static_cast<
never executed: static_cast<QWindow *>(child)->d_func()->emitScreenChangedRecursion(newScreen);
QWindow *>(child)->d_func()->emitScreenChangedRecursion(newScreen);
never executed: static_cast<QWindow *>(child)->d_func()->emitScreenChangedRecursion(newScreen);
0
158 }
never executed: end of block
0
159}
never executed: end of block
0
160-
161void QWindowPrivate::setTopLevelScreen(QScreen *newScreen, bool recreate)-
162{-
163 QWindow * const q = q_func();-
164 if (parentWindow) {-
165 QMessageLogger(__FILE__, 374380, __PRETTY_FUNCTION__).warning() << q << '(' << newScreen << "): Attempt to set a screen on a child window.";-
166 return;-
167 }-
168 if (newScreen != topLevelScreen) {-
169 const bool shouldRecreate = recreate && windowRecreationRequired(newScreen);-
170 const bool shouldShow = visibilityOnDestroy && !topLevelScreen;-
171 if (shouldRecreate && platformWindow)-
172 q->destroy();-
173 connectToScreen(newScreen);-
174 if (shouldShow)-
175 q->setVisible(true);-
176 else if (newScreen && shouldRecreate)-
177 create(true);-
178 emitScreenChangedRecursion(newScreen);-
179 }-
180}-
181-
182void QWindowPrivate::create(bool recursive)-
183{-
184 QWindow * const q = q_func();-
185 if (platformWindow
platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
186 return;
never executed: return;
0
187-
188 if (q->parent()
q->parent()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
189 q->parent()->create();
never executed: q->parent()->create();
0
190-
191 platformWindow = QGuiApplicationPrivate::platformIntegration()->createPlatformWindow(q);-
192 ((!(platformWindow || q->type() == Qt::ForeignWindow)) ? qt_assert("platformWindow""platformWindow || q->type() == Qt::ForeignWindow",__FILE__,398407) : qt_noop());-
193-
194 if (!platformWindow
!platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
195 QMessageLogger(__FILE__, 401410, __PRETTY_FUNCTION__).warning() << "Failed to create platform window for" << q << "with flags" << q->flags();-
196 return;
never executed: return;
0
197 }-
198-
199 QObjectList childObjects = q->children();-
200 for (int i = 0; i < childObjects.size()
i < childObjects.size()Description
TRUEnever evaluated
FALSEnever evaluated
; i ++) {
0
201 QObject *object = childObjects.at(i);-
202 if ((!
!object->isWindowType()Description
TRUEnever evaluated
FALSEnever evaluated
object->isWindowType()
!object->isWindowType()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
203 {continue;
never executed: continue;
0
204-
205 QWindow *windowchildWindow = static_cast<QWindow *>(object);-
206 if (recursive
recursiveDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
207 windowchildWindow
never executed: childWindow->d_func()->create(recursive);
->d_func()->create(recursive);
never executed: childWindow->d_func()->create(recursive);
0
208-
209-
210-
211-
212 if (childWindow->isVisible()
childWindow->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
213 childWindow->setVisible
never executed: childWindow->setVisible(true);
never executed: childWindow->setVisible(true);
(true);
never executed: childWindow->setVisible(true);
0
214-
215 if (windowQPlatformWindow *childPlatformWindow = childWindow
QPlatformWindo...platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
->d_func()->platformWindow
QPlatformWindo...platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
216 window->d_func()->platformWindowchildPlatformWindow
never executed: childPlatformWindow->setParent(this->platformWindow);
->setParent(this->platformWindow);
never executed: childPlatformWindow->setParent(this->platformWindow);
0
217 }}
never executed: end of block
0
218-
219 QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated);-
220 QGuiApplication::sendEvent(q, &e);-
221}
never executed: end of block
0
222-
223void QWindowPrivate::clearFocusObject()-
224{-
225}-
226-
227-
228-
229-
230QRectF QWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const-
231{-
232 (void)rect;-
233 return QRectF();-
234}-
235void QWindow::setSurfaceType(SurfaceType surfaceType)-
236{-
237 QWindowPrivate * const d = d_func();-
238 d->surfaceType = surfaceType;-
239}-
240-
241-
242-
243-
244-
245-
246QWindow::SurfaceType QWindow::surfaceType() const-
247{-
248 const QWindowPrivate * const d = d_func();-
249 return d->surfaceType;-
250}-
251void QWindow::setVisible(bool visible)-
252{-
253 QWindowPrivate * const d = d_func();-
254-
255 if (d->visible ==!= visible
d->visible != visibleDescription
TRUEnever evaluated
FALSEnever evaluated
) return;{
0
256 d->visible = visible;-
257 visibleChanged(visible);-
258 d->updateVisibility();-
259 }
never executed: end of block
else if (d->platformWindow
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
260-
261 return;
never executed: return;
0
262 }-
263-
264 if (!d->platformWindow
!d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
265-
266-
267 if (parent()
parent()Description
TRUEnever evaluated
FALSEnever evaluated
&& !parent()->handle()
!parent()->handle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
268 return;
never executed: return;
0
269 else-
270 create();
never executed: create();
0
271 }-
272-
273 if (visible
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
274-
275 QCoreApplication::removePostedEvents((static_cast<QGuiApplication *>(QCoreApplication::instance())), QEvent::Quit);-
276-
277 if (type() == Qt::Window
type() == Qt::WindowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
278 QGuiApplicationPrivate *app_priv = QGuiApplicationPrivate::instance();-
279 QString &firstWindowTitle = app_priv->firstWindowTitle;-
280 if (!firstWindowTitle.isEmpty()
!firstWindowTitle.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
281 setTitle(firstWindowTitle);-
282 firstWindowTitle = QString();-
283 }
never executed: end of block
0
284 if (!app_priv->forcedWindowIcon.isNull()
!app_priv->for...wIcon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
285 setIcon(app_priv->forcedWindowIcon);
never executed: setIcon(app_priv->forcedWindowIcon);
0
286-
287-
288 static bool geometryApplied = false;-
289 if (!geometryApplied
!geometryAppliedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
290 geometryApplied = true;-
291 QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(this);-
292 }
never executed: end of block
0
293 }
never executed: end of block
0
294-
295 QShowEvent showEvent;-
296 QGuiApplication::sendEvent(this, &showEvent);-
297 }
never executed: end of block
0
298-
299 if (isModal()
isModal()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
300 if (visible
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
301 QGuiApplicationPrivate::showModalWindow(this);
never executed: QGuiApplicationPrivate::showModalWindow(this);
0
302 else-
303 QGuiApplicationPrivate::hideModalWindow(this);
never executed: QGuiApplicationPrivate::hideModalWindow(this);
0
304 }-
305-
306-
307 if (visible
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
&& (d->hasCursor
d->hasCursorDescription
TRUEnever evaluated
FALSEnever evaluated
|| QGuiApplication::overrideCursor()
QGuiApplicatio...errideCursor()Description
TRUEnever evaluated
FALSEnever evaluated
))
0
308 d->applyCursor();
never executed: d->applyCursor();
0
309-
310-
311 d->platformWindow->setVisible(visible);-
312-
313 if (!visible
!visibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
314 QHideEvent hideEvent;-
315 QGuiApplication::sendEvent(this, &hideEvent);-
316 }
never executed: end of block
0
317}
never executed: end of block
0
318-
319bool QWindow::isVisible() const-
320{-
321 const QWindowPrivate * const d = d_func();-
322-
323 return d->visible;-
324}-
325void QWindow::create()-
326{-
327 QWindowPrivate * const d = d_func();-
328 d->create(false);-
329}-
330WId QWindow::winId() const-
331{-
332 const QWindowPrivate * const d = d_func();-
333-
334 if (type() == Qt::ForeignWindow)-
335 return WId(property("_q_foreignWinId").value<WId>());-
336-
337 if(!d->platformWindow)-
338 const_cast<QWindow *>(this)->create();-
339-
340 return d->platformWindow->winId();-
341}-
342-
343-
344-
345-
346-
347-
348QWindow *QWindow::parent() const-
349{-
350 const QWindowPrivate * const d = d_func();-
351 return d->parentWindow;-
352}-
353void QWindow::setParent(QWindow *parent)-
354{-
355 QWindowPrivate * const d = d_func();-
356 if (d->parentWindow == parent
d->parentWindow == parentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
357 return;
never executed: return;
0
358-
359 QScreen *newScreen = parent
parentDescription
TRUEnever evaluated
FALSEnever evaluated
? parent->screen() : screen();
0
360 if (d->windowRecreationRequired(newScreen)
d->windowRecre...red(newScreen)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
361 QMessageLogger(__FILE__, 609636, __PRETTY_FUNCTION__).warning() << this << '(' << parent << "): Cannot change screens (" << screen() << newScreen << ')';-
362 return;
never executed: return;
0
363 }-
364-
365 QObject::setParent(parent);-
366 d->parentWindow = parent;-
367-
368 if (parent
parentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
369 d->disconnectFromScreen();
never executed: d->disconnectFromScreen();
0
370 else-
371 d->connectToScreen(newScreen);
never executed: d->connectToScreen(newScreen);
0
372-
373-
374-
375-
376 if (isVisible()
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
&& (!parent
!parentDescription
TRUEnever evaluated
FALSEnever evaluated
|| parent->handle()
parent->handle()Description
TRUEnever evaluated
FALSEnever evaluated
))
0
377 setVisible(true
never executed: setVisible(true);
never executed: setVisible(true);
);
never executed: setVisible(true);
0
378-
379 if (d->platformWindow
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
380 if (parent&&
parentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
381 parent->d_func()->platformWindow) {create();
never executed: parent->create();
0
382-
383 d->platformWindow->setParent(parent ? parent->d_func()->platformWindow);-
} else {
d->platformWindow ->setParent(: 0);
384 }}
never executed: end of block
0
385-
386 QGuiApplicationPrivate::updateBlockedStatus(this);-
387}
never executed: end of block
0
388-
389-
390-
391-
392bool QWindow::isTopLevel() const-
393{-
394 const QWindowPrivate * const d = d_func();-
395 return d->parentWindow == 0;-
396}-
397bool QWindow::isModal() const-
398{-
399 const QWindowPrivate * const d = d_func();-
400 return d->modality != Qt::NonModal;-
401}-
402Qt::WindowModality QWindow::modality() const-
403{-
404 const QWindowPrivate * const d = d_func();-
405 return d->modality;-
406}-
407-
408void QWindow::setModality(Qt::WindowModality modality)-
409{-
410 QWindowPrivate * const d = d_func();-
411 if (d->modality == modality)-
412 return;-
413 d->modality = modality;-
414 modalityChanged(modality);-
415}-
416void QWindow::setFormat(const QSurfaceFormat &format)-
417{-
418 QWindowPrivate * const d = d_func();-
419 d->requestedFormat = format;-
420}-
421QSurfaceFormat QWindow::requestedFormat() const-
422{-
423 const QWindowPrivate * const d = d_func();-
424 return d->requestedFormat;-
425}-
426QSurfaceFormat QWindow::format() const-
427{-
428 const QWindowPrivate * const d = d_func();-
429 if (d->platformWindow)-
430 return d->platformWindow->format();-
431 return d->requestedFormat;-
432}-
433void QWindow::setFlags(Qt::WindowFlags flags)-
434{-
435 QWindowPrivate * const d = d_func();-
436 if (d->platformWindow)-
437 d->platformWindow->setWindowFlags(flags);-
438 d->windowFlags = flags;-
439}-
440-
441Qt::WindowFlags QWindow::flags() const-
442{-
443 const QWindowPrivate * const d = d_func();-
444 return d->windowFlags;-
445}-
446Qt::WindowType QWindow::type() const-
447{-
448 const QWindowPrivate * const d = d_func();-
449 return static_cast<Qt::WindowType>(int(d->windowFlags & Qt::WindowType_Mask));-
450}-
451void QWindow::setTitle(const QString &title)-
452{-
453 QWindowPrivate * const d = d_func();-
454 bool changed = false;-
455 if (d->windowTitle != title) {-
456 d->windowTitle = title;-
457 changed = true;-
458 }-
459 if (d->platformWindow && type() != Qt::Desktop)-
460 d->platformWindow->setWindowTitle(title);-
461 if (changed)-
462 windowTitleChanged(title);-
463}-
464-
465QString QWindow::title() const-
466{-
467 const QWindowPrivate * const d = d_func();-
468 return d->windowTitle;-
469}-
470void QWindow::setFilePath(const QString &filePath)-
471{-
472 QWindowPrivate * const d = d_func();-
473 d->windowFilePath = filePath;-
474 if (d->platformWindow)-
475 d->platformWindow->setWindowFilePath(filePath);-
476}-
477-
478-
479-
480-
481-
482-
483QString QWindow::filePath() const-
484{-
485 const QWindowPrivate * const d = d_func();-
486 return d->windowFilePath;-
487}-
488-
489-
490-
491-
492-
493-
494-
495void QWindow::setIcon(const QIcon &icon)-
496{-
497 QWindowPrivate * const d = d_func();-
498 d->windowIcon = icon;-
499 if (d->platformWindow)-
500 d->platformWindow->setWindowIcon(icon);-
501 QEvent e(QEvent::WindowIconChange);-
502 QCoreApplication::sendEvent(this, &e);-
503}-
504-
505-
506-
507-
508-
509-
510QIcon QWindow::icon() const-
511{-
512 const QWindowPrivate * const d = d_func();-
513 if (d->windowIcon.isNull())-
514 return QGuiApplication::windowIcon();-
515 return d->windowIcon;-
516}-
517-
518-
519-
520-
521-
522-
523void QWindow::raise()-
524{-
525 QWindowPrivate * const d = d_func();-
526 if (d->platformWindow)-
527 d->platformWindow->raise();-
528}-
529-
530-
531-
532-
533-
534-
535void QWindow::lower()-
536{-
537 QWindowPrivate * const d = d_func();-
538 if (d->platformWindow)-
539 d->platformWindow->lower();-
540}-
541void QWindow::setOpacity(qreal level)-
542{-
543 QWindowPrivate * const d = d_func();-
544 if (level == d->opacity)-
545 return;-
546 d->opacity = level;-
547 if (d->platformWindow) {-
548 d->platformWindow->setOpacity(level);-
549 opacityChanged(level);-
550 }-
551}-
552-
553qreal QWindow::opacity() const-
554{-
555 const QWindowPrivate * const d = d_func();-
556 return d->opacity;-
557}-
558void QWindow::setMask(const QRegion &region)-
559{-
560 QWindowPrivate * const d = d_func();-
561 if (!d->platformWindow)-
562 return;-
563 d->platformWindow->setMask(QHighDpi::toNativeLocalRegion(region, this));-
564 d->mask = region;-
565}-
566-
567-
568-
569-
570-
571-
572-
573QRegion QWindow::mask() const-
574{-
575 const QWindowPrivate * const d = d_func();-
576 return d->mask;-
577}-
578-
579-
580-
581-
582-
583-
584void QWindow::requestActivate()-
585{-
586 QWindowPrivate * const d = d_func();-
587 if (flags() & Qt::WindowDoesNotAcceptFocus) {-
588 QMessageLogger(__FILE__, 9811013, __PRETTY_FUNCTION__).warning() << "requestActivate() called for " << this << " which has Qt::WindowDoesNotAcceptFocus set.";-
589 return;-
590 }-
591 if (d->platformWindow)-
592 d->platformWindow->requestActivateWindow();-
593}-
594bool QWindow::isExposed() const-
595{-
596 const QWindowPrivate * const d = d_func();-
597 return d->exposed;-
598}-
599bool QWindow::isActive() const-
600{-
601 const QWindowPrivate * const d = d_func();-
602 if (!d->platformWindow)-
603 return false;-
604-
605 QWindow *focus = QGuiApplication::focusWindow();-
606-
607-
608 if (!focus)-
609 return false;-
610-
611 if (focus == this)-
612 return true;-
613-
614 if (!parent() && !transientParent()) {-
615 return isAncestorOf(focus);-
616 } else {-
617 return (parent() && parent()->isActive()) || (transientParent() && transientParent()->isActive());-
618 }-
619}-
620void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation)-
621{-
622 QWindowPrivate * const d = d_func();-
623 if (d->contentOrientation == orientation)-
624 return;-
625 if (d->platformWindow)-
626 d->platformWindow->handleContentOrientationChange(orientation);-
627 d->contentOrientation = orientation;-
628 contentOrientationChanged(orientation);-
629}-
630-
631Qt::ScreenOrientation QWindow::contentOrientation() const-
632{-
633 const QWindowPrivate * const d = d_func();-
634 return d->contentOrientation;-
635}-
636qreal QWindow::devicePixelRatio() const-
637{-
638 const QWindowPrivate * const d = d_func();-
639-
640-
641-
642-
643 if (!d->platformWindow)-
644 return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio();-
645-
646 return d->platformWindow->devicePixelRatio() * QHighDpiScaling::factor(this);-
647}-
648void QWindow::setWindowState(Qt::WindowState state)-
649{-
650 if (state == Qt::WindowActive
state == Qt::WindowActiveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
651 QMessageLogger(__FILE__, 11181150, __PRETTY_FUNCTION__).warning() << ("QWindow::setWindowState does not accept Qt::WindowActive";);-
652 return;
never executed: return;
0
653 }-
654-
655 QWindowPrivate * const d = d_func();-
656 if (d->platformWindow
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
657 d->platformWindow->setWindowState(state);
never executed: d->platformWindow->setWindowState(state);
0
658 d->windowState = state;-
659 windowStateChanged(d->windowState);-
660 d->updateVisibility();-
661}
never executed: end of block
0
662-
663-
664-
665-
666-
667-
668Qt::WindowState QWindow::windowState() const-
669{-
670 const QWindowPrivate * const d = d_func();-
671 return d->windowState;-
672}-
673void QWindow::setTransientParent(QWindow *parent)-
674{-
675 QWindowPrivate * const d = d_func();-
676 if (parent && !parent->isTopLevel()) {-
677 QMessageLogger(__FILE__, 11651197, __PRETTY_FUNCTION__).warning() << parent << "must be a top level window.";-
678 return;-
679 }-
680-
681 d->transientParent = parent;-
682-
683 QGuiApplicationPrivate::updateBlockedStatus(this);-
684}-
685-
686-
687-
688-
689-
690-
691QWindow *QWindow::transientParent() const-
692{-
693 const QWindowPrivate * const d = d_func();-
694 return d->transientParent.data();-
695}-
696bool QWindow::isAncestorOf(const QWindow *child, AncestorMode mode) const-
697{-
698 if (child->parent() == this || (mode == IncludeTransients && child->transientParent() == this))-
699 return true;-
700-
701 return (child->parent() && isAncestorOf(child->parent(), mode))-
702 || (mode == IncludeTransients && child->transientParent() && isAncestorOf(child->transientParent(), mode));-
703}-
704-
705-
706-
707-
708-
709-
710QSize QWindow::minimumSize() const-
711{-
712 const QWindowPrivate * const d = d_func();-
713 return d->minimumSize;-
714}-
715-
716-
717-
718-
719-
720-
721QSize QWindow::maximumSize() const-
722{-
723 const QWindowPrivate * const d = d_func();-
724 return d->maximumSize;-
725}-
726-
727-
728-
729-
730-
731-
732QSize QWindow::baseSize() const-
733{-
734 const QWindowPrivate * const d = d_func();-
735 return d->baseSize;-
736}-
737-
738-
739-
740-
741-
742-
743QSize QWindow::sizeIncrement() const-
744{-
745 const QWindowPrivate * const d = d_func();-
746 return d->sizeIncrement;-
747}-
748void QWindow::setMinimumSize(const QSize &size)-
749{-
750 QWindowPrivate * const d = d_func();-
751 QSize adjustedSize = QSize(qBound(0, size.width(), ((1<<24)-1)), qBound(0, size.height(), ((1<<24)-1)));-
752 if (d->minimumSize == adjustedSize)-
753 return;-
754 QSize oldSize = d->minimumSize;-
755 d->minimumSize = adjustedSize;-
756 if (d->platformWindow && isTopLevel())-
757 d->platformWindow->propagateSizeHints();-
758 if (d->minimumSize.width() != oldSize.width())-
759 minimumWidthChanged(d->minimumSize.width());-
760 if (d->minimumSize.height() != oldSize.height())-
761 minimumHeightChanged(d->minimumSize.height());-
762}-
763-
764-
765-
766-
767-
768void QWindow::setX(int arg)-
769{-
770 QWindowPrivate * const d = d_func();-
771 if (x() != arg)-
772 setGeometry(QRect(arg, y(), width(), height()));-
773 else-
774 d->positionAutomatic = false;-
775}-
776-
777-
778-
779-
780-
781void QWindow::setY(int arg)-
782{-
783 QWindowPrivate * const d = d_func();-
784 if (y() != arg)-
785 setGeometry(QRect(x(), arg, width(), height()));-
786 else-
787 d->positionAutomatic = false;-
788}-
789-
790-
791-
792-
793-
794void QWindow::setWidth(int arg)-
795{-
796 if (width() != arg)-
797 resize(arg, height());-
798}-
799-
800-
801-
802-
803-
804void QWindow::setHeight(int arg)-
805{-
806 if (height() != arg)-
807 resize(width(), arg);-
808}-
809-
810-
811-
812-
813-
814void QWindow::setMinimumWidth(int w)-
815{-
816 setMinimumSize(QSize(w, minimumHeight()));-
817}-
818-
819-
820-
821-
822-
823void QWindow::setMinimumHeight(int h)-
824{-
825 setMinimumSize(QSize(minimumWidth(), h));-
826}-
827void QWindow::setMaximumSize(const QSize &size)-
828{-
829 QWindowPrivate * const d = d_func();-
830 QSize adjustedSize = QSize(qBound(0, size.width(), ((1<<24)-1)), qBound(0, size.height(), ((1<<24)-1)));-
831 if (d->maximumSize == adjustedSize)-
832 return;-
833 QSize oldSize = d->maximumSize;-
834 d->maximumSize = adjustedSize;-
835 if (d->platformWindow && isTopLevel())-
836 d->platformWindow->propagateSizeHints();-
837 if (d->maximumSize.width() != oldSize.width())-
838 maximumWidthChanged(d->maximumSize.width());-
839 if (d->maximumSize.height() != oldSize.height())-
840 maximumHeightChanged(d->maximumSize.height());-
841}-
842-
843-
844-
845-
846-
847void QWindow::setMaximumWidth(int w)-
848{-
849 setMaximumSize(QSize(w, maximumHeight()));-
850}-
851-
852-
853-
854-
855-
856void QWindow::setMaximumHeight(int h)-
857{-
858 setMaximumSize(QSize(maximumWidth(), h));-
859}-
860void QWindow::setBaseSize(const QSize &size)-
861{-
862 QWindowPrivate * const d = d_func();-
863 if (d->baseSize == size)-
864 return;-
865 d->baseSize = size;-
866 if (d->platformWindow && isTopLevel())-
867 d->platformWindow->propagateSizeHints();-
868}-
869void QWindow::setSizeIncrement(const QSize &size)-
870{-
871 QWindowPrivate * const d = d_func();-
872 if (d->sizeIncrement == size)-
873 return;-
874 d->sizeIncrement = size;-
875 if (d->platformWindow && isTopLevel())-
876 d->platformWindow->propagateSizeHints();-
877}-
878-
879-
880-
881-
882-
883-
884-
885void QWindow::setGeometry(int posx, int posy, int w, int h)-
886{-
887 setGeometry(QRect(posx, posy, w, h));-
888}-
889-
890-
891-
892-
893-
894-
895void QWindow::setGeometry(const QRect &rect)-
896{-
897 QWindowPrivate * const d = d_func();-
898 d->positionAutomatic = false;-
899 const QRect oldRect = geometry();-
900 if (rect == geometry())oldRect
rect == oldRectDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
901 return;
never executed: return;
0
902-
903 QRect oldRect = geometry();d->positionPolicy = QWindowPrivate::WindowFrameExclusive;-
904 if (d->platformWindow
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
905 QRect nativeRect;-
906 QScreen *newScreen = d->screenForGeometry(rect);-
907 if (newScreen
newScreenDescription
TRUEnever evaluated
FALSEnever evaluated
&& isTopLevel()
isTopLevel()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
908 nativeRect = QHighDpi::toNativePixels(rect, newScreen);
never executed: nativeRect = QHighDpi::toNativePixels(rect, newScreen);
0
909 else-
910 nativeRect = QHighDpi::toNativePixels(rect, this);
never executed: nativeRect = QHighDpi::toNativePixels(rect, this);
0
911 d->platformWindow->setGeometry(nativeRect);-
912 }
never executed: end of block
else {
0
913 d->geometry = rect;-
914-
915 if (rect.x() != oldRect.x()
rect.x() != oldRect.x()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
916 xChanged(rect.x());
never executed: xChanged(rect.x());
0
917 if (rect.y() != oldRect.y()
rect.y() != oldRect.y()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
918 yChanged(rect.y());
never executed: yChanged(rect.y());
0
919 if (rect.width() != oldRect.width()
rect.width() !...ldRect.width()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
920 widthChanged(rect.width());
never executed: widthChanged(rect.width());
0
921 if (rect.height() != oldRect.height()
rect.height() ...dRect.height()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
922 heightChanged(rect.height());
never executed: heightChanged(rect.height());
0
923 }
never executed: end of block
0
924}-
925-
926-
927-
928-
929-
930-
931-
932QScreen *QWindowPrivate::screenForGeometry(const QRect &newGeometry)-
933{-
934 QWindow * const q = q_func();-
935 QScreen *currentScreen = q->screen();-
936 QScreen *fallback = currentScreen;-
937 QPoint center = newGeometry.center();-
938 if (!q->parent()
!q->parent()Description
TRUEnever evaluated
FALSEnever evaluated
&& currentScreen
currentScreenDescription
TRUEnever evaluated
FALSEnever evaluated
&& !currentScreen->geometry().contains(center)
!currentScreen...ntains(center)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
939 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(currentScreen->virtualSiblings())>::type> _container_((const auto screens = currentScreen->virtualSiblings())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)();-
940 for (QScreen* screen = *_container_.i; _container_.control; _container_.control = 0: screens) {-
941 if (screen->geometry().contains(center)
screen->geomet...ntains(center)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
942 return
never executed: return screen;
screen;
never executed: return screen;
0
943 if (screen->geometry().intersects(newGeometry)
screen->geomet...s(newGeometry)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
944 fallback = screen;
never executed: fallback = screen;
0
945 }
never executed: end of block
0
946 }
never executed: end of block
0
947 return
never executed: return fallback;
fallback;
never executed: return fallback;
0
948}-
949-
950-
951-
952-
953-
954-
955-
956QRect QWindow::geometry() const-
957{-
958 const QWindowPrivate * const d = d_func();-
959 if (d->platformWindow)-
960 return QHighDpi::fromNativePixels(d->platformWindow->geometry(), this);-
961 return d->geometry;-
962}-
963-
964-
965-
966-
967-
968-
969QMargins QWindow::frameMargins() const-
970{-
971 const QWindowPrivate * const d = d_func();-
972 if (d->platformWindow)-
973 return QHighDpi::fromNativePixels(d->platformWindow->frameMargins(), this);-
974 return QMargins();-
975}-
976-
977-
978-
979-
980-
981-
982QRect QWindow::frameGeometry() const-
983{-
984 const QWindowPrivate * const d = d_func();-
985 if (d->platformWindow) {-
986 QMargins m = frameMargins();-
987 return QHighDpi::fromNativePixels(d->platformWindow->geometry(), this).adjusted(-m.left(), -m.top(), m.right(), m.bottom());-
988 }-
989 return d->geometry;-
990}-
991QPoint QWindow::framePosition() const-
992{-
993 const QWindowPrivate * const d = d_func();-
994 if (d->platformWindow) {-
995 QMargins margins = frameMargins();-
996 return QHighDpi::fromNativePixels(d->platformWindow->geometry().topLeft(), this) - QPoint(margins.left(), margins.top());-
997 }-
998 return d->geometry.topLeft();-
999}-
1000-
1001-
1002-
1003-
1004-
1005-
1006void QWindow::setFramePosition(const QPoint &point)-
1007{-
1008 QWindowPrivate * const d = d_func();-
1009 d->positionPolicy = QWindowPrivate::WindowFrameInclusive;-
1010 d->positionAutomatic = false;-
1011 if (d->platformWindow) {-
1012 d->platformWindow->setGeometry(QHighDpi::toNativePixels(QRect(point, size()), this));-
1013 } else {-
1014 d->geometry.moveTopLeft(point);-
1015 }-
1016}-
1017-
1018-
1019-
1020-
1021-
1022-
1023void QWindow::setPosition(const QPoint &pt)-
1024{-
1025 setGeometry(QRect(pt, size()));-
1026}-
1027-
1028-
1029-
1030-
1031-
1032-
1033void QWindow::setPosition(int posx, int posy)-
1034{-
1035 setPosition(QPoint(posx, posy));-
1036}-
1037void QWindow::resize(int w, int h)-
1038{-
1039 resize(QSize(w, h));-
1040}-
1041-
1042-
1043-
1044-
1045-
1046-
1047void QWindow::resize(const QSize &newSize)-
1048{-
1049 QWindowPrivate * const d = d_func();-
1050 if (d->platformWindow) {-
1051 d->platformWindow->setGeometry(QHighDpi::toNativePixels(QRect(position(), newSize), this));-
1052 } else {-
1053 const QSize oldSize = d->geometry.size();-
1054 d->geometry.setSize(newSize);-
1055 if (newSize.width() != oldSize.width())-
1056 widthChanged(newSize.width());-
1057 if (newSize.height() != oldSize.height())-
1058 heightChanged(newSize.height());-
1059 }-
1060}-
1061-
1062-
1063-
1064-
1065-
1066-
1067void QWindow::destroy()-
1068{-
1069 QWindowPrivate * const d = d_func();-
1070 if (!d->platformWindow
!d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1071 return;
never executed: return;
0
1072-
1073 QObjectList childrenWindows = children();-
1074 for (int i = 0; i < childrenWindows.size()
i < childrenWindows.size()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1075 QObject *object = childrenWindows.at(i);-
1076 if (object->isWindowType()
object->isWindowType()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1077 QWindow *w = static_cast<QWindow*>(object);-
1078 w->destroy();-
1079 }
never executed: end of block
0
1080 }
never executed: end of block
0
1081-
1082 if (QGuiApplicationPrivate::focus_window == this
QGuiApplicatio...window == thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1083 QGuiApplicationPrivate::focus_window = parent();
never executed: QGuiApplicationPrivate::focus_window = parent();
0
1084 if (QGuiApplicationPrivate::currentMouseWindow == this
QGuiApplicatio...Window == thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1085 QGuiApplicationPrivate::currentMouseWindow = parent();
never executed: QGuiApplicationPrivate::currentMouseWindow = parent();
0
1086 if (QGuiApplicationPrivate::currentMousePressWindow == this
QGuiApplicatio...Window == thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1087 QGuiApplicationPrivate::currentMousePressWindow = parent();
never executed: QGuiApplicationPrivate::currentMousePressWindow = parent();
0
1088-
1089 for (int i = 0; i < QGuiApplicationPrivate::tabletDevicePoints.size
i < QGuiApplic...ePoints.size()Description
TRUEnever evaluated
FALSEnever evaluated
i < QGuiApplic...ePoints.size()Description
TRUEnever evaluated
FALSEnever evaluated
()
i < QGuiApplic...ePoints.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1090 if (QGuiApplicationPrivate::tabletPressTargettabletDevicePoints.at(i).target == this
QGuiApplicatio...target == thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1091 QGuiApplicationPrivate::tabletPressTargettabletDevicePoints[i].target = parent();
never executed: QGuiApplicationPrivate::tabletDevicePoints[i].target = parent();
0
1092-
1093 bool wasVisible = isVisible();-
1094 d->visibilityOnDestroy = wasVisible
wasVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->platformWindow
d->platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
1095-
1096 setVisible(false);-
1097-
1098 QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed);-
1099 QGuiApplication::sendEvent(this, &e);-
1100-
1101 delete d->platformWindow;-
1102 d->resizeEventPending = true;-
1103 d->receivedExpose = false;-
1104 d->exposed = false;-
1105 d->platformWindow = 0;-
1106-
1107 if (wasVisible
wasVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1108 d->maybeQuitOnLastWindowClosed();
never executed: d->maybeQuitOnLastWindowClosed();
0
1109}
never executed: end of block
0
1110-
1111-
1112-
1113-
1114-
1115-
1116QPlatformWindow *QWindow::handle() const-
1117{-
1118 const QWindowPrivate * const d = d_func();-
1119 return d->platformWindow;-
1120}-
1121-
1122-
1123-
1124-
1125-
1126-
1127QPlatformSurface *QWindow::surfaceHandle() const-
1128{-
1129 const QWindowPrivate * const d = d_func();-
1130 return d->platformWindow;-
1131}-
1132bool QWindow::setKeyboardGrabEnabled(bool grab)-
1133{-
1134 QWindowPrivate * const d = d_func();-
1135 if (d->platformWindow)-
1136 return d->platformWindow->setKeyboardGrabEnabled(grab);-
1137 return false;-
1138}-
1139bool QWindow::setMouseGrabEnabled(bool grab)-
1140{-
1141 QWindowPrivate * const d = d_func();-
1142 if (d->platformWindow)-
1143 return d->platformWindow->setMouseGrabEnabled(grab);-
1144 return false;-
1145}-
1146QScreen *QWindow::screen() const-
1147{-
1148 const QWindowPrivate * const d = d_func();-
1149 return d->parentWindow ? d->parentWindow->screen() : d->topLevelScreen.data();-
1150}-
1151void QWindow::setScreen(QScreen *newScreen)-
1152{-
1153 QWindowPrivate * const d = d_func();-
1154 if (!newScreen)-
1155 newScreen = QGuiApplication::primaryScreen();-
1156 d->setTopLevelScreen(newScreen, newScreen != 0);-
1157}-
1158QAccessibleInterface *QWindow::accessibleRoot() const-
1159{-
1160 return 0;-
1161}-
1162QObject *QWindow::focusObject() const-
1163{-
1164 return const_cast<QWindow *>(this);-
1165}-
1166void QWindow::show()-
1167{-
1168 Qt::WindowState defaultState = QGuiApplicationPrivate::platformIntegration()->defaultWindowState(d_func()->windowFlags);-
1169 if (defaultState == Qt::WindowFullScreen)-
1170 showFullScreen();-
1171 else if (defaultState == Qt::WindowMaximized)-
1172 showMaximized();-
1173 else-
1174 showNormal();-
1175}-
1176void QWindow::hide()-
1177{-
1178 setVisible(false);-
1179}-
1180void QWindow::showMinimized()-
1181{-
1182 setWindowState(Qt::WindowMinimized);-
1183 setVisible(true);-
1184}-
1185void QWindow::showMaximized()-
1186{-
1187 setWindowState(Qt::WindowMaximized);-
1188 setVisible(true);-
1189}-
1190void QWindow::showFullScreen()-
1191{-
1192 setWindowState(Qt::WindowFullScreen);-
1193 setVisible(true);-
1194-
1195-
1196 requestActivate();-
1197-
1198}-
1199void QWindow::showNormal()-
1200{-
1201 setWindowState(Qt::WindowNoState);-
1202 setVisible(true);-
1203}-
1204bool QWindow::close()-
1205{-
1206 QWindowPrivate * const d = d_func();-
1207-
1208-
1209 if (parent())-
1210 return false;-
1211-
1212 if (!d->platformWindow)-
1213 return true;-
1214-
1215 bool accepted = false;-
1216 QWindowSystemInterface::handleCloseEvent(this, &accepted);-
1217 QWindowSystemInterface::flushWindowSystemEvents();-
1218 return accepted;-
1219}-
1220void QWindow::exposeEvent(QExposeEvent *ev)-
1221{-
1222 ev->ignore();-
1223}-
1224-
1225-
1226-
1227-
1228void QWindow::moveEvent(QMoveEvent *ev)-
1229{-
1230 ev->ignore();-
1231}-
1232void QWindow::resizeEvent(QResizeEvent *ev)-
1233{-
1234 ev->ignore();-
1235}-
1236void QWindow::showEvent(QShowEvent *ev)-
1237{-
1238 ev->ignore();-
1239}-
1240-
1241-
1242-
1243-
1244-
1245-
1246-
1247void QWindow::hideEvent(QHideEvent *ev)-
1248{-
1249 ev->ignore();-
1250}-
1251bool QWindow::event(QEvent *ev)-
1252{-
1253 switch (ev->type()) {-
1254 case QEvent::MouseMove:-
1255 mouseMoveEvent(static_cast<QMouseEvent*>(ev));-
1256 break;-
1257-
1258 case QEvent::MouseButtonPress:-
1259 mousePressEvent(static_cast<QMouseEvent*>(ev));-
1260 break;-
1261-
1262 case QEvent::MouseButtonRelease:-
1263 mouseReleaseEvent(static_cast<QMouseEvent*>(ev));-
1264 break;-
1265-
1266 case QEvent::MouseButtonDblClick:-
1267 mouseDoubleClickEvent(static_cast<QMouseEvent*>(ev));-
1268 break;-
1269-
1270 case QEvent::TouchBegin:-
1271 case QEvent::TouchUpdate:-
1272 case QEvent::TouchEnd:-
1273 case QEvent::TouchCancel:-
1274 touchEvent(static_cast<QTouchEvent *>(ev));-
1275 break;-
1276-
1277 case QEvent::Move:-
1278 moveEvent(static_cast<QMoveEvent*>(ev));-
1279 break;-
1280-
1281 case QEvent::Resize:-
1282 resizeEvent(static_cast<QResizeEvent*>(ev));-
1283 break;-
1284-
1285 case QEvent::KeyPress:-
1286 keyPressEvent(static_cast<QKeyEvent *>(ev));-
1287 break;-
1288-
1289 case QEvent::KeyRelease:-
1290 keyReleaseEvent(static_cast<QKeyEvent *>(ev));-
1291 break;-
1292-
1293 case QEvent::FocusIn: {-
1294 focusInEvent(static_cast<QFocusEvent *>(ev));-
1295-
1296 QAccessible::State state;-
1297 state.active = true;-
1298 QAccessibleStateChangeEvent event(this, state);-
1299 QAccessible::updateAccessibility(&event);-
1300-
1301 break; }-
1302-
1303 case QEvent::FocusOut: {-
1304 focusOutEvent(static_cast<QFocusEvent *>(ev));-
1305-
1306 QAccessible::State state;-
1307 state.active = true;-
1308 QAccessibleStateChangeEvent event(this, state);-
1309 QAccessible::updateAccessibility(&event);-
1310-
1311 break; }-
1312-
1313-
1314 case QEvent::Wheel:-
1315 wheelEvent(static_cast<QWheelEvent*>(ev));-
1316 break;-
1317-
1318-
1319 case QEvent::Close:-
1320 if (ev->isAccepted())-
1321 destroy();-
1322 break;-
1323-
1324 case QEvent::Expose:-
1325 exposeEvent(static_cast<QExposeEvent *>(ev));-
1326 break;-
1327-
1328 case QEvent::Show:-
1329 showEvent(static_cast<QShowEvent *>(ev));-
1330 break;-
1331-
1332 case QEvent::Hide:-
1333 hideEvent(static_cast<QHideEvent *>(ev));-
1334 break;-
1335-
1336 case QEvent::ApplicationWindowIconChange:-
1337 setIcon(icon());-
1338 break;-
1339-
1340 case QEvent::WindowStateChange: {-
1341 QWindowPrivate * const d = d_func();-
1342 windowStateChanged(d->windowState);-
1343 d->updateVisibility();-
1344 break;-
1345 }-
1346-
1347-
1348 case QEvent::TabletPress:-
1349 case QEvent::TabletMove:-
1350 case QEvent::TabletRelease:-
1351 tabletEvent(static_cast<QTabletEvent *>(ev));-
1352 break;-
1353-
1354-
1355 case QEvent::Timer: {-
1356 QWindowPrivate * const d = d_func();-
1357 if (static_cast<QTimerEvent *>(ev)->timerId() == d->updateTimer) {-
1358 killTimer(d->updateTimer);-
1359 d->updateTimer = 0;-
1360 d->deliverUpdateRequest();-
1361 } else {-
1362 QObject::event(ev);-
1363 }-
1364 break;-
1365 }-
1366-
1367 case QEvent::PlatformSurface: {-
1368 if ((static_cast<QPlatformSurfaceEvent *>(ev))->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) {-
1369-
1370 QOpenGLContext *context = QOpenGLContext::currentContext();-
1371 if (context && context->surface() == static_cast<QSurface *>(this))-
1372 context->doneCurrent();-
1373-
1374 }-
1375 break;-
1376 }-
1377-
1378 default:-
1379 return QObject::event(ev);-
1380 }-
1381 return true;-
1382}-
1383-
1384void QWindowPrivate::deliverUpdateRequest()-
1385{-
1386 QWindow * const q = q_func();-
1387 updateRequestPending = false;-
1388 QEvent request(QEvent::UpdateRequest);-
1389 QCoreApplication::sendEvent(q, &request);-
1390}-
1391void QWindow::requestUpdate()-
1392{-
1393 ((!(QThread::currentThread() == QCoreApplication::instance()->thread())) ? qt_assert_x("QWindow", "Updates can only be scheduled from the GUI (main) thread",-
1394 __FILE__-
1395 ,-
1396 21642199-
1397 ) : qt_noop())-
1398 ;-
1399-
1400 QWindowPrivate * const d = d_func();-
1401 if (d->updateRequestPending || !d->platformWindow)-
1402 return;-
1403 d->updateRequestPending = true;-
1404 d->platformWindow->requestUpdate();-
1405}-
1406-
1407-
1408-
1409-
1410-
1411-
1412void QWindow::keyPressEvent(QKeyEvent *ev)-
1413{-
1414 ev->ignore();-
1415}-
1416-
1417-
1418-
1419-
1420-
1421-
1422void QWindow::keyReleaseEvent(QKeyEvent *ev)-
1423{-
1424 ev->ignore();-
1425}-
1426void QWindow::focusInEvent(QFocusEvent *ev)-
1427{-
1428 ev->ignore();-
1429}-
1430void QWindow::focusOutEvent(QFocusEvent *ev)-
1431{-
1432 ev->ignore();-
1433}-
1434-
1435-
1436-
1437-
1438-
1439-
1440void QWindow::mousePressEvent(QMouseEvent *ev)-
1441{-
1442 ev->ignore();-
1443}-
1444-
1445-
1446-
1447-
1448-
1449-
1450void QWindow::mouseReleaseEvent(QMouseEvent *ev)-
1451{-
1452 ev->ignore();-
1453}-
1454-
1455-
1456-
1457-
1458-
1459-
1460void QWindow::mouseDoubleClickEvent(QMouseEvent *ev)-
1461{-
1462 ev->ignore();-
1463}-
1464-
1465-
1466-
1467-
1468void QWindow::mouseMoveEvent(QMouseEvent *ev)-
1469{-
1470 ev->ignore();-
1471}-
1472-
1473-
1474-
1475-
1476-
1477void QWindow::wheelEvent(QWheelEvent *ev)-
1478{-
1479 ev->ignore();-
1480}-
1481-
1482-
1483-
1484-
1485-
1486void QWindow::touchEvent(QTouchEvent *ev)-
1487{-
1488 ev->ignore();-
1489}-
1490void QWindow::tabletEvent(QTabletEvent *ev)-
1491{-
1492 ev->ignore();-
1493}-
1494bool QWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)-
1495{-
1496 (void)eventType;;-
1497 (void)message;;-
1498 (void)result;;-
1499 return false;-
1500}-
1501QPoint QWindow::mapToGlobal(const QPoint &pos) const-
1502{-
1503 const QWindowPrivate * const d = d_func();-
1504-
1505 if (d->platformWindow-
1506 && (type() == Qt::ForeignWindow || d->platformWindow->isEmbedded())) {-
1507 return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapToGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this);-
1508 }-
1509 return pos + d->globalPosition();-
1510}-
1511QPoint QWindow::mapFromGlobal(const QPoint &pos) const-
1512{-
1513 const QWindowPrivate * const d = d_func();-
1514-
1515 if (d->platformWindow-
1516 && (type() == Qt::ForeignWindow || d->platformWindow->isEmbedded())) {-
1517 return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapFromGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this);-
1518 }-
1519 return pos - d->globalPosition();-
1520}-
1521-
1522-
1523__attribute__((visibility("default"))) QWindowPrivate *qt_window_private(QWindow *window)-
1524{-
1525 return window->d_func();-
1526}-
1527-
1528void QWindowPrivate::maybeQuitOnLastWindowClosed()-
1529{-
1530 if (!QCoreApplication::instance())-
1531 return;-
1532-
1533 QWindow * const q = q_func();-
1534-
1535 bool quitOnClose = QGuiApplication::quitOnLastWindowClosed() && !q->parent();-
1536 QWindowList list = QGuiApplication::topLevelWindows();-
1537 bool lastWindowClosed = true;-
1538 for (int i = 0; i < list.size(); ++i) {-
1539 QWindow *w = list.at(i);-
1540 if (!w->isVisible() || w->transientParent() || w->type() == Qt::ToolTip)-
1541 continue;-
1542 lastWindowClosed = false;-
1543 break;-
1544 }-
1545 if (lastWindowClosed) {-
1546 QGuiApplicationPrivate::emitLastWindowClosed();-
1547 if (quitOnClose) {-
1548 QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance()));-
1549 applicationPrivate->maybeQuit();-
1550 }-
1551 }-
1552}-
1553-
1554QWindow *QWindowPrivate::topLevelWindow() const-
1555{-
1556 const QWindow * const q = q_func();-
1557-
1558 QWindow *window = const_cast<QWindow *>(q);-
1559-
1560 while (window) {-
1561 QWindow *parent = window->parent();-
1562 if (!parent)-
1563 parent = window->transientParent();-
1564-
1565 if (!parent)-
1566 break;-
1567-
1568 window = parent;-
1569 }-
1570-
1571 return window;-
1572}-
1573QWindow *QWindow::fromWinId(WId id)-
1574{-
1575 if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ForeignWindows)
!QGuiApplicati...oreignWindows)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1576 QMessageLogger(__FILE__, 24182454, __PRETTY_FUNCTION__).warning() << ("QWindow::fromWinId(): platform plugin does not support foreign windows.";);-
1577 return
never executed: return 0;
0;
never executed: return 0;
0
1578 }-
1579-
1580 QWindow *window = new QWindow;-
1581 window->setFlags(Qt::ForeignWindow);-
1582 window->setProperty("_q_foreignWinId", QVariant::fromValue(id));-
1583 window->create();-
1584 if (!window->handle()
!window->handle()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1585 delete window;-
1586 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
1587 }-
1588 return
never executed: return window;
window;
never executed: return window;
0
1589}-
1590void QWindow::alert(int msec)-
1591{-
1592 QWindowPrivate * const d = d_func();-
1593 if (!d->platformWindow || d->platformWindow->isAlertState() || isActive())-
1594 return;-
1595 d->platformWindow->setAlertState(true);-
1596 if (d->platformWindow->isAlertState() && msec)-
1597 QTimer::singleShot(msec, this, qFlagLocation("1""_q_clearAlert()" "\0" __FILE__ ":" "2447""2487"));-
1598}-
1599-
1600void QWindowPrivate::_q_clearAlert()-
1601{-
1602 if (platformWindow && platformWindow->isAlertState())-
1603 platformWindow->setAlertState(false);-
1604}-
1605void QWindow::setCursor(const QCursor &cursor)-
1606{-
1607 QWindowPrivate * const d = d_func();-
1608 d->setCursor(&cursor);-
1609}-
1610-
1611-
1612-
1613-
1614void QWindow::unsetCursor()-
1615{-
1616 QWindowPrivate * const d = d_func();-
1617 d->setCursor(0);-
1618}-
1619-
1620-
1621-
1622-
1623-
1624-
1625QCursor QWindow::cursor() const-
1626{-
1627 const QWindowPrivate * const d = d_func();-
1628 return d->cursor;-
1629}-
1630-
1631void QWindowPrivate::setCursor(const QCursor *newCursor)-
1632{-
1633-
1634 QWindow * const q = q_func();-
1635 if (newCursor
newCursorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1636 const Qt::CursorShape newShape = newCursor->shape();-
1637 if (newShape <= Qt::LastCursor
newShape <= Qt::LastCursorDescription
TRUEnever evaluated
FALSEnever evaluated
&& hasCursor
hasCursorDescription
TRUEnever evaluated
FALSEnever evaluated
&& newShape == cursor.shape()
newShape == cursor.shape()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1638 return;
never executed: return;
0
1639 cursor = *newCursor;-
1640 hasCursor = true;-
1641 }
never executed: end of block
else {
0
1642 if (!hasCursor
!hasCursorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1643 return;
never executed: return;
0
1644 cursor = QCursor(Qt::ArrowCursor);-
1645 hasCursor = false;-
1646 }
never executed: end of block
0
1647-
1648 QScreen* screen = q->screen();-
1649 if (applyCursorscreen
screenDescription
TRUEnever evaluated
FALSEnever evaluated
&& screen->handle()->cursor
screen->handle()->cursor()Description
TRUEnever evaluated
FALSEnever evaluated
()
screen->handle()->cursor()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1650 applyCursor();-
1651 QEvent event(QEvent::CursorChange);-
1652 QGuiApplication::sendEvent(q, &event);-
1653 }
never executed: end of block
0
1654}
never executed: end of block
0
1655-
boolvoid QWindowPrivate::applyCursor()
1657{-
1658 QWindow * const q = q_func();-
1659 if (QScreen *screen = q->screen())platformWindow
platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
)
{
0
1660 if (QPlatformCursor *platformCursor = screenq->screen()->handle()->cursor()
QPlatformCurso...le()->cursor()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1661 if (!platformWindow)-
return true;QCursor *c = QGuiApplication::overrideCursor();
1662 if (!c
!cDescription
TRUEnever evaluated
FALSEnever evaluated
&& hasCursor
hasCursorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1663 c = &cursor;
never executed: c = &cursor;
0
1664 platformCursor->changeCursor(c, q);-
1665 return true;}
never executed: end of block
0
1666 }
never executed: end of block
return false;
never executed: end of block
0
1667}
never executed: end of block
0
1668-
1669-
1670-
1671QDebug operator<<(QDebug debug, const QWindow *window)-
1672{-
1673 QDebugStateSaver saver(debug);-
1674 debug.nospace();-
1675 if (window) {-
1676 debug << window->metaObject()->className() << '(' << (const void *)window;-
1677 if (!window->objectName().isEmpty())-
1678 debug << ", name=" << window->objectName();-
1679 if (debug.verbosity() > 2) {-
1680 const QRect geometry = window->geometry();-
1681 if (window->isVisible())-
1682 debug << ", visible";-
1683 if (window->isExposed())-
1684 debug << ", exposed";-
1685 debug << ", state=" << window->windowState()-
1686 << ", type=" << window->type() << ", flags=" << window->flags()-
1687 << ", surface type=" << window->surfaceType();-
1688 if (window->isTopLevel())-
1689 debug << ", toplevel";-
1690 debug << ", " << geometry.width() << 'x' << geometry.height()-
1691 << forcesign << geometry.x() << geometry.y() << noforcesign;-
1692 const QMargins margins = window->frameMargins();-
1693 if (!margins.isNull())-
1694 debug << ", margins=" << margins;-
1695 debug << ", devicePixelRatio=" << window->devicePixelRatio();-
1696 if (const QPlatformWindow *platformWindow = window->handle())-
1697 debug << ", winId=0x" << hex << platformWindow->winId() << dec;-
1698 if (const QScreen *screen = window->screen())-
1699 debug << ", on " << screen->name();-
1700 }-
1701 debug << ')';-
1702 } else {-
1703 debug << "QWindow(0x0)";-
1704 }-
1705 return debug;-
1706}-
1707-
1708-
1709-
1710-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9