Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qwindow.h"
5
6#include <qpa/qplatformwindow.h>
7#include <qpa/qplatformintegration.h>
8#ifndef QT_NO_CONTEXTMENU
9#include <qpa/qplatformtheme.h>
10#endif
11#include "qsurfaceformat.h"
12#ifndef QT_NO_OPENGL
13#include <qpa/qplatformopenglcontext.h>
14#include "qopenglcontext.h"
15#include "qopenglcontext_p.h"
16#endif
17#include "qscreen.h"
18
19#include "qwindow_p.h"
20#include "qguiapplication_p.h"
21#if QT_CONFIG(accessibility)
22# include "qaccessible.h"
23#endif
24#include "qhighdpiscaling_p.h"
25#if QT_CONFIG(draganddrop)
27#endif // QT_CONFIG(draganddrop)
28
29#include <private/qevent_p.h>
30
31#include <QtCore/QTimer>
32#include <QtCore/QDebug>
33
34#include <QStyleHints>
35#include <qpa/qplatformcursor.h>
36#include <qpa/qplatformwindow_p.h>
37
39
126QWindow::QWindow(QScreen *targetScreen)
129{
130 Q_D(QWindow);
131 d->init(nullptr, targetScreen);
132}
133
135{
136 if (parent && parent->type() == Qt::Desktop) {
137 qWarning("QWindows cannot be reparented into desktop windows");
138 return nullptr;
139 }
140
141 return parent;
142}
143
154QWindow::QWindow(QWindow *parent)
155 : QWindow(*new QWindowPrivate(), parent)
156{
157}
158
171QWindow::QWindow(QWindowPrivate &dd, QWindow *parent)
172 : QObject(dd, nullptr)
174{
175 Q_D(QWindow);
176 d->init(nonDesktopParent(parent));
177}
178
182QWindow::~QWindow()
183{
184 Q_D(QWindow);
185 d->destroy();
186 // Decouple from parent before window goes under
187 setParent(nullptr);
190 QGuiApplicationPrivate::instance()->modalWindowList.removeOne(this);
191
192 // thse are normally cleared in destroy(), but the window may in
193 // some cases end up becoming the focus window again, or receive an enter
194 // event. Clear it again here as a workaround. See QTBUG-75326.
201
202 d->isWindow = false;
203}
204
206 = default;
207
209 = default;
210
211void QWindowPrivate::init(QWindow *parent, QScreen *targetScreen)
212{
213 Q_Q(QWindow);
214
215 q->QObject::setParent(parent);
216
217 isWindow = true;
218 parentWindow = static_cast<QWindow *>(q->QObject::parent());
219
220 QScreen *connectScreen = targetScreen ? targetScreen : QGuiApplication::primaryScreen();
221
222 if (!parentWindow)
223 connectToScreen(connectScreen);
224
225 // If your application aborts here, you are probably creating a QWindow
226 // before the screen list is populated.
228 qFatal("Cannot create window: no screens available");
229 }
231
233 devicePixelRatio = connectScreen->devicePixelRatio();
234
236 // We may have changed scaling; trigger resize event if needed,
237 // except on Windows, where we send resize events during WM_DPICHANGED
238 // event handling. FIXME: unify DPI change handling across all platforms.
239#ifndef Q_OS_WIN
240 if (q->handle()) {
241 QWindowSystemInterfacePrivate::GeometryChangeEvent gce(q, QHighDpi::fromNativePixels(q->handle()->geometry(), q));
242 QGuiApplicationPrivate::processGeometryChangeEvent(&gce);
243 }
244#else
245 Q_UNUSED(q);
246#endif
248 });
249
250 if (parentWindow) {
252 QCoreApplication::sendEvent(parentWindow, &childAddedEvent);
253 }
254}
255
305QWindow::Visibility QWindow::visibility() const
306{
307 Q_D(const QWindow);
308 return d->visibility;
309}
310
311void QWindow::setVisibility(Visibility v)
312{
313 switch (v) {
314 case Hidden:
315 hide();
316 break;
317 case AutomaticVisibility:
318 show();
319 break;
320 case Windowed:
321 showNormal();
322 break;
323 case Minimized:
325 break;
326 case Maximized:
328 break;
329 case FullScreen:
331 break;
332 default:
333 Q_ASSERT(false);
334 }
335}
336
337/*
338 Subclasses may override this function to run custom setVisible
339 logic. Subclasses that do so must call the base class implementation
340 at some point to make the native window visible, and must not
341 call QWindow::setVisble() since that will recurse back here.
342*/
344{
345 Q_Q(QWindow);
346
347 if (this->visible != visible) {
348 this->visible = visible;
349 emit q->visibleChanged(visible);
351 } else if (platformWindow) {
352 // Visibility hasn't changed, and the platform window is in sync
353 return;
354 }
355
356 if (!platformWindow) {
357 // If we have a parent window, but the parent hasn't been created yet, we
358 // can defer creation until the parent is created or we're re-parented.
359 if (parentWindow && !parentWindow->handle())
360 return;
361
362 // We only need to create the window if it's being shown
363 if (visible) {
364 // FIXME: At this point we've already updated the visible state of
365 // the QWindow, so if the platform layer reads the window state during
366 // creation, and reflects that in the native window, it will end up
367 // with a visible window. This may in turn result in resize or expose
368 // events from the platform before we have sent the show event below.
369 q->create();
370 }
371 }
372
373 if (visible) {
374 // remove posted quit events when showing a new window
376
377 if (q->type() == Qt::Window) {
379 QString &firstWindowTitle = app_priv->firstWindowTitle;
380 if (!firstWindowTitle.isEmpty()) {
381 q->setTitle(firstWindowTitle);
382 firstWindowTitle = QString();
383 }
384 if (!app_priv->forcedWindowIcon.isNull())
385 q->setIcon(app_priv->forcedWindowIcon);
386
387 // Handling of the -qwindowgeometry, -geometry command line arguments
388 static bool geometryApplied = false;
389 if (!geometryApplied) {
390 geometryApplied = true;
392 }
393 }
394
395 QShowEvent showEvent;
396 QGuiApplication::sendEvent(q, &showEvent);
397 }
398
399 if (q->isModal()) {
400 if (visible)
402 else
404 // QShapedPixmapWindow is used on some platforms for showing a drag pixmap, so don't block
405 // input to this window as it is performing a drag - QTBUG-63846
407#if QT_CONFIG(draganddrop)
408 && !qobject_cast<QShapedPixmapWindow *>(q)
409#endif // QT_CONFIG(draganddrop)
410 ) {
412 }
413
414#ifndef QT_NO_CURSOR
416 applyCursor();
417#endif
418
419 if (platformWindow)
421
422 if (!visible) {
423 QHideEvent hideEvent;
424 QGuiApplication::sendEvent(q, &hideEvent);
425 }
426}
427
429{
430 Q_Q(QWindow);
431
432 QWindow::Visibility old = visibility;
433
434 if (!visible)
435 visibility = QWindow::Hidden;
437 visibility = QWindow::Minimized;
439 visibility = QWindow::FullScreen;
441 visibility = QWindow::Maximized;
442 else
443 visibility = QWindow::Windowed;
444
445 if (visibility != old)
446 emit q->visibilityChanged(visibility);
447}
448
450{
451 Q_Q(QWindow);
452
453 if (!q->parent())
454 return;
455
456 QObjectList &siblings = q->parent()->d_ptr->children;
457
458 const qsizetype siblingCount = siblings.size() - 1;
459 if (siblingCount == 0)
460 return;
461
462 const qsizetype currentPosition = siblings.indexOf(q);
463 Q_ASSERT(currentPosition >= 0);
464
465 const qsizetype targetPosition = position == PositionTop ? siblingCount : 0;
466
467 if (currentPosition == targetPosition)
468 return;
469
470 siblings.move(currentPosition, targetPosition);
471}
472
474{
475 Q_Q(const QWindow);
476 const QScreen *oldScreen = q->screen();
477 return oldScreen != newScreen && (platformWindow || !oldScreen)
478 && !(oldScreen && oldScreen->virtualSiblings().contains(newScreen));
479}
480
486
492
494{
495 Q_Q(QWindow);
496 emit q->screenChanged(newScreen);
497 for (QObject *child : q->children()) {
498 if (child->isWindowType())
499 static_cast<QWindow *>(child)->d_func()->emitScreenChangedRecursion(newScreen);
500 }
501}
502
503void QWindowPrivate::setTopLevelScreen(QScreen *newScreen, bool recreate)
504{
505 Q_Q(QWindow);
506 if (parentWindow) {
507 qWarning() << q << '(' << newScreen << "): Attempt to set a screen on a child window.";
508 return;
509 }
510 if (newScreen != topLevelScreen) {
511 const bool shouldRecreate = recreate && windowRecreationRequired(newScreen);
512 const bool shouldShow = visibilityOnDestroy && !topLevelScreen;
513 if (shouldRecreate && platformWindow)
514 q->destroy();
515 connectToScreen(newScreen);
516 if (shouldShow)
517 q->setVisible(true);
518 else if (newScreen && shouldRecreate)
519 create(true);
521 }
522}
523
524static constexpr auto kForeignWindowId = "_q_foreignWinId";
525
526void QWindowPrivate::create(bool recursive)
527{
528 Q_Q(QWindow);
529 if (platformWindow)
530 return;
531
532 // avoid losing update requests when re-creating
533 const bool needsUpdate = updateRequestPending;
534 // the platformWindow, if there was one, is now gone, so make this flag reflect reality now
535 updateRequestPending = false;
536
537 if (q->parent())
538 q->parent()->create();
539
540 if (platformWindow) {
541 // Creating the parent window will end up creating any child window
542 // that was already visible, via setVisible. If this applies to us,
543 // we will already have a platform window at this point.
544 return;
545 }
546
547 // QPlatformWindow will poll geometry() during construction below. Set the
548 // screen here so that high-dpi scaling will use the correct scale factor.
549 if (q->isTopLevel()) {
552 }
553
554 const WId nativeHandle = q->property(kForeignWindowId).value<WId>();
555
557 platformWindow = nativeHandle ? platformIntegration->createForeignWindow(q, nativeHandle)
558 : platformIntegration->createPlatformWindow(q);
560
561 if (!platformWindow) {
562 qWarning() << "Failed to create platform window for" << q << "with flags" << q->flags();
563 return;
564 }
565
567
568 QObjectList childObjects = q->children();
569 for (int i = 0; i < childObjects.size(); i ++) {
570 QObject *object = childObjects.at(i);
571 if (!object->isWindowType())
572 continue;
573
574 QWindow *childWindow = static_cast<QWindow *>(object);
575 if (recursive)
576 childWindow->d_func()->create(recursive);
577
578 // The child may have had deferred creation due to this window not being created
579 // at the time setVisible was called, so we re-apply the visible state, which
580 // may result in creating the child, and emitting the appropriate signals.
581 if (childWindow->isVisible())
582 childWindow->setVisible(true);
583
584 if (QPlatformWindow *childPlatformWindow = childWindow->d_func()->platformWindow)
585 childPlatformWindow->setParent(this->platformWindow);
586 }
587
590
592
593 if (needsUpdate)
594 q->requestUpdate();
595}
596
600
601// Allows for manipulating the suggested geometry before a resize/move
602// event in derived classes for platforms that support it, for example to
603// implement heightForWidth().
609
611 qxp::function_ref<void()> funcWidthChanged,
612 qxp::function_ref<void()> funcHeightChanged)
613{
614 Q_Q(QWindow);
615 Q_ASSERT(oldSizeMember);
616 const QSize adjustedSize =
618 if (*oldSizeMember == adjustedSize)
619 return;
620 const bool widthChanged = adjustedSize.width() != oldSizeMember->width();
621 const bool heightChanged = adjustedSize.height() != oldSizeMember->height();
622 *oldSizeMember = adjustedSize;
623
624 if (platformWindow && q->isTopLevel())
626
627 if (widthChanged)
628 funcWidthChanged();
629 if (heightChanged)
630 funcHeightChanged();
631
632 // resize window if current size is outside of min and max limits
635 const QSize currentSize = q->size();
636 const QSize boundedSize = currentSize.expandedTo(minimumSize).boundedTo(maximumSize);
637 q->resize(boundedSize);
638 }
639}
640
654void QWindow::setSurfaceType(SurfaceType surfaceType)
655{
656 Q_D(QWindow);
657 d->surfaceType = surfaceType;
658}
659
666{
667 Q_D(const QWindow);
668 return d->surfaceType;
669}
670
689void QWindow::setVisible(bool visible)
690{
691 Q_D(QWindow);
692
693 d->setVisible(visible);
694}
695
696bool QWindow::isVisible() const
697{
698 Q_D(const QWindow);
699
700 return d->visible;
701}
702
717void QWindow::create()
718{
719 Q_D(QWindow);
720 d->create(false);
721}
722
734WId QWindow::winId() const
735{
736 Q_D(const QWindow);
737
738 if (!d->platformWindow)
739 const_cast<QWindow *>(this)->create();
740
741 if (!d->platformWindow)
742 return 0;
743
744 return d->platformWindow->winId();
745}
746
757QWindow *QWindow::parent(AncestorMode mode) const
758{
759 Q_D(const QWindow);
760 return d->parentWindow ? d->parentWindow : (mode == IncludeTransients ? transientParent() : nullptr);
761}
762
773void QWindow::setParent(QWindow *parent)
774{
776
777 Q_D(QWindow);
778 if (d->parentWindow == parent)
779 return;
780
781 QScreen *newScreen = parent ? parent->screen() : screen();
782 if (d->windowRecreationRequired(newScreen)) {
783 qWarning() << this << '(' << parent << "): Cannot change screens (" << screen() << newScreen << ')';
784 return;
785 }
786
787 QEvent parentAboutToChangeEvent(QEvent::ParentWindowAboutToChange);
788 QCoreApplication::sendEvent(this, &parentAboutToChangeEvent);
789
790 const auto previousParent = d->parentWindow;
792 d->parentWindow = parent;
793
794 if (parent)
795 d->disconnectFromScreen();
796 else
797 d->connectToScreen(newScreen);
798
799 // If we were set visible, but not created because we were a child, and we're now
800 // re-parented into a created parent, or to being a top level, we need re-apply the
801 // visibility state, which will also create.
802 if (isVisible() && (!parent || parent->handle()))
803 setVisible(true);
804
805 if (d->platformWindow) {
806 if (parent)
807 parent->create();
808
809 d->platformWindow->setParent(parent ? parent->d_func()->platformWindow : nullptr);
810 }
811
813
814 if (previousParent) {
815 QChildWindowEvent childRemovedEvent(QEvent::ChildWindowRemoved, this);
816 QCoreApplication::sendEvent(previousParent, &childRemovedEvent);
817 }
818
819 if (parent) {
820 QChildWindowEvent childAddedEvent(QEvent::ChildWindowAdded, this);
821 QCoreApplication::sendEvent(parent, &childAddedEvent);
822 }
823
824 QEvent parentChangedEvent(QEvent::ParentWindowChange);
825 QCoreApplication::sendEvent(this, &parentChangedEvent);
826}
827
831bool QWindow::isTopLevel() const
832{
833 Q_D(const QWindow);
834 return d->parentWindow == nullptr;
835}
836
844bool QWindow::isModal() const
845{
846 Q_D(const QWindow);
847 return d->modality != Qt::NonModal;
848}
849
862{
863 Q_D(const QWindow);
864 return d->modality;
865}
866
867void QWindow::setModality(Qt::WindowModality modality)
868{
869 Q_D(QWindow);
870 if (d->modality == modality)
871 return;
872 d->modality = modality;
874}
875
907void QWindow::setFormat(const QSurfaceFormat &format)
908{
909 Q_D(QWindow);
910 d->requestedFormat = format;
911}
912
923QSurfaceFormat QWindow::requestedFormat() const
924{
925 Q_D(const QWindow);
926 return d->requestedFormat;
927}
928
947{
948 Q_D(const QWindow);
949 if (d->platformWindow)
950 return d->platformWindow->format();
951 return d->requestedFormat;
952}
953
967void QWindow::setFlags(Qt::WindowFlags flags)
968{
969 Q_D(QWindow);
970 if (d->windowFlags == flags)
971 return;
972
973 if (d->platformWindow)
974 d->platformWindow->setWindowFlags(flags);
975 d->windowFlags = flags;
976}
977
978Qt::WindowFlags QWindow::flags() const
979{
980 Q_D(const QWindow);
981 Qt::WindowFlags flags = d->windowFlags;
982
983 if (d->platformWindow && d->platformWindow->isForeignWindow())
985
986 return flags;
987}
988
997void QWindow::setFlag(Qt::WindowType flag, bool on)
998{
999 Q_D(QWindow);
1000 if (on)
1001 setFlags(d->windowFlags | flag);
1002 else
1003 setFlags(d->windowFlags & ~flag);
1004}
1005
1014Qt::WindowType QWindow::type() const
1015{
1016 return static_cast<Qt::WindowType>(int(flags() & Qt::WindowType_Mask));
1017}
1018
1031{
1032 Q_D(QWindow);
1033 bool changed = false;
1034 if (d->windowTitle != title) {
1035 d->windowTitle = title;
1036 changed = true;
1037 }
1038 if (d->platformWindow && type() != Qt::Desktop)
1039 d->platformWindow->setWindowTitle(title);
1040 if (changed)
1041 emit windowTitleChanged(title);
1042}
1043
1044QString QWindow::title() const
1045{
1046 Q_D(const QWindow);
1047 return d->windowTitle;
1048}
1049
1057void QWindow::setFilePath(const QString &filePath)
1058{
1059 Q_D(QWindow);
1060 d->windowFilePath = filePath;
1061 if (d->platformWindow)
1062 d->platformWindow->setWindowFilePath(filePath);
1063}
1064
1070QString QWindow::filePath() const
1071{
1072 Q_D(const QWindow);
1073 return d->windowFilePath;
1074}
1075
1087void QWindow::setIcon(const QIcon &icon)
1088{
1089 Q_D(QWindow);
1090 d->windowIcon = icon;
1091 if (d->platformWindow)
1092 d->platformWindow->setWindowIcon(icon);
1095}
1096
1102QIcon QWindow::icon() const
1103{
1104 Q_D(const QWindow);
1105 if (d->windowIcon.isNull())
1107 return d->windowIcon;
1108}
1109
1116{
1117 Q_D(QWindow);
1118
1119 d->updateSiblingPosition(QWindowPrivate::PositionTop);
1120
1121 if (d->platformWindow)
1122 d->platformWindow->raise();
1123}
1124
1131{
1132 Q_D(QWindow);
1133
1134 d->updateSiblingPosition(QWindowPrivate::PositionBottom);
1135
1136 if (d->platformWindow)
1137 d->platformWindow->lower();
1138}
1139
1158bool QWindow::startSystemResize(Qt::Edges edges)
1159{
1160 Q_D(QWindow);
1161 if (Q_UNLIKELY(!isVisible() || !d->platformWindow || d->maximumSize == d->minimumSize))
1162 return false;
1163
1164 const bool isSingleEdge = edges == Qt::TopEdge || edges == Qt::RightEdge || edges == Qt::BottomEdge || edges == Qt::LeftEdge;
1165 const bool isCorner =
1166 edges == (Qt::TopEdge | Qt::LeftEdge) ||
1167 edges == (Qt::TopEdge | Qt::RightEdge) ||
1168 edges == (Qt::BottomEdge | Qt::RightEdge) ||
1169 edges == (Qt::BottomEdge | Qt::LeftEdge);
1170
1171 if (Q_UNLIKELY(!isSingleEdge && !isCorner)) {
1172 qWarning() << "Invalid edges" << edges << "passed to QWindow::startSystemResize, ignoring.";
1173 return false;
1174 }
1175
1176 return d->platformWindow->startSystemResize(edges);
1177}
1178
1197{
1198 Q_D(QWindow);
1199 if (Q_UNLIKELY(!isVisible() || !d->platformWindow))
1200 return false;
1201
1202 return d->platformWindow->startSystemMove();
1203}
1204
1219void QWindow::setOpacity(qreal level)
1220{
1221 Q_D(QWindow);
1222 if (level == d->opacity)
1223 return;
1224 d->opacity = level;
1225 if (d->platformWindow) {
1226 d->platformWindow->setOpacity(level);
1227 emit opacityChanged(level);
1228 }
1229}
1230
1231qreal QWindow::opacity() const
1232{
1233 Q_D(const QWindow);
1234 return d->opacity;
1235}
1236
1247void QWindow::setMask(const QRegion &region)
1248{
1249 Q_D(QWindow);
1250 if (d->platformWindow)
1251 d->platformWindow->setMask(QHighDpi::toNativeLocalRegion(region, this));
1252 d->mask = region;
1253}
1254
1261QRegion QWindow::mask() const
1262{
1263 Q_D(const QWindow);
1264 return d->mask;
1265}
1266
1272void QWindow::requestActivate()
1273{
1274 Q_D(QWindow);
1276 qWarning() << "requestActivate() called for " << this << " which has Qt::WindowDoesNotAcceptFocus set.";
1277 return;
1278 }
1279 if (d->platformWindow)
1280 d->platformWindow->requestActivateWindow();
1281}
1282
1294bool QWindow::isExposed() const
1295{
1296 Q_D(const QWindow);
1297 return d->exposed;
1298}
1299
1320bool QWindow::isActive() const
1321{
1322 Q_D(const QWindow);
1323 if (!d->platformWindow)
1324 return false;
1325
1327
1328 // Means the whole application lost the focus
1329 if (!focus)
1330 return false;
1331
1332 if (focus == this)
1333 return true;
1334
1335 if (QWindow *p = parent(IncludeTransients))
1336 return p->isActive();
1337 else
1338 return isAncestorOf(focus);
1339}
1340
1360void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation)
1361{
1362 Q_D(QWindow);
1363 if (d->contentOrientation == orientation)
1364 return;
1365 if (d->platformWindow)
1366 d->platformWindow->handleContentOrientationChange(orientation);
1367 d->contentOrientation = orientation;
1368 emit contentOrientationChanged(orientation);
1369}
1370
1372{
1373 Q_D(const QWindow);
1374 return d->contentOrientation;
1375}
1376
1389qreal QWindow::devicePixelRatio() const
1390{
1391 Q_D(const QWindow);
1392 return d->devicePixelRatio;
1393}
1394
1395/*
1396 Updates the cached devicePixelRatio value by polling for a new value.
1397 Sends QEvent::DevicePixelRatioChange to the window if the DPR has changed.
1398 Returns true if the DPR was changed.
1399*/
1401{
1402 Q_Q(QWindow);
1403
1404 // If there is no platform window use the associated screen's devicePixelRatio,
1405 // which typically is the primary screen and will be correct for single-display
1406 // systems (a very common case).
1407 const qreal newDevicePixelRatio = platformWindow ?
1408 platformWindow->devicePixelRatio() * QHighDpiScaling::factor(q) : q->screen()->devicePixelRatio();
1409
1410 if (newDevicePixelRatio == devicePixelRatio)
1411 return false;
1412
1413 devicePixelRatio = newDevicePixelRatio;
1414 QEvent dprChangeEvent(QEvent::DevicePixelRatioChange);
1415 QGuiApplication::sendEvent(q, &dprChangeEvent);
1416 return true;
1417}
1418
1420{
1422 return Qt::WindowMinimized;
1423 else if (state & Qt::WindowFullScreen)
1424 return Qt::WindowFullScreen;
1425 else if (state & Qt::WindowMaximized)
1426 return Qt::WindowMaximized;
1427 return Qt::WindowNoState;
1428}
1429
1440void QWindow::setWindowState(Qt::WindowState state)
1441{
1442 setWindowStates(state);
1443}
1444
1461void QWindow::setWindowStates(Qt::WindowStates state)
1462{
1463 Q_D(QWindow);
1464 if (state & Qt::WindowActive) {
1465 qWarning("QWindow::setWindowStates does not accept Qt::WindowActive");
1466 state &= ~Qt::WindowActive;
1467 }
1468
1469 if (d->platformWindow)
1470 d->platformWindow->setWindowState(state);
1471
1472 auto originalEffectiveState = QWindowPrivate::effectiveState(d->windowState);
1473 d->windowState = state;
1474 auto newEffectiveState = QWindowPrivate::effectiveState(d->windowState);
1475 if (newEffectiveState != originalEffectiveState)
1476 emit windowStateChanged(newEffectiveState);
1477
1478 d->updateVisibility();
1479}
1480
1486Qt::WindowState QWindow::windowState() const
1487{
1488 Q_D(const QWindow);
1489 return QWindowPrivate::effectiveState(d->windowState);
1490}
1491
1503Qt::WindowStates QWindow::windowStates() const
1504{
1505 Q_D(const QWindow);
1506 return d->windowState;
1507}
1508
1531void QWindow::setTransientParent(QWindow *parent)
1532{
1533 Q_D(QWindow);
1534 if (parent && !parent->isTopLevel()) {
1535 qWarning() << parent << "must be a top level window.";
1536 return;
1537 }
1538 if (parent == this) {
1539 qWarning() << "transient parent" << parent << "cannot be same as window";
1540 return;
1541 }
1542
1543 d->transientParent = parent;
1544
1546 emit transientParentChanged(parent);
1547}
1548
1549QWindow *QWindow::transientParent() const
1550{
1551 Q_D(const QWindow);
1552 return d->transientParent.data();
1553}
1554
1555/*
1556 The setter for the QWindow::transientParent property.
1557 The only reason this exists is to set the transientParentPropertySet flag
1558 so that Qt Quick knows whether it was set programmatically (because of
1559 Window declaration context) or because the user set the property.
1560*/
1562{
1563 Q_Q(QWindow);
1564 q->setTransientParent(parent);
1566}
1567
1582bool QWindow::isAncestorOf(const QWindow *child, AncestorMode mode) const
1583{
1584 if (child->parent() == this || (mode == IncludeTransients && child->transientParent() == this))
1585 return true;
1586
1587 if (QWindow *parent = child->parent(mode)) {
1588 if (isAncestorOf(parent, mode))
1589 return true;
1590 } else if (handle() && child->handle()) {
1591 if (handle()->isAncestorOf(child->handle()))
1592 return true;
1593 }
1594
1595 return false;
1596}
1597
1603QSize QWindow::minimumSize() const
1604{
1605 Q_D(const QWindow);
1606 return d->minimumSize;
1607}
1608
1614QSize QWindow::maximumSize() const
1615{
1616 Q_D(const QWindow);
1617 return d->maximumSize;
1618}
1619
1625QSize QWindow::baseSize() const
1626{
1627 Q_D(const QWindow);
1628 return d->baseSize;
1629}
1630
1636QSize QWindow::sizeIncrement() const
1637{
1638 Q_D(const QWindow);
1639 return d->sizeIncrement;
1640}
1641
1649void QWindow::setMinimumSize(const QSize &size)
1650{
1651 Q_D(QWindow);
1652 d->setMinOrMaxSize(
1653 &d->minimumSize, size, [this, d]() { emit minimumWidthChanged(d->minimumSize.width()); },
1654 [this, d]() { emit minimumHeightChanged(d->minimumSize.height()); });
1655}
1656
1662{
1663 Q_D(QWindow);
1664 if (x() != arg)
1665 setGeometry(QRect(arg, y(), width(), height()));
1666 else
1667 d->positionAutomatic = false;
1668}
1669
1675{
1676 Q_D(QWindow);
1677 if (y() != arg)
1678 setGeometry(QRect(x(), arg, width(), height()));
1679 else
1680 d->positionAutomatic = false;
1681}
1682
1688{
1689 resize(w, height());
1690}
1691
1697{
1698 resize(width(), h);
1699}
1700
1706{
1707 setMinimumSize(QSize(w, minimumHeight()));
1708}
1709
1715{
1716 setMinimumSize(QSize(minimumWidth(), h));
1717}
1718
1726void QWindow::setMaximumSize(const QSize &size)
1727{
1728 Q_D(QWindow);
1729 d->setMinOrMaxSize(
1730 &d->maximumSize, size, [this, d]() { emit maximumWidthChanged(d->maximumSize.width()); },
1731 [this, d]() { emit maximumHeightChanged(d->maximumSize.height()); });
1732}
1733
1739{
1740 setMaximumSize(QSize(w, maximumHeight()));
1741}
1742
1748{
1749 setMaximumSize(QSize(maximumWidth(), h));
1750}
1751
1760void QWindow::setBaseSize(const QSize &size)
1761{
1762 Q_D(QWindow);
1763 if (d->baseSize == size)
1764 return;
1765 d->baseSize = size;
1766 if (d->platformWindow && isTopLevel())
1767 d->platformWindow->propagateSizeHints();
1768}
1769
1784void QWindow::setSizeIncrement(const QSize &size)
1785{
1786 Q_D(QWindow);
1787 if (d->sizeIncrement == size)
1788 return;
1789 d->sizeIncrement = size;
1790 if (d->platformWindow && isTopLevel())
1791 d->platformWindow->propagateSizeHints();
1792}
1793
1802void QWindow::setGeometry(int posx, int posy, int w, int h)
1803{
1804 setGeometry(QRect(posx, posy, w, h));
1805}
1806
1815{
1816 Q_D(QWindow);
1817 d->positionAutomatic = false;
1818 const QRect oldRect = geometry();
1819 if (rect == oldRect)
1820 return;
1821
1822 d->positionPolicy = QWindowPrivate::WindowFrameExclusive;
1823 if (d->platformWindow) {
1824 QScreen *newScreen = d->screenForGeometry(rect);
1825 if (newScreen && isTopLevel())
1826 d->setTopLevelScreen(newScreen, true);
1827 d->platformWindow->setGeometry(QHighDpi::toNativeWindowGeometry(rect, this));
1828 } else {
1829 d->geometry = rect;
1830
1831 if (rect.x() != oldRect.x())
1832 emit xChanged(rect.x());
1833 if (rect.y() != oldRect.y())
1834 emit yChanged(rect.y());
1835 if (rect.width() != oldRect.width())
1836 emit widthChanged(rect.width());
1837 if (rect.height() != oldRect.height())
1838 emit heightChanged(rect.height());
1839 }
1840}
1841
1842/*
1843 This is equivalent to QPlatformWindow::screenForGeometry, but in platform
1844 independent coordinates. The duplication is unfortunate, but there is a
1845 chicken and egg problem here: we cannot convert to native coordinates
1846 before we know which screen we are on.
1847*/
1849{
1850 Q_Q(const QWindow);
1851 QScreen *currentScreen = q->screen();
1852 QScreen *fallback = currentScreen;
1853 QPoint center = newGeometry.center();
1854 if (!q->parent() && currentScreen && !currentScreen->geometry().contains(center)) {
1855 const auto screens = currentScreen->virtualSiblings();
1856 for (QScreen* screen : screens) {
1857 if (screen->geometry().contains(center))
1858 return screen;
1859 if (screen->geometry().intersects(newGeometry))
1860 fallback = screen;
1861 }
1862 }
1863 return fallback;
1864}
1865
1866
1874QRect QWindow::geometry() const
1875{
1876 Q_D(const QWindow);
1877 if (d->platformWindow) {
1878 const auto nativeGeometry = d->platformWindow->geometry();
1879 return QHighDpi::fromNativeWindowGeometry(nativeGeometry, this);
1880 }
1881 return d->geometry;
1882}
1883
1889QMargins QWindow::frameMargins() const
1890{
1891 Q_D(const QWindow);
1892 if (d->platformWindow)
1893 return QHighDpi::fromNativePixels(d->platformWindow->frameMargins(), this);
1894 return QMargins();
1895}
1896
1904QRect QWindow::frameGeometry() const
1905{
1906 Q_D(const QWindow);
1907 if (d->platformWindow) {
1908 QMargins m = frameMargins();
1909 return QHighDpi::fromNativeWindowGeometry(d->platformWindow->geometry(), this).adjusted(-m.left(), -m.top(), m.right(), m.bottom());
1910 }
1911 return d->geometry;
1912}
1913
1921QPoint QWindow::framePosition() const
1922{
1923 Q_D(const QWindow);
1924 if (d->platformWindow) {
1925 QMargins margins = frameMargins();
1926 return QHighDpi::fromNativeWindowGeometry(d->platformWindow->geometry().topLeft(), this) - QPoint(margins.left(), margins.top());
1927 }
1928 return d->geometry.topLeft();
1929}
1930
1938void QWindow::setFramePosition(const QPoint &point)
1939{
1940 Q_D(QWindow);
1941 d->positionPolicy = QWindowPrivate::WindowFrameInclusive;
1942 d->positionAutomatic = false;
1943 if (d->platformWindow) {
1944 d->platformWindow->setGeometry(QHighDpi::toNativeWindowGeometry(QRect(point, size()), this));
1945 } else {
1946 d->geometry.moveTopLeft(point);
1947 }
1948}
1949
1964void QWindow::setPosition(const QPoint &pt)
1965{
1966 setGeometry(QRect(pt, size()));
1967}
1968
1976void QWindow::setPosition(int posx, int posy)
1977{
1978 setPosition(QPoint(posx, posy));
1979}
1980
2007void QWindow::resize(int w, int h)
2008{
2009 resize(QSize(w, h));
2010}
2011
2017void QWindow::resize(const QSize &newSize)
2018{
2019 Q_D(QWindow);
2020
2021 const QSize oldSize = size();
2022 if (newSize == oldSize)
2023 return;
2024
2025 d->positionPolicy = QWindowPrivate::WindowFrameExclusive;
2026 if (d->platformWindow) {
2027 d->platformWindow->setGeometry(
2028 QHighDpi::toNativeWindowGeometry(QRect(position(), newSize), this));
2029 } else {
2030 d->geometry.setSize(newSize);
2031 if (newSize.width() != oldSize.width())
2032 emit widthChanged(newSize.width());
2033 if (newSize.height() != oldSize.height())
2034 emit heightChanged(newSize.height());
2035 }
2036}
2037
2043void QWindow::destroy()
2044{
2045 Q_D(QWindow);
2046 if (!d->platformWindow)
2047 return;
2048
2049 if (d->platformWindow->isForeignWindow())
2050 return;
2051
2052 d->destroy();
2053}
2054
2056{
2057 if (!platformWindow)
2058 return;
2059
2060 Q_Q(QWindow);
2061 QObjectList childrenWindows = q->children();
2062 for (int i = 0; i < childrenWindows.size(); i++) {
2063 QObject *object = childrenWindows.at(i);
2064 if (object->isWindowType()) {
2065 QWindow *w = static_cast<QWindow*>(object);
2066 auto *childPlatformWindow = w->handle();
2067 if (!childPlatformWindow)
2068 continue;
2069
2070 // Decouple the foreign window from this window,
2071 // so that destroying our native handle doesn't
2072 // bring down the foreign window as well.
2073 if (childPlatformWindow->isForeignWindow())
2074 childPlatformWindow->setParent(nullptr);
2075
2076 qt_window_private(w)->destroy();
2077 }
2078 }
2079
2080 bool wasVisible = q->isVisible();
2081 visibilityOnDestroy = wasVisible && platformWindow;
2082
2083 q->setVisible(false);
2084
2085 // Let subclasses act, typically by doing graphics resource cleaup, when
2086 // the window, to which graphics resource may be tied, is going away.
2087 //
2088 // NB! This is dysfunctional when destroy() is invoked from the dtor since
2089 // a reimplemented event() will not get called in the subclasses at that
2090 // stage. However, the typical QWindow cleanup involves either close() or
2091 // going through QWindowContainer, both of which will do an explicit, early
2092 // destroy(), which is good here.
2093
2096
2097 // Unset platformWindow before deleting, so that the destructor of the
2098 // platform window does not recurse back into the platform window via
2099 // this window during destruction (e.g. as a result of platform events).
2100 delete std::exchange(platformWindow, nullptr);
2101
2108
2109 for (int i = 0; i < QGuiApplicationPrivate::tabletDevicePoints.size(); ++i)
2112
2113 resizeEventPending = true;
2114 receivedExpose = false;
2115 exposed = false;
2116}
2117
2123QPlatformWindow *QWindow::handle() const
2124{
2125 Q_D(const QWindow);
2126 return d->platformWindow;
2127}
2128
2135{
2136 Q_D(const QWindow);
2137 return d->platformWindow;
2138}
2139
2150bool QWindow::setKeyboardGrabEnabled(bool grab)
2151{
2152 Q_D(QWindow);
2153 if (d->platformWindow)
2154 return d->platformWindow->setKeyboardGrabEnabled(grab);
2155 return false;
2156}
2157
2167bool QWindow::setMouseGrabEnabled(bool grab)
2168{
2169 Q_D(QWindow);
2170 if (d->platformWindow)
2171 return d->platformWindow->setMouseGrabEnabled(grab);
2172 return false;
2173}
2174
2182QScreen *QWindow::screen() const
2183{
2184 Q_D(const QWindow);
2185 return d->parentWindow ? d->parentWindow->screen() : d->topLevelScreen.data();
2186}
2187
2201void QWindow::setScreen(QScreen *newScreen)
2202{
2203 Q_D(QWindow);
2204 if (!newScreen)
2205 newScreen = QGuiApplication::primaryScreen();
2206 d->setTopLevelScreen(newScreen, newScreen != nullptr);
2207}
2208
2222QAccessibleInterface *QWindow::accessibleRoot() const
2223{
2224 return nullptr;
2225}
2226
2241{
2242 return const_cast<QWindow *>(this);
2243}
2244
2255{
2256 if (parent()) {
2257 showNormal();
2258 } else {
2259 const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
2260 Qt::WindowState defaultState = platformIntegration->defaultWindowState(d_func()->windowFlags);
2261 if (defaultState == Qt::WindowFullScreen)
2263 else if (defaultState == Qt::WindowMaximized)
2264 showMaximized();
2265 else
2266 showNormal();
2267 }
2268}
2269
2278{
2279 setVisible(false);
2280}
2281
2291{
2292 setWindowStates(Qt::WindowMinimized);
2293 setVisible(true);
2294}
2295
2305{
2306 setWindowStates(Qt::WindowMaximized);
2307 setVisible(true);
2308}
2309
2322{
2323 setWindowStates(Qt::WindowFullScreen);
2324 setVisible(true);
2325#if !defined Q_OS_QNX // On QNX this window will be activated anyway from libscreen
2326 // activating it here before libscreen activates it causes problems
2327 requestActivate();
2328#endif
2329}
2330
2340{
2341 setWindowStates(Qt::WindowNoState);
2342 setVisible(true);
2343}
2344
2355{
2356 Q_D(QWindow);
2357 if (d->inClose)
2358 return true;
2359
2360 // Do not close non top level windows
2361 if (!isTopLevel())
2362 return false;
2363
2364 if (!d->platformWindow)
2365 return true;
2366
2367 // The window might be deleted during close,
2368 // as a result of delivering the close event.
2369 QPointer guard(this);
2370 d->inClose = true;
2371 bool success = d->platformWindow->close();
2372 if (guard)
2373 d->inClose = false;
2374
2375 return success;
2376}
2377
2379{
2380 Q_Q(const QWindow);
2381
2382 if (!q->isTopLevel())
2383 return false;
2384
2385 // Tool-tip widgets do not normally have Qt::WA_QuitOnClose,
2386 // but since we do not have a similar flag for non-widget
2387 // windows we need an explicit exclusion here as well.
2388 if (q->type() == Qt::ToolTip)
2389 return false;
2390
2391 // A window with a transient parent is not a primary window,
2392 // it's a secondary window.
2393 if (q->transientParent())
2394 return false;
2395
2396 return true;
2397}
2398
2400{
2401 Q_Q(const QWindow);
2402 return q->isVisible();
2403}
2404
2424{
2425 ev->ignore();
2426}
2427
2443{
2444 ev->ignore();
2445}
2446
2451{
2452 ev->ignore();
2453}
2454
2463{
2464 ev->ignore();
2465}
2466
2476{
2477 ev->ignore();
2478}
2479
2487{
2488 ev->ignore();
2489}
2490
2500{
2501 Q_UNUSED(ev);
2502}
2503
2512{
2513 switch (ev->type()) {
2514 case QEvent::MouseMove:
2515 mouseMoveEvent(static_cast<QMouseEvent*>(ev));
2516 break;
2517
2519 mousePressEvent(static_cast<QMouseEvent*>(ev));
2520 break;
2521
2523 mouseReleaseEvent(static_cast<QMouseEvent*>(ev));
2524 break;
2525
2527 mouseDoubleClickEvent(static_cast<QMouseEvent*>(ev));
2528 break;
2529
2530 case QEvent::TouchBegin:
2532 case QEvent::TouchEnd:
2534 touchEvent(static_cast<QTouchEvent *>(ev));
2535 break;
2536
2537 case QEvent::Move:
2538 moveEvent(static_cast<QMoveEvent*>(ev));
2539 break;
2540
2541 case QEvent::Resize:
2542 resizeEvent(static_cast<QResizeEvent*>(ev));
2543 break;
2544
2545 case QEvent::KeyPress:
2546 keyPressEvent(static_cast<QKeyEvent *>(ev));
2547 break;
2548
2549 case QEvent::KeyRelease:
2550 keyReleaseEvent(static_cast<QKeyEvent *>(ev));
2551 break;
2552
2553 case QEvent::FocusIn: {
2554 focusInEvent(static_cast<QFocusEvent *>(ev));
2555#if QT_CONFIG(accessibility)
2557 state.active = true;
2558 QAccessibleStateChangeEvent event(this, state);
2559 QAccessible::updateAccessibility(&event);
2560#endif
2561 break; }
2562
2563 case QEvent::FocusOut: {
2564 focusOutEvent(static_cast<QFocusEvent *>(ev));
2565#if QT_CONFIG(accessibility)
2567 state.active = true;
2568 QAccessibleStateChangeEvent event(this, state);
2569 QAccessible::updateAccessibility(&event);
2570#endif
2571 break; }
2572
2573#if QT_CONFIG(wheelevent)
2574 case QEvent::Wheel:
2575 wheelEvent(static_cast<QWheelEvent*>(ev));
2576 break;
2577#endif
2578
2579 case QEvent::Close: {
2580
2581 Q_D(QWindow);
2582 const bool wasVisible = d->treatAsVisible();
2583 const bool participatesInLastWindowClosed = d->participatesInLastWindowClosed();
2584
2585 // The window might be deleted in the close event handler
2586 QPointer<QWindow> deletionGuard(this);
2587 closeEvent(static_cast<QCloseEvent*>(ev));
2588
2589 if (ev->isAccepted()) {
2590 if (deletionGuard)
2591 destroy();
2592 if (wasVisible && participatesInLastWindowClosed)
2593 QGuiApplicationPrivate::instance()->maybeLastWindowClosed();
2594 }
2595
2596 break;
2597 }
2598
2599 case QEvent::Expose:
2600 exposeEvent(static_cast<QExposeEvent *>(ev));
2601 break;
2602
2603 case QEvent::Paint:
2604 paintEvent(static_cast<QPaintEvent *>(ev));
2605 break;
2606
2607 case QEvent::Show:
2608 showEvent(static_cast<QShowEvent *>(ev));
2609 break;
2610
2611 case QEvent::Hide:
2612 hideEvent(static_cast<QHideEvent *>(ev));
2613 break;
2614
2616 setIcon(icon());
2617 break;
2618
2619#if QT_CONFIG(tabletevent)
2621 case QEvent::TabletMove:
2623 tabletEvent(static_cast<QTabletEvent *>(ev));
2624 break;
2625#endif
2626
2628 if ((static_cast<QPlatformSurfaceEvent *>(ev))->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) {
2629#ifndef QT_NO_OPENGL
2631 if (context && context->surface() == static_cast<QSurface *>(this))
2632 context->doneCurrent();
2633#endif
2634 }
2635 break;
2636 }
2637
2638 default:
2639 return QObject::event(ev);
2640 }
2641
2642#ifndef QT_NO_CONTEXTMENU
2643 /*
2644 QGuiApplicationPrivate::processContextMenuEvent blocks mouse-triggered
2645 context menu events that the QPA plugin might generate. In practice that
2646 never happens, as even on Windows WM_CONTEXTMENU is never generated by
2647 the OS (we never call the default window procedure that would do that in
2648 response to unhandled WM_RBUTTONUP).
2649
2650 So, we always have to syntheize QContextMenuEvent for mouse events anyway.
2651 QWidgetWindow synthesizes QContextMenuEvent similar to this code, and
2652 never calls QWindow::event, so we have to do it here as well.
2653
2654 This logic could be simplified by always synthesizing events in
2655 QGuiApplicationPrivate, or perhaps even in each QPA plugin. See QTBUG-93486.
2656 */
2657 auto asMouseEvent = [](QEvent *ev) {
2658 const auto t = ev->type();
2660 ? static_cast<QMouseEvent *>(ev) : nullptr ;
2661 };
2662 if (QMouseEvent *me = asMouseEvent(ev);
2664 && me->button() == Qt::RightButton) {
2665 QContextMenuEvent e(QContextMenuEvent::Mouse, me->position().toPoint(),
2666 me->globalPosition().toPoint(), me->modifiers());
2668 }
2669#endif
2670 return true;
2671}
2672
2700void QWindow::requestUpdate()
2701{
2703 "QWindow", "Updates can only be scheduled from the GUI (main) thread");
2704
2705 Q_D(QWindow);
2706 if (d->updateRequestPending || !d->platformWindow)
2707 return;
2708 d->updateRequestPending = true;
2709 d->platformWindow->requestUpdate();
2710}
2711
2718{
2719 ev->ignore();
2720}
2721
2728{
2729 ev->ignore();
2730}
2731
2740{
2741 ev->ignore();
2742}
2743
2752{
2753 ev->ignore();
2754}
2755
2762{
2763 ev->ignore();
2764}
2765
2772{
2773 ev->ignore();
2774}
2775
2782{
2783 ev->ignore();
2784}
2785
2790{
2791 ev->ignore();
2792}
2793
2794#if QT_CONFIG(wheelevent)
2798void QWindow::wheelEvent(QWheelEvent *ev)
2799{
2800 ev->ignore();
2801}
2802#endif // QT_CONFIG(wheelevent)
2803
2808{
2809 ev->ignore();
2810}
2811
2812#if QT_CONFIG(tabletevent)
2819void QWindow::tabletEvent(QTabletEvent *ev)
2820{
2821 ev->ignore();
2822}
2823#endif
2824
2835{
2836 Q_UNUSED(eventType);
2839 return false;
2840}
2841
2852QPointF QWindow::mapToGlobal(const QPointF &pos) const
2853{
2854 Q_D(const QWindow);
2855 // QTBUG-43252, prefer platform implementation for foreign windows.
2856 if (d->platformWindow
2857 && (d->platformWindow->isForeignWindow() || d->platformWindow->isEmbedded())) {
2858 return QHighDpi::fromNativeGlobalPosition(d->platformWindow->mapToGlobalF(QHighDpi::toNativeLocalPosition(pos, this)), this);
2859 }
2860
2862 return pos + d->globalPosition();
2863
2864 // The normal pos + windowGlobalPos calculation may give a point which is outside
2865 // screen geometry for windows which span multiple screens, due to the way QHighDpiScaling
2866 // creates gaps between screens in the the device indendent cooordinate system.
2867 //
2868 // Map the position (and the window's global position) to native coordinates, perform
2869 // the addition, and then map back to device independent coordinates.
2870 QPointF nativeLocalPos = QHighDpi::toNativeLocalPosition(pos, this);
2871 // Get the native window position directly from the platform window
2872 // if available (it can be null if the window hasn't been shown yet),
2873 // or fall back to scaling the QWindow position.
2874 QPointF nativeWindowGlobalPos = d->platformWindow
2875 ? d->platformWindow->mapToGlobal(QPoint(0,0)).toPointF()
2876 : QHighDpi::toNativeGlobalPosition(QPointF(d->globalPosition()), this);
2877 QPointF nativeGlobalPos = nativeLocalPos + nativeWindowGlobalPos;
2878 QPointF deviceIndependentGlobalPos = QHighDpi::fromNativeGlobalPosition(nativeGlobalPos, this);
2879 return deviceIndependentGlobalPos;
2880}
2881
2885QPoint QWindow::mapToGlobal(const QPoint &pos) const
2886{
2887 return mapToGlobal(QPointF(pos)).toPoint();
2888}
2889
2899QPointF QWindow::mapFromGlobal(const QPointF &pos) const
2900{
2901 Q_D(const QWindow);
2902 // QTBUG-43252, prefer platform implementation for foreign windows.
2903 if (d->platformWindow
2904 && (d->platformWindow->isForeignWindow() || d->platformWindow->isEmbedded())) {
2905 return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapFromGlobalF(QHighDpi::toNativeGlobalPosition(pos, this)), this);
2906 }
2907
2909 return pos - d->globalPosition();
2910
2911 // Calculate local position in the native coordinate system. (See comment for the
2912 // corresponding mapToGlobal() code above).
2913 QPointF nativeGlobalPos = QHighDpi::toNativeGlobalPosition(pos, this);
2914 // Get the native window position directly from the platform window
2915 // if available (it can be null if the window hasn't been shown yet),
2916 // or fall back to scaling the QWindow position.
2917 QPointF nativeWindowGlobalPos = d->platformWindow
2918 ? d->platformWindow->mapToGlobal(QPoint(0,0)).toPointF()
2919 : QHighDpi::toNativeGlobalPosition(QPointF(d->globalPosition()), this);
2920 QPointF nativeLocalPos = nativeGlobalPos - nativeWindowGlobalPos;
2921 QPointF deviceIndependentLocalPos = QHighDpi::fromNativeLocalPosition(nativeLocalPos, this);
2922 return deviceIndependentLocalPos;
2923}
2924
2928QPoint QWindow::mapFromGlobal(const QPoint &pos) const
2929{
2930 return QWindow::mapFromGlobal(QPointF(pos)).toPoint();
2931}
2932
2934{
2935 Q_Q(const QWindow);
2936 QPoint offset = q->position();
2937 for (const QWindow *p = q->parent(); p; p = p->parent()) {
2938 QPlatformWindow *pw = p->handle();
2939 if (pw && (pw->isForeignWindow() || pw->isEmbedded())) {
2940 // Use mapToGlobal() for foreign windows
2941 offset += p->mapToGlobal(QPoint(0, 0));
2942 break;
2943 } else {
2944 offset += p->position();
2945 }
2946 }
2947 return offset;
2948}
2949
2951{
2952 return window->d_func();
2953}
2954
2955QWindow *QWindowPrivate::topLevelWindow(QWindow::AncestorMode mode) const
2956{
2957 Q_Q(const QWindow);
2958
2959 QWindow *window = const_cast<QWindow *>(q);
2960
2961 while (window) {
2962 QWindow *parent = window->parent(mode);
2963 if (!parent)
2964 break;
2965
2966 window = parent;
2967 }
2968
2969 return window;
2970}
2971
2993QWindow *QWindow::fromWinId(WId id)
2994{
2996 qWarning("QWindow::fromWinId(): platform plugin does not support foreign windows.");
2997 return nullptr;
2998 }
2999
3000 QWindow *window = new QWindow;
3001
3002 // Persist the winId in a private property so that we
3003 // can recreate the window after being destroyed.
3004 window->setProperty(kForeignWindowId, id);
3005 window->create();
3006
3007 if (!window->handle()) {
3008 delete window;
3009 return nullptr;
3010 }
3011
3012 return window;
3013}
3014
3026void QWindow::alert(int msec)
3027{
3028 Q_D(QWindow);
3029 if (!d->platformWindow || d->platformWindow->isAlertState() || isActive())
3030 return;
3031 d->platformWindow->setAlertState(true);
3032 if (d->platformWindow->isAlertState() && msec)
3033 QTimer::singleShot(msec, this, SLOT(_q_clearAlert()));
3034}
3035
3041
3042#ifndef QT_NO_CURSOR
3063void QWindow::setCursor(const QCursor &cursor)
3064{
3065 Q_D(QWindow);
3066 d->setCursor(&cursor);
3067}
3068
3072void QWindow::unsetCursor()
3073{
3074 Q_D(QWindow);
3075 d->setCursor(nullptr);
3076}
3077
3083QCursor QWindow::cursor() const
3084{
3085 Q_D(const QWindow);
3086 return d->cursor;
3087}
3088
3090{
3091
3092 Q_Q(QWindow);
3093 if (newCursor) {
3094 const Qt::CursorShape newShape = newCursor->shape();
3095 if (newShape <= Qt::LastCursor && hasCursor && newShape == cursor.shape())
3096 return; // Unchanged and no bitmap/custom cursor.
3097 cursor = *newCursor;
3098 hasCursor = true;
3099 } else {
3100 if (!hasCursor)
3101 return;
3103 hasCursor = false;
3104 }
3105 // Only attempt to emit signal if there is an actual platform cursor
3106 if (applyCursor()) {
3109 }
3110}
3111
3112// Apply the cursor and returns true iff the platform cursor exists
3114{
3115 Q_Q(QWindow);
3116 if (QScreen *screen = q->screen()) {
3117 if (QPlatformCursor *platformCursor = screen->handle()->cursor()) {
3118 if (!platformWindow)
3119 return true;
3121 if (c != nullptr && platformCursor->capabilities().testFlag(QPlatformCursor::OverrideCursor))
3122 return true;
3123 if (!c && hasCursor)
3124 c = &cursor;
3125 platformCursor->changeCursor(c, q);
3126 return true;
3127 }
3128 }
3129 return false;
3130}
3131#endif // QT_NO_CURSOR
3132
3133void *QWindow::resolveInterface(const char *name, int revision) const
3134{
3135 using namespace QNativeInterface::Private;
3136
3137 auto *platformWindow = handle();
3138 Q_UNUSED(platformWindow);
3139 Q_UNUSED(name);
3140 Q_UNUSED(revision);
3141
3142#if defined(Q_OS_WIN)
3144#endif
3145
3146#if QT_CONFIG(xcb)
3148#endif
3149
3150#if defined(Q_OS_MACOS)
3152#endif
3153
3154#if QT_CONFIG(wayland)
3155 QT_NATIVE_INTERFACE_RETURN_IF(QWaylandWindow, platformWindow);
3156#endif
3157
3158#if defined(Q_OS_WASM)
3160#endif
3161
3162 return nullptr;
3163}
3164
3165#ifndef QT_NO_DEBUG_STREAM
3167{
3168 QDebugStateSaver saver(debug);
3169 debug.nospace();
3170 if (window) {
3171 debug << window->metaObject()->className() << '(' << (const void *)window;
3172 if (!window->objectName().isEmpty())
3173 debug << ", name=" << window->objectName();
3174 if (debug.verbosity() > 2) {
3175 const QRect geometry = window->geometry();
3176 if (window->isVisible())
3177 debug << ", visible";
3178 if (window->isExposed())
3179 debug << ", exposed";
3180 debug << ", state=" << window->windowState()
3181 << ", type=" << window->type() << ", flags=" << window->flags()
3182 << ", surface type=" << window->surfaceType();
3183 if (window->isTopLevel())
3184 debug << ", toplevel";
3185 debug << ", " << geometry.width() << 'x' << geometry.height()
3186 << Qt::forcesign << geometry.x() << geometry.y() << Qt::noforcesign;
3187 const QMargins margins = window->frameMargins();
3188 if (!margins.isNull())
3189 debug << ", margins=" << margins;
3190 debug << ", devicePixelRatio=" << window->devicePixelRatio();
3191 if (const QPlatformWindow *platformWindow = window->handle())
3192 debug << ", winId=0x" << Qt::hex << platformWindow->winId() << Qt::dec;
3193 if (const QScreen *screen = window->screen())
3194 debug << ", on " << screen->name();
3195 }
3196 debug << ')';
3197 } else {
3198 debug << "QWindow(0x0)";
3199 }
3200 return debug;
3201}
3202#endif // !QT_NO_DEBUG_STREAM
3203
3204#if QT_CONFIG(vulkan) || defined(Q_QDOC)
3205
3211void QWindow::setVulkanInstance(QVulkanInstance *instance)
3212{
3213 Q_D(QWindow);
3214 d->vulkanInstance = instance;
3215}
3216
3220QVulkanInstance *QWindow::vulkanInstance() const
3221{
3222 Q_D(const QWindow);
3223 return d->vulkanInstance;
3224}
3225
3226#endif // QT_CONFIG(vulkan)
3227
3229
3230#include "moc_qwindow.cpp"
\inmodule QtGui
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtGui
Definition qevent.h:1025
The QCloseEvent class contains parameters that describe a close event.
Definition qevent.h:562
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition qevent.h:594
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static void removePostedEvents(QObject *receiver, int eventType=0)
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition qcursor.h:45
Qt::CursorShape shape() const
Returns the cursor shape identifier.
Definition qcursor.cpp:498
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qcoreevent.h:45
@ ParentWindowAboutToChange
Definition qcoreevent.h:291
@ TabletMove
Definition qcoreevent.h:121
@ DevicePixelRatioChange
Definition qcoreevent.h:287
@ ApplicationWindowIconChange
Definition qcoreevent.h:90
@ FocusOut
Definition qcoreevent.h:67
@ ParentWindowChange
Definition qcoreevent.h:292
@ ChildWindowRemoved
Definition qcoreevent.h:290
@ CursorChange
Definition qcoreevent.h:228
@ KeyRelease
Definition qcoreevent.h:65
@ MouseMove
Definition qcoreevent.h:63
@ KeyPress
Definition qcoreevent.h:64
@ FocusIn
Definition qcoreevent.h:66
@ TouchCancel
Definition qcoreevent.h:264
@ MouseButtonPress
Definition qcoreevent.h:60
@ TouchUpdate
Definition qcoreevent.h:242
@ TouchBegin
Definition qcoreevent.h:241
@ TabletRelease
Definition qcoreevent.h:127
@ WindowIconChange
Definition qcoreevent.h:89
@ PlatformSurface
Definition qcoreevent.h:278
@ ChildWindowAdded
Definition qcoreevent.h:289
@ TabletPress
Definition qcoreevent.h:126
@ MouseButtonDblClick
Definition qcoreevent.h:62
@ MouseButtonRelease
Definition qcoreevent.h:61
Type type() const
Returns the event type.
Definition qcoreevent.h:304
The QExposeEvent class contains event parameters for expose events. \inmodule QtGui.
Definition qevent.h:515
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
static void updateBlockedStatus(QWindow *window)
static QWindow * currentMousePressWindow
static void showModalWindow(QWindow *window)
static void hideModalWindow(QWindow *window)
static QPlatformIntegration * platformIntegration()
static QWindowList window_list
static QList< TabletPointData > tabletDevicePoints
static QEvent::Type contextMenuEventType()
static QGuiApplicationPrivate * instance()
static QWindow * currentMouseWindow
static QWindow * focus_window
static void applyWindowGeometrySpecificationTo(QWindow *window)
static QWindow * modalWindow()
Returns the most recently shown modal window.
QScreen * primaryScreen
the primary (or default) screen of the application.
static QCursor * overrideCursor()
Returns the active application override cursor.
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
QIcon windowIcon
the default window icon
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition qevent.h:586
static bool isActive()
static qreal factor(C *context)
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
The QKeyEvent class describes a key event.
Definition qevent.h:424
qsizetype size() const noexcept
Definition qlist.h:397
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
\inmodule QtCore
Definition qmargins.h:24
constexpr bool isNull() const noexcept
Returns true if all margins are is 0; otherwise returns false.
Definition qmargins.h:103
constexpr int left() const noexcept
Returns the left margin.
Definition qmargins.h:106
constexpr int top() const noexcept
Returns the top margin.
Definition qmargins.h:109
\inmodule QtGui
Definition qevent.h:196
The QMoveEvent class contains event parameters for move events.
Definition qevent.h:502
uint isWindow
Definition qobject.h:82
QObject * parent
Definition qobject.h:73
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition qobject.cpp:1389
void setParent(QObject *parent)
Makes the object a child of parent.
Definition qobject.cpp:2195
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1598
\inmodule QtGui
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
The QPlatformCursor class provides information about pointer device events (movement,...
The QPlatformIntegration class is the entry for WindowSystem specific functionality.
virtual QPlatformCursor * cursor() const
Reimplement this function in subclass to return the cursor of the screen.
The QPlatformSurfaceEvent class is used to notify about native platform surface events....
Definition qevent.h:531
The QPlatformSurface class provides an abstraction for a surface.
The QPlatformWindow class provides an abstraction for top-level windows.
virtual bool isAlertState() const
Reimplement this method return whether the window is in an alert state.
virtual void setVisible(bool visible)
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
virtual void initialize()
Called as part of QWindow::create(), after constructing the window.
virtual void setParent(const QPlatformWindow *window)
This function is called to enable native child window in QPA.
virtual void propagateSizeHints()
Reimplement to propagate the size hints of the QWindow.
virtual void setAlertState(bool enabled)
Reimplement this method to set whether the window demands attention (for example, by flashing the tas...
virtual qreal devicePixelRatio() const
Reimplement this function in subclass to return the device pixel ratio for the window.
virtual QPoint mapToGlobal(const QPoint &pos) const
Translates the window coordinate pos to global screen coordinates using native methods.
\inmodule QtCore\reentrant
Definition qpoint.h:217
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition qpoint.h:404
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
bool intersects(const QRect &r) const noexcept
Returns true if this rectangle intersects with the given rectangle (i.e., there is at least one pixel...
Definition qrect.cpp:1069
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:239
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrect.cpp:855
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:185
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:188
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
Definition qrect.h:233
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
QRect geometry
the screen's geometry in pixels
Definition qscreen.h:45
QString name
a user presentable string representing the screen
Definition qscreen.h:36
QPlatformScreen * handle() const
Get the platform screen handle.
Definition qscreen.cpp:83
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:578
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
constexpr QSize expandedTo(const QSize &) const noexcept
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition qsize.h:192
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
static QSurfaceFormat defaultFormat()
Returns the global default surface format.
\inmodule QtGui
Definition qsurface.h:21
virtual QPlatformSurface * surfaceHandle() const =0
Returns a handle to the platform-specific implementation of the surface.
SurfaceType
The SurfaceType enum describes what type of surface this is.
Definition qsurface.h:30
static QThread * currentThread()
Definition qthread.cpp:1039
bool singleShot
whether the timer is a single-shot timer
Definition qtimer.h:22
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
bool windowRecreationRequired(QScreen *newScreen) const
Definition qwindow.cpp:473
QWindow * topLevelWindow(QWindow::AncestorMode mode=QWindow::IncludeTransients) const
Definition qwindow.cpp:2955
QPointer< QScreen > topLevelScreen
Definition qwindow_p.h:151
void disconnectFromScreen()
Definition qwindow.cpp:481
QScreen * screenForGeometry(const QRect &rect) const
Definition qwindow.cpp:1848
bool visibilityOnDestroy
Definition qwindow_p.h:115
virtual void clearFocusObject()
Definition qwindow.cpp:597
QPlatformWindow * platformWindow
Definition qwindow_p.h:113
virtual void setVisible(bool visible)
Definition qwindow.cpp:343
void emitScreenChangedRecursion(QScreen *newScreen)
Definition qwindow.cpp:493
void updateVisibility()
Definition qwindow.cpp:428
bool updateRequestPending
Definition qwindow_p.h:147
~QWindowPrivate() override
QPoint globalPosition() const
Definition qwindow.cpp:2933
QCursor cursor
Definition qwindow_p.h:154
bool applyCursor()
Definition qwindow.cpp:3113
void _q_clearAlert()
Definition qwindow.cpp:3036
void updateSiblingPosition(SiblingPosition)
Definition qwindow.cpp:449
void setCursor(const QCursor *c=nullptr)
Definition qwindow.cpp:3089
void setTopLevelScreen(QScreen *newScreen, bool recreate)
Definition qwindow.cpp:503
QWindow::Visibility visibility
Definition qwindow_p.h:125
QWindow * parentWindow
Definition qwindow_p.h:112
bool receivedExpose
Definition qwindow_p.h:127
bool updateDevicePixelRatio()
Definition qwindow.cpp:1400
void setMinOrMaxSize(QSize *oldSizeMember, const QSize &size, qxp::function_ref< void()> funcWidthChanged, qxp::function_ref< void()> funcHeightChanged)
Definition qwindow.cpp:610
void init(QWindow *parent, QScreen *targetScreen=nullptr)
Definition qwindow.cpp:211
bool resizeEventPending
Definition qwindow_p.h:126
QSize minimumSize
Definition qwindow_p.h:139
void connectToScreen(QScreen *topLevelScreen)
Definition qwindow.cpp:487
Qt::WindowStates windowState
Definition qwindow_p.h:124
bool transientParentPropertySet
Definition qwindow_p.h:148
virtual QRectF closestAcceptableGeometry(const QRectF &rect) const
Definition qwindow.cpp:604
static Qt::WindowState effectiveState(Qt::WindowStates)
Definition qwindow.cpp:1419
virtual bool treatAsVisible() const
Definition qwindow.cpp:2399
QSize maximumSize
Definition qwindow_p.h:140
QSurfaceFormat requestedFormat
Definition qwindow_p.h:118
qreal devicePixelRatio
Definition qwindow_p.h:123
virtual bool participatesInLastWindowClosed() const
Definition qwindow.cpp:2378
void setTransientParent(QWindow *parent)
Definition qwindow.cpp:1561
void create(bool recursive)
Definition qwindow.cpp:526
\inmodule QtGui
Definition qwindow.h:63
void showNormal()
Shows the window as normal, i.e.
Definition qwindow.cpp:2339
int minimumHeight
the minimum height of the window's geometry
Definition qwindow.h:86
virtual QAccessibleInterface * accessibleRoot() const
Returns the accessibility interface for the object that the window represents.
Definition qwindow.cpp:2222
virtual void moveEvent(QMoveEvent *)
Override this to handle window move events (ev).
Definition qwindow.cpp:2450
int x
the x position of the window's geometry
Definition qwindow.h:80
void windowStateChanged(Qt::WindowState windowState)
This signal is emitted when the windowState changes, either by being set explicitly with setWindowSta...
void heightChanged(int arg)
int maximumWidth
the maximum width of the window's geometry
Definition qwindow.h:87
void showFullScreen()
Shows the window as fullscreen.
Definition qwindow.cpp:2321
virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result)
Override this to handle platform dependent events.
Definition qwindow.cpp:2834
void setWidth(int arg)
Definition qwindow.cpp:1687
int width
the width of the window's geometry
Definition qwindow.h:82
bool startSystemMove()
Start a system-specific move operation.
Definition qwindow.cpp:1196
void showMinimized()
Shows the window as minimized.
Definition qwindow.cpp:2290
void modalityChanged(Qt::WindowModality modality)
This signal is emitted when the Qwindow::modality property changes to modality.
void xChanged(int arg)
virtual void closeEvent(QCloseEvent *)
Override this to handle close events (ev).
Definition qwindow.cpp:2499
void show()
Shows the window.
Definition qwindow.cpp:2254
void setMaximumHeight(int h)
Definition qwindow.cpp:1747
virtual void mousePressEvent(QMouseEvent *)
Override this to handle mouse press events (ev).
Definition qwindow.cpp:2761
void hide()
Hides the window.
Definition qwindow.cpp:2277
void setMinimumHeight(int h)
Definition qwindow.cpp:1714
virtual void focusInEvent(QFocusEvent *)
Override this to handle focus in events (ev).
Definition qwindow.cpp:2739
Qt::WindowFlags flags
the window flags of the window
Definition qwindow.h:79
void contentOrientationChanged(Qt::ScreenOrientation orientation)
virtual void keyPressEvent(QKeyEvent *)
Override this to handle key press events (ev).
Definition qwindow.cpp:2717
QSurfaceFormat format() const override
Returns the actual format of this window.
Definition qwindow.cpp:946
virtual void mouseMoveEvent(QMouseEvent *)
Override this to handle mouse move events (ev).
Definition qwindow.cpp:2789
SurfaceType surfaceType() const override
Returns the surface type of the window.
Definition qwindow.cpp:665
Qt::ScreenOrientation contentOrientation
the orientation of the window's contents
Definition qwindow.h:95
void setX(int arg)
Definition qwindow.cpp:1661
void setTitle(const QString &)
Definition qwindow.cpp:1030
bool visible
whether the window is visible or not
Definition qwindow.h:90
void raise()
Raise the window in the windowing system.
Definition qwindow.cpp:1115
virtual void exposeEvent(QExposeEvent *)
The expose event (ev) is sent by the window system when a window moves between the un-exposed and exp...
Definition qwindow.cpp:2423
int maximumHeight
the maximum height of the window's geometry
Definition qwindow.h:89
void setMaximumWidth(int w)
Definition qwindow.cpp:1738
void showMaximized()
Shows the window as maximized.
Definition qwindow.cpp:2304
void setMinimumWidth(int w)
Definition qwindow.cpp:1705
QSize size() const override
Returns the size of the window excluding any window frame.
Definition qwindow.h:210
virtual bool event(QEvent *) override
Override this to handle any event (ev) sent to the window.
Definition qwindow.cpp:2511
virtual void mouseReleaseEvent(QMouseEvent *)
Override this to handle mouse release events (ev).
Definition qwindow.cpp:2771
void yChanged(int arg)
int y
the y position of the window's geometry
Definition qwindow.h:81
void setGeometry(int posx, int posy, int w, int h)
Sets the geometry of the window, excluding its window frame, to a rectangle constructed from posx,...
Definition qwindow.cpp:1802
int minimumWidth
the minimum width of the window's geometry
Definition qwindow.h:84
virtual QObject * focusObject() const
Returns the QObject that will be the final receiver of events tied focus, such as key events.
Definition qwindow.cpp:2240
void setY(int arg)
Definition qwindow.cpp:1674
virtual void hideEvent(QHideEvent *)
Override this to handle hide events (ev).
Definition qwindow.cpp:2486
virtual void mouseDoubleClickEvent(QMouseEvent *)
Override this to handle mouse double click events (ev).
Definition qwindow.cpp:2781
bool close()
Close the window.
Definition qwindow.cpp:2354
void setHeight(int arg)
Definition qwindow.cpp:1696
virtual void keyReleaseEvent(QKeyEvent *)
Override this to handle key release events (ev).
Definition qwindow.cpp:2727
QString title
the window's title in the windowing system
Definition qwindow.h:77
Visibility visibility
the screen-occupation state of the window
Definition qwindow.h:93
bool startSystemResize(Qt::Edges edges)
Start a system-specific resize operation.
Definition qwindow.cpp:1158
virtual void touchEvent(QTouchEvent *)
Override this to handle touch events (ev).
Definition qwindow.cpp:2807
virtual void paintEvent(QPaintEvent *)
The paint event (ev) is sent by the window system whenever an area of the window needs a repaint,...
Definition qwindow.cpp:2442
virtual void resizeEvent(QResizeEvent *)
Override this to handle resize events (ev).
Definition qwindow.cpp:2462
virtual void focusOutEvent(QFocusEvent *)
Override this to handle focus out events (ev).
Definition qwindow.cpp:2751
void widthChanged(int arg)
void screenChanged(QScreen *screen)
This signal is emitted when a window's screen changes, either by being set explicitly with setScreen(...
virtual void showEvent(QShowEvent *)
Override this to handle show events (ev).
Definition qwindow.cpp:2475
Qt::WindowModality modality
the modality of the window
Definition qwindow.h:78
void setVisible(bool visible)
Definition qwindow.cpp:689
int height
the height of the window's geometry
Definition qwindow.h:83
void lower()
Lower the window in the windowing system.
Definition qwindow.cpp:1130
qreal opacity
The opacity of the window in the windowing system.
Definition qwindow.h:96
Raster or OpenGL Window.
[Window class with invokable method]
Definition window.h:11
#define this
Definition dialogs.cpp:9
bool focus
[0]
QCursor cursor
rect
[4]
else opt state
[0]
T toNativeLocalPosition(const T &value, const C *context)
T toNativeGlobalPosition(const T &value, const C *context)
T fromNativeLocalPosition(const T &value, const C *context)
T fromNativeGlobalPosition(const T &value, const C *context)
T fromNativePixels(const T &value, const C *context)
QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *window)
T toNativeWindowGeometry(const T &value, const C *context)
T fromNativeWindowGeometry(const T &value, const C *context)
Combined button and popup list for selecting options.
Definition qcompare.h:63
WindowState
Definition qnamespace.h:251
@ WindowFullScreen
Definition qnamespace.h:255
@ WindowNoState
Definition qnamespace.h:252
@ WindowMinimized
Definition qnamespace.h:253
@ WindowMaximized
Definition qnamespace.h:254
@ WindowActive
Definition qnamespace.h:256
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
@ RightButton
Definition qnamespace.h:59
WindowModality
@ NonModal
QTextStream & noforcesign(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ForceSign) on stream and...
ScreenOrientation
Definition qnamespace.h:271
CursorShape
@ LastCursor
@ ArrowCursor
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
@ RightEdge
@ TopEdge
@ BottomEdge
@ LeftEdge
QTextStream & forcesign(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ForceSign) on stream and ...
WindowType
Definition qnamespace.h:205
@ Desktop
Definition qnamespace.h:215
@ WindowDoesNotAcceptFocus
Definition qnamespace.h:236
@ ForeignWindow
Definition qnamespace.h:217
@ ToolTip
Definition qnamespace.h:213
@ WindowType_Mask
Definition qnamespace.h:220
@ Window
Definition qnamespace.h:207
static void * context
#define Q_UNLIKELY(x)
#define qApp
#define qWarning
Definition qlogging.h:166
#define qFatal
Definition qlogging.h:168
#define QT_NATIVE_INTERFACE_RETURN_IF(NativeInterface, baseType)
#define SLOT(a)
Definition qobjectdefs.h:52
n void setPosition(void) \n\
GLsizei const GLfloat * v
[13]
GLuint64 GLenum void * handle
GLenum mode
const GLfloat * m
GLenum GLuint GLint level
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint object
[3]
GLenum type
GLenum target
GLbitfield flags
GLuint GLsizei const GLchar * message
GLenum GLuint GLintptr offset
GLuint name
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
const GLubyte * c
GLdouble GLdouble t
Definition qopenglext.h:243
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
#define QWINDOWSIZE_MAX
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_ASSERT_X(cond, x, msg)
Definition qrandom.cpp:48
SSL_CTX int void * arg
QScreen * screen
[1]
Definition main.cpp:29
#define QT_CONFIG(feature)
#define emit
#define Q_UNUSED(x)
ptrdiff_t qsizetype
Definition qtypes.h:165
double qreal
Definition qtypes.h:187
ptrdiff_t qintptr
Definition qtypes.h:166
Q_GUI_EXPORT QWindowPrivate * qt_window_private(QWindow *window)
Definition qwindow.cpp:2950
static constexpr auto kForeignWindowId
Definition qwindow.cpp:524
QDebug operator<<(QDebug debug, const QWindow *window)
Definition qwindow.cpp:3166
static QWindow * nonDesktopParent(QWindow *parent)
Definition qwindow.cpp:134
QObject::connect nullptr
QString title
[35]
QLayoutItem * child
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QAction * at
view create()