4801void QWidgetPrivate::updateFont(
const QFont &font)
4804#if QT_CONFIG(style_stylesheet)
4805 const QStyleSheetStyle* cssStyle;
4806 cssStyle = extra ? qt_styleSheet(extra->style) :
nullptr;
4807 const bool useStyleSheetPropagationInWidgetStyles =
4808 QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
4811 data.fnt = QFont(font, q);
4814#if QT_CONFIG(graphicsview)
4815 if (!q->parentWidget() && extra && extra->proxyWidget) {
4816 QGraphicsProxyWidget *p = extra->proxyWidget;
4817 inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolveMask();
4820 if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
4821 inheritedFontResolveMask = 0;
4823 uint newMask = data.fnt.resolveMask() | inheritedFontResolveMask;
4827 directFontResolveMask = data.fnt.resolveMask();
4828 data.fnt.setResolveMask(newMask);
4830 for (
int i = 0; i < children.size(); ++i) {
4831 QWidget *w = qobject_cast<QWidget*>(children.at(i));
4834#if QT_CONFIG(style_stylesheet)
4835 }
else if (!useStyleSheetPropagationInWidgetStyles && w->testAttribute(Qt::WA_StyleSheet)) {
4838 cssStyle->updateStyleSheetFont(w);
4840 }
else if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {
4842 QWidgetPrivate *wd = w->d_func();
4843 wd->inheritedFontResolveMask = newMask;
4849#if QT_CONFIG(style_stylesheet)
4850 if (!useStyleSheetPropagationInWidgetStyles && cssStyle) {
4851 cssStyle->updateStyleSheetFont(q);
4855 QEvent e(QEvent::FontChange);
4856 QCoreApplication::sendEvent(q, &e);
5136void QWidget::render(QPainter *painter,
const QPoint &targetOffset,
5137 const QRegion &sourceRegion, RenderFlags renderFlags)
5139 if (Q_UNLIKELY(!painter)) {
5140 qWarning(
"QWidget::render: Null pointer to painter");
5144 if (Q_UNLIKELY(!painter->isActive())) {
5145 qWarning(
"QWidget::render: Cannot render with an inactive painter");
5149 const qreal opacity = painter->opacity();
5150 if (qFuzzyIsNull(opacity))
5154 const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;
5155 const QRegion toBePainted = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)
5157 if (toBePainted.isEmpty())
5162 d->extra->inRenderWithPainter =
true;
5164 QPaintEngine *engine = painter->paintEngine();
5166 QPaintEnginePrivate *enginePriv = engine->d_func();
5167 Q_ASSERT(enginePriv);
5168 QPaintDevice *target = engine->paintDevice();
5172 if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) {
5173 d->render_helper(painter, targetOffset, toBePainted, renderFlags);
5174 d->extra->inRenderWithPainter = inRenderWithPainter;
5179 QPainter *oldPainter = d->sharedPainter();
5180 d->setSharedPainter(painter);
5183 const QTransform oldTransform = enginePriv->systemTransform;
5184 const QRegion oldSystemClip = enginePriv->systemClip;
5185 const QRegion oldBaseClip = enginePriv->baseSystemClip;
5186 const QRegion oldSystemViewport = enginePriv->systemViewport;
5187 const Qt::LayoutDirection oldLayoutDirection = painter->layoutDirection();
5190 if (painter->hasClipping()) {
5191 const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion());
5192 enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip);
5194 enginePriv->setSystemViewport(oldSystemClip);
5196 painter->setLayoutDirection(layoutDirection());
5198 d->render(target, targetOffset, toBePainted, renderFlags);
5201 enginePriv->baseSystemClip = oldBaseClip;
5202 enginePriv->setSystemTransformAndViewport(oldTransform, oldSystemViewport);
5203 enginePriv->systemStateChanged();
5204 painter->setLayoutDirection(oldLayoutDirection);
5207 d->setSharedPainter(oldPainter);
5209 d->extra->inRenderWithPainter = inRenderWithPainter;
5350QRegion QWidgetPrivate::prepareToRender(
const QRegion ®ion, QWidget::RenderFlags renderFlags)
5353 const bool isVisible = q->isVisible();
5356 if (!isVisible && !isAboutToShow()) {
5357 QWidget *topLevel = q->window();
5358 (
void)topLevel->d_func()->topData();
5359 topLevel->ensurePolished();
5363 QWidget *widget = q;
5364 QWidgetList hiddenWidgets;
5366 if (widget->isHidden()) {
5367 widget->setAttribute(Qt::WA_WState_Hidden,
false);
5368 hiddenWidgets.append(widget);
5369 if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
5370 widget->d_func()->updateGeometry_helper(
true);
5372 widget = widget->parentWidget();
5376 if (topLevel->d_func()->layout)
5377 topLevel->d_func()->layout->activate();
5380 QTLWExtra *topLevelExtra = topLevel->d_func()->maybeTopData();
5381 if (topLevelExtra && !topLevelExtra->sizeAdjusted
5382 && !topLevel->testAttribute(Qt::WA_Resized)) {
5383 topLevel->adjustSize();
5384 topLevel->setAttribute(Qt::WA_Resized,
false);
5388 topLevel->d_func()->activateChildLayoutsRecursively();
5391 for (
int i = 0; i < hiddenWidgets.size(); ++i) {
5392 QWidget *widget = hiddenWidgets.at(i);
5393 widget->setAttribute(Qt::WA_WState_Hidden);
5394 if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
5395 widget->parentWidget()->d_func()->layout->invalidate();
5397 }
else if (isVisible) {
5398 q->window()->d_func()->sendPendingMoveAndResizeEvents(
true,
true);
5402 QRegion toBePainted = !region.isEmpty() ? region : QRegion(q->rect());
5403 if (!(renderFlags & QWidget::IgnoreMask) && extra && extra->hasMask)
5404 toBePainted &= extra->mask;
5408void QWidgetPrivate::render_helper(QPainter *painter,
const QPoint &targetOffset,
const QRegion &toBePainted,
5409 QWidget::RenderFlags renderFlags)
5412 Q_ASSERT(!toBePainted.isEmpty());
5415 const QTransform originalTransform = painter->worldTransform();
5416 const bool useDeviceCoordinates = originalTransform.isScaling();
5417 if (!useDeviceCoordinates) {
5419 const QRect rect = toBePainted.boundingRect();
5420 const QSize size = rect.size();
5424 const qreal pixmapDevicePixelRatio = painter->device()->devicePixelRatio();
5425 QPixmap pixmap(size * pixmapDevicePixelRatio);
5426 pixmap.setDevicePixelRatio(pixmapDevicePixelRatio);
5428 if (!(renderFlags & QWidget::DrawWindowBackground) || !isOpaque)
5429 pixmap.fill(Qt::transparent);
5430 q->render(&pixmap, QPoint(), toBePainted, renderFlags);
5432 const bool restore = !(painter->renderHints() & QPainter::SmoothPixmapTransform);
5433 painter->setRenderHints(QPainter::SmoothPixmapTransform,
true);
5435 painter->drawPixmap(targetOffset, pixmap);
5438 painter->setRenderHints(QPainter::SmoothPixmapTransform,
false);
5442 QTransform transform = originalTransform;
5443 transform.translate(targetOffset.x(), targetOffset.y());
5445 QPaintDevice *device = painter->device();
5449 const QRectF rect(toBePainted.boundingRect());
5450 QRect deviceRect = transform.mapRect(QRectF(0, 0, rect.width(), rect.height())).toAlignedRect();
5451 deviceRect &= QRect(0, 0, device->width(), device->height());
5453 QPixmap pixmap(deviceRect.size());
5454 pixmap.fill(Qt::transparent);
5457 QPainter pixmapPainter(&pixmap);
5458 pixmapPainter.setRenderHints(painter->renderHints());
5459 transform *= QTransform::fromTranslate(-deviceRect.x(), -deviceRect.y());
5460 pixmapPainter.setTransform(transform);
5462 q->render(&pixmapPainter, QPoint(), toBePainted, renderFlags);
5463 pixmapPainter.end();
5466 painter->setTransform(QTransform());
5467 painter->drawPixmap(deviceRect.topLeft(), pixmap);
5468 painter->setTransform(originalTransform);
5472void QWidgetPrivate::drawWidget(QPaintDevice *pdev,
const QRegion &rgn,
const QPoint &offset, DrawWidgetFlags flags,
5473 QPainter *sharedPainter, QWidgetRepaintManager *repaintManager)
5480 qCInfo(lcWidgetPainting) <<
"Drawing" << rgn <<
"of" << q <<
"at" << offset
5481 <<
"into paint device" << pdev <<
"with" << flags;
5483 const bool asRoot = flags & DrawAsRoot;
5484 bool onScreen = shouldPaintOnScreen();
5486#if QT_CONFIG(graphicseffect)
5487 if (graphicsEffect && graphicsEffect->isEnabled()) {
5488 QGraphicsEffectSource *source = graphicsEffect->d_func()->source;
5489 QWidgetEffectSourcePrivate *sourced =
static_cast<QWidgetEffectSourcePrivate *>
5491 if (!sourced->context) {
5492 const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
5493 QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
5494 sourced->context = &context;
5495 if (!sharedPainter) {
5496 setSystemClip(pdev->paintEngine(), pdev->devicePixelRatio(), effectRgn.translated(offset));
5498 p.translate(offset);
5499 context.painter = &p;
5500 graphicsEffect->draw(&p);
5501 setSystemClip(pdev->paintEngine(), 1, QRegion());
5503 context.painter = sharedPainter;
5504 if (sharedPainter->worldTransform() != sourced->lastEffectTransform) {
5505 sourced->invalidateCache();
5506 sourced->lastEffectTransform = sharedPainter->worldTransform();
5508 sharedPainter->save();
5509 sharedPainter->translate(offset);
5510 setSystemClip(sharedPainter->paintEngine(), sharedPainter->device()->devicePixelRatio(), effectRgn.translated(offset));
5511 graphicsEffect->draw(sharedPainter);
5512 setSystemClip(sharedPainter->paintEngine(), 1, QRegion());
5513 sharedPainter->restore();
5515 sourced->context =
nullptr;
5518 repaintManager->markNeedsFlush(q, effectRgn, offset);
5524 flags = flags & ~UseEffectRegionBounds;
5526 const bool alsoOnScreen = flags & DrawPaintOnScreen;
5527 const bool recursive = flags & DrawRecursive;
5528 const bool alsoInvisible = flags & DrawInvisible;
5530 Q_ASSERT(sharedPainter ? sharedPainter->isActive() :
true);
5532 QRegion toBePainted(rgn);
5533 if (asRoot && !alsoInvisible)
5534 toBePainted &= clipRect();
5535 if (!(flags & DontSubtractOpaqueChildren))
5536 subtractOpaqueChildren(toBePainted, q->rect());
5538 if (!toBePainted.isEmpty()) {
5539 if (!onScreen || alsoOnScreen) {
5541 if (Q_UNLIKELY(q->testAttribute(Qt::WA_WState_InPaintEvent)))
5542 qWarning(
"QWidget::repaint: Recursive repaint detected");
5543 q->setAttribute(Qt::WA_WState_InPaintEvent);
5546 QPaintEngine *paintEngine = pdev->paintEngine();
5548 setRedirected(pdev, -offset);
5551 setSystemClip(pdev->paintEngine(), pdev->devicePixelRatio(), toBePainted);
5553 paintEngine->d_func()->systemRect = q->data->crect;
5556 if ((asRoot || q->autoFillBackground() || onScreen || q->testAttribute(Qt::WA_StyledBackground))
5557 && !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {
5558 beginBackingStorePainting();
5560 p.setRenderHint(QPainter::SmoothPixmapTransform);
5561 paintBackground(&p, toBePainted, (asRoot || onScreen) ? (flags | DrawAsRoot) : DrawWidgetFlags());
5562 endBackingStorePainting();
5566 setSystemClip(pdev->paintEngine(), pdev->devicePixelRatio(), toBePainted.translated(offset));
5568 if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) {
5569 beginBackingStorePainting();
5571 QColor tint = q->palette().window().color();
5572 tint.setAlphaF(.6f);
5573 p.fillRect(toBePainted.boundingRect(), tint);
5574 endBackingStorePainting();
5579 qDebug() <<
"painting" << q <<
"opaque ==" << isOpaque();
5580 qDebug() <<
"clipping to" << toBePainted <<
"location == " << offset
5581 <<
"geometry ==" << QRect(q->mapTo(q->window(), QPoint(0, 0)), q->size());
5584 bool skipPaintEvent =
false;
5585 if (renderToTexture) {
5588 beginBackingStorePainting();
5589 if (!q->testAttribute(Qt::WA_AlwaysStackOnTop) && repaintManager) {
5591 p.setCompositionMode(QPainter::CompositionMode_Source);
5592 p.fillRect(q->rect(), Qt::transparent);
5593 }
else if (!repaintManager) {
5595 QImage img = grabFramebuffer();
5598 if (img.format() == QImage::Format_RGB32)
5599 img.reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied);
5601 p.drawImage(q->rect(), img);
5602 skipPaintEvent =
true;
5604 endBackingStorePainting();
5605 if (renderToTextureReallyDirty)
5606 renderToTextureReallyDirty = 0;
5608 skipPaintEvent =
true;
5611 if (!skipPaintEvent) {
5613 sendPaintEvent(toBePainted);
5617 repaintManager->markNeedsFlush(q, toBePainted, offset);
5621 restoreRedirected();
5623 paintEngine->d_func()->systemRect = QRect();
5625 paintEngine->d_func()->currentClipDevice =
nullptr;
5627 setSystemClip(pdev->paintEngine(), 1, QRegion());
5629 q->setAttribute(Qt::WA_WState_InPaintEvent,
false);
5630 if (Q_UNLIKELY(q->paintingActive()))
5631 qWarning(
"QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
5633 if (paintEngine && paintEngine->autoDestruct()) {
5636 }
else if (q->isWindow()) {
5637 QPaintEngine *engine = pdev->paintEngine();
5640 p.setClipRegion(toBePainted);
5641 const QBrush bg = q->palette().brush(QPalette::Window);
5642 if (bg.style() == Qt::TexturePattern)
5643 p.drawTiledPixmap(q->rect(), bg.texture());
5645 p.fillRect(q->rect(), bg);
5647 if (engine->autoDestruct())
5653 if (recursive && !children.isEmpty()) {
5654 paintSiblingsRecursive(pdev, children, children.size() - 1, rgn, offset, flags & ~DrawAsRoot,
5655 sharedPainter, repaintManager);
5669void QWidgetPrivate::render(QPaintDevice *target,
const QPoint &targetOffset,
5670 const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
5672 if (Q_UNLIKELY(!target)) {
5673 qWarning(
"QWidget::render: null pointer to paint device");
5677 const bool inRenderWithPainter = extra && extra->inRenderWithPainter;
5678 QRegion paintRegion = !inRenderWithPainter
5679 ? prepareToRender(sourceRegion, renderFlags)
5681 if (paintRegion.isEmpty())
5684 QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() :
nullptr;
5688 if (target->devType() == QInternal::Widget) {
5689 QWidgetPrivate *targetPrivate =
static_cast<QWidget *>(target)->d_func();
5690 if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) {
5691 QPainter *targetPainter = targetPrivate->sharedPainter();
5692 if (targetPainter && targetPainter->isActive())
5693 setSharedPainter(targetPainter);
5700 QPoint offset = targetOffset;
5701 offset -= paintRegion.boundingRect().topLeft();
5702 QPoint redirectionOffset;
5703 QPaintDevice *redirected =
nullptr;
5705 if (target->devType() == QInternal::Widget)
5706 redirected =
static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset);
5709 target = redirected;
5710 offset -= redirectionOffset;
5713 if (!inRenderWithPainter) {
5714 if (QPaintEngine *targetEngine = target->paintEngine()) {
5715 const QRegion targetSystemClip = targetEngine->systemClip();
5716 if (!targetSystemClip.isEmpty())
5717 paintRegion &= targetSystemClip.translated(-offset);
5722 DrawWidgetFlags flags = DrawPaintOnScreen | DrawInvisible;
5723 if (renderFlags & QWidget::DrawWindowBackground)
5724 flags |= DrawAsRoot;
5726 if (renderFlags & QWidget::DrawChildren)
5727 flags |= DrawRecursive;
5729 flags |= DontSubtractOpaqueChildren;
5731 flags |= DontSetCompositionMode;
5734 drawWidget(target, paintRegion, offset, flags, sharedPainter());
5737 if (oldSharedPainter)
5738 setSharedPainter(oldSharedPainter);
5741void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev,
const QObjectList& siblings,
int index,
const QRegion &rgn,
5742 const QPoint &offset, DrawWidgetFlags flags
5743 , QPainter *sharedPainter, QWidgetRepaintManager *repaintManager)
5745 QWidget *w =
nullptr;
5747 bool dirtyBoundingRect =
true;
5748 const bool exludeOpaqueChildren = (flags & DontDrawOpaqueChildren);
5749 const bool excludeNativeChildren = (flags & DontDrawNativeChildren);
5752 QWidget *x = qobject_cast<QWidget*>(siblings.at(index));
5753 if (x && !(exludeOpaqueChildren && x->d_func()->isOpaque) && !x->isHidden() && !x->isWindow()
5754 && !(excludeNativeChildren && x->internalWinId())) {
5755 if (dirtyBoundingRect) {
5756 boundingRect = rgn.boundingRect();
5757 dirtyBoundingRect =
false;
5760 if (qRectIntersects(boundingRect, x->d_func()->effectiveRectFor(x->data->crect))) {
5766 }
while (index >= 0);
5771 QWidgetPrivate *wd = w->d_func();
5772 const QPoint widgetPos(w->data->crect.topLeft());
5773 const bool hasMask = wd->extra && wd->extra->hasMask && !wd->graphicsEffect;
5777 wr -= hasMask ? wd->extra->mask.translated(widgetPos) : w->data->crect;
5778 paintSiblingsRecursive(pdev, siblings, --index, wr, offset, flags,
5779 sharedPainter, repaintManager);
5782 if (w->updatesEnabled()
5783#if QT_CONFIG(graphicsview)
5784 && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget)
5787 QRegion wRegion(rgn);
5788 wRegion &= wd->effectiveRectFor(w->data->crect);
5789 wRegion.translate(-widgetPos);
5791 wRegion &= wd->extra->mask;
5792 wd->drawWidget(pdev, wRegion, offset + widgetPos, flags, sharedPainter, repaintManager);
6544void QWidget::setFocus(Qt::FocusReason reason)
6549 QWidget *f = d_func()->deepestFocusProxy();
6553 if (QApplication::focusWidget() == f)
6556#if QT_CONFIG(graphicsview)
6557 QWidget *previousProxyFocus =
nullptr;
6558 if (
const auto &topData = window()->d_func()->extra) {
6559 if (topData->proxyWidget && topData->proxyWidget->hasFocus()) {
6560 previousProxyFocus = topData->proxyWidget->widget()->focusWidget();
6561 if (previousProxyFocus && previousProxyFocus->focusProxy())
6562 previousProxyFocus = previousProxyFocus->focusProxy();
6563 if (previousProxyFocus == f && !topData->proxyWidget->d_func()->proxyIsGivingFocus)
6569#if QT_CONFIG(graphicsview)
6571 if (
const auto &topData = window()->d_func()->extra) {
6572 if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) {
6573 f->d_func()->updateFocusChild();
6574 topData->proxyWidget->d_func()->focusFromWidgetToProxy = 1;
6575 topData->proxyWidget->setFocus(reason);
6576 topData->proxyWidget->d_func()->focusFromWidgetToProxy = 0;
6581 if (f->isActiveWindow()) {
6582 QWidget *prev = QApplicationPrivate::focus_widget;
6584 if (reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
6585 && prev->testAttribute(Qt::WA_InputMethodEnabled)) {
6586 QGuiApplication::inputMethod()->commit();
6589 if (reason != Qt::NoFocusReason) {
6590 QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, reason);
6591 QCoreApplication::sendEvent(prev, &focusAboutToChange);
6595 f->d_func()->updateFocusChild();
6597 QApplicationPrivate::setFocusWidget(f, reason);
6598#if QT_CONFIG(accessibility)
6600 if (!(f->inherits(
"QMenuBar") || f->inherits(
"QMenu") || f->inherits(
"QMenuItem")))
6602 QAccessibleEvent event(f, QAccessible::Focus);
6603 QAccessible::updateAccessibility(&event);
6606#if QT_CONFIG(graphicsview)
6607 if (
const auto &topData = window()->d_func()->extra) {
6608 if (topData->proxyWidget) {
6609 if (previousProxyFocus && previousProxyFocus != f) {
6611 QFocusEvent event(QEvent::FocusOut, reason);
6612 QPointer<QWidget> that = previousProxyFocus;
6613 QCoreApplication::sendEvent(previousProxyFocus, &event);
6615 QCoreApplication::sendEvent(that->style(), &event);
6618#if QT_CONFIG(graphicsview)
6620 if (
const auto &topData = window()->d_func()->extra)
6621 if (topData->proxyWidget && topData->proxyWidget->hasFocus())
6622 topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget();
6625 QFocusEvent event(QEvent::FocusIn, reason);
6626 QPointer<QWidget> that = f;
6627 QCoreApplication::sendEvent(f, &event);
6629 QCoreApplication::sendEvent(that->style(), &event);
6635 f->d_func()->updateFocusChild();
7029void QWidget::setTabOrder(QWidget* first, QWidget *second)
7031 if (!first || !second || first == second
7032 || first->focusPolicy() == Qt::NoFocus
7033 || second->focusPolicy() == Qt::NoFocus)
7036 if (Q_UNLIKELY(first->window() != second->window())) {
7037 qWarning(
"QWidget::setTabOrder: 'first' and 'second' must be in the same window");
7041 const auto determineLastFocusChild = [](QWidget *target, QWidget *noFurtherThan)
7047 QWidget *lastFocusChild = target;
7049 QWidget *focusProxy = target->d_func()->deepestFocusProxy();
7056 for (
auto *object : target->children()) {
7057 QWidget *w = qobject_cast<QWidget*>(object);
7058 if (w && w->focusProxy() == target) {
7063 }
else if (target->isAncestorOf(focusProxy)) {
7064 lastFocusChild = focusProxy;
7065 for (QWidget *focusNext = lastFocusChild->nextInFocusChain();
7066 focusNext != focusProxy && target->isAncestorOf(focusNext) && focusNext->window() == focusProxy->window();
7067 focusNext = focusNext->nextInFocusChain()) {
7068 if (focusNext == noFurtherThan)
7070 if (focusNext->focusPolicy() != Qt::NoFocus)
7071 lastFocusChild = focusNext;
7074 return lastFocusChild;
7077 QWidget *lastFocusChildOfFirst = determineLastFocusChild(first, second);
7078 if (lastFocusChildOfFirst == second)
7079 lastFocusChildOfFirst = first;
7080 QWidget *lastFocusChildOfSecond = determineLastFocusChild(second, first);
7081 if (lastFocusChildOfSecond == first)
7082 lastFocusChildOfSecond = second;
7085 QWidget *oldPrev = second->previousInFocusChain();
7086 QWidget *prevWithFocus = oldPrev;
7087 while (prevWithFocus->focusPolicy() == Qt::NoFocus)
7088 prevWithFocus = prevWithFocus->previousInFocusChain();
7089 if (prevWithFocus == first)
7091 const QWidgetList chain = QWidgetPrivate::takeFromFocusChain(second, lastFocusChildOfSecond);
7092 QWidgetPrivate::insertIntoFocusChain(chain, QWidgetPrivate::FocusDirection::Next, lastFocusChildOfFirst);
7258void QWidgetPrivate::setGeometry_sys(
int x,
int y,
int w,
int h,
bool isMove)
7262 w = qMin(w,extra->maxw);
7263 h = qMin(h,extra->maxh);
7264 w = qMax(w,extra->minw);
7265 h = qMax(h,extra->minh);
7268 if (q->isWindow() && q->windowHandle()) {
7269 QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration();
7270 if (!integration->hasCapability(QPlatformIntegration::NonFullScreenWindows)) {
7273 w = q->windowHandle()->width();
7274 h = q->windowHandle()->height();
7278 QPoint oldp = q->geometry().topLeft();
7279 QSize olds = q->size();
7280 QRect r(x, y, w, h);
7282 bool isResize = olds != r.size();
7284 isMove = oldp != r.topLeft();
7289 if (r.size() == olds && oldp == r.topLeft())
7292 if (!data.in_set_window_state) {
7293 q->data->window_state &= ~Qt::WindowMaximized;
7294 q->data->window_state &= ~Qt::WindowFullScreen;
7296 topData()->normalGeometry = QRect(0, 0, -1, -1);
7299 QPoint oldPos = q->pos();
7302 bool needsShow =
false;
7304 if (q->isWindow() || q->windowHandle()) {
7305 if (!(data.window_state & Qt::WindowFullScreen) && (w == 0 || h == 0)) {
7306 q->setAttribute(Qt::WA_OutsideWSRange,
true);
7309 data.crect = QRect(x, y, w, h);
7310 }
else if (q->testAttribute(Qt::WA_OutsideWSRange)) {
7311 q->setAttribute(Qt::WA_OutsideWSRange,
false);
7316 if (q->isVisible()) {
7317 if (!q->testAttribute(Qt::WA_DontShowOnScreen) && !q->testAttribute(Qt::WA_OutsideWSRange)) {
7318 if (QWindow *win = q->windowHandle()) {
7319 if (q->isWindow()) {
7320 if (isResize && !isMove)
7322 else if (isMove && !isResize)
7323 win->setPosition(x, y);
7325 win->setGeometry(q->geometry());
7327 QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint());
7328 win->setGeometry(QRect(posInNativeParent,r.size()));
7335 if (!q->isWindow()) {
7336 if (renderToTexture) {
7337 QRegion updateRegion(q->geometry());
7338 updateRegion += QRect(oldPos, olds);
7339 q->parentWidget()->d_func()->invalidateBackingStore(updateRegion);
7340 }
else if (isMove && !isResize) {
7341 moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y());
7343 invalidateBackingStore_resizeHelper(oldPos, olds);
7349 QMoveEvent e(q->pos(), oldPos);
7350 QCoreApplication::sendEvent(q, &e);
7353 QResizeEvent e(r.size(), olds);
7354 QCoreApplication::sendEvent(q, &e);
7355 if (q->windowHandle())
7359 if (isMove && q->pos() != oldPos)
7360 q->setAttribute(Qt::WA_PendingMoveEvent,
true);
7362 q->setAttribute(Qt::WA_PendingResizeEvent,
true);
7365#if QT_CONFIG(accessibility)
7366 if (QAccessible::isActive() && q->isVisible()) {
7367 QAccessibleEvent event(q, QAccessible::LocationChanged);
7368 QAccessible::updateAccessibility(&event);
7502bool QWidget::restoreGeometry(
const QByteArray &geometry)
7504 if (geometry.size() < 4)
7506 QDataStream stream(geometry);
7507 stream.setVersion(QDataStream::Qt_4_0);
7509 const quint32 magicNumber = 0x1D9D0CB;
7510 quint32 storedMagicNumber;
7511 stream >> storedMagicNumber;
7512 if (storedMagicNumber != magicNumber)
7515 const quint16 currentMajorVersion = 3;
7516 quint16 majorVersion = 0;
7517 quint16 minorVersion = 0;
7519 stream >> majorVersion >> minorVersion;
7521 if (majorVersion > currentMajorVersion)
7525 QRect restoredFrameGeometry;
7526 QRect restoredGeometry;
7527 QRect restoredNormalGeometry;
7528 qint32 restoredScreenNumber;
7531 qint32 restoredScreenWidth = 0;
7533 stream >> restoredFrameGeometry
7534 >> restoredNormalGeometry
7535 >> restoredScreenNumber
7539 if (majorVersion > 1)
7540 stream >> restoredScreenWidth;
7541 if (majorVersion > 2)
7542 stream >> restoredGeometry;
7546 if (restoredScreenNumber >= qMax(QGuiApplication::screens().size(), 1))
7547 restoredScreenNumber = 0;
7548 const QScreen *restoredScreen = QGuiApplication::screens().value(restoredScreenNumber,
nullptr);
7549 const qreal screenWidthF = restoredScreen ? qreal(restoredScreen->geometry().width()) : 0;
7552 if (restoredScreenWidth) {
7553 const qreal factor = qreal(restoredScreenWidth) / screenWidthF;
7554 if (factor < 0.8 || factor > 1.25)
7559 if (!maximized && !fullScreen && qreal(restoredFrameGeometry.width()) / screenWidthF > 1.5)
7563 const int frameHeight = QApplication::style()
7564 ? QApplication::style()->pixelMetric(QStyle::PM_TitleBarHeight,
nullptr,
this)
7567 if (!restoredNormalGeometry.isValid())
7568 restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint());
7569 if (!restoredNormalGeometry.isValid()) {
7571 restoredNormalGeometry.setSize(restoredNormalGeometry
7573 .expandedTo(d_func()->adjustedSize()));
7576 const QRect availableGeometry = restoredScreen ? restoredScreen->availableGeometry()
7584 QWidgetPrivate::checkRestoredGeometry(availableGeometry, &restoredGeometry, frameHeight);
7585 QWidgetPrivate::checkRestoredGeometry(availableGeometry, &restoredNormalGeometry, frameHeight);
7587 if (maximized || fullScreen) {
7590 Qt::WindowStates ws = windowState();
7592 setGeometry(restoredNormalGeometry);
7594 if (ws & Qt::WindowFullScreen) {
7596 move(availableGeometry.topLeft());
7597 }
else if (ws & Qt::WindowMaximized) {
7601 if (restoredScreen != screen()) {
7602 setWindowState(Qt::WindowNoState);
7603 setGeometry(restoredNormalGeometry);
7606 setGeometry(restoredNormalGeometry);
7610 ws |= Qt::WindowMaximized;
7612 ws |= Qt::WindowFullScreen;
7614 d_func()->topData()->normalGeometry = restoredNormalGeometry;
7616 setWindowState(windowState() & ~(Qt::WindowMaximized | Qt::WindowFullScreen));
7619 if (majorVersion > 2)
7620 setGeometry(restoredGeometry);
7622 setGeometry(restoredNormalGeometry);
7725QMargins QWidgetPrivate::safeAreaMargins()
const
7729#if QT_CONFIG(graphicsview)
7732 if (nearestGraphicsProxyWidget(q))
7736 QWidget *nativeWidget = q->window();
7737 if (!nativeWidget->windowHandle())
7740 QMargins safeAreaMargins = nativeWidget->windowHandle()->safeAreaMargins();
7742 if (!q->isWindow()) {
7750 if (safeAreaMargins.isNull())
7757 const QWidget *assumedSafeWidget =
nullptr;
7758 for (
const QWidget *w = q; w != nativeWidget; w = w->parentWidget()) {
7759 QWidget *parentWidget = w->parentWidget();
7760 if (!parentWidget->testAttribute(Qt::WA_ContentsMarginsRespectsSafeArea))
7763 if (parentWidget->testAttribute(Qt::WA_LayoutOnEntireRect))
7766 QLayout *layout = parentWidget->layout();
7770 if (layout->geometry().isNull())
7773 if (layout->indexOf(w) < 0)
7776 assumedSafeWidget = w;
7780#if !defined(QT_DEBUG)
7781 if (assumedSafeWidget) {
7792 QPoint topLeftMargins = q->mapFrom(nativeWidget, QPoint(safeAreaMargins.left(), safeAreaMargins.top()));
7793 QRect widgetRect = q->isVisible() ? q->visibleRegion().boundingRect() : q->rect();
7794 QPoint bottomRightMargins = widgetRect.bottomRight() - q->mapFrom(nativeWidget,
7795 nativeWidget->rect().bottomRight() - QPoint(safeAreaMargins.right(), safeAreaMargins.bottom()));
7798 safeAreaMargins = QMargins(qMax(0, topLeftMargins.x()), qMax(0, topLeftMargins.y()),
7799 qMax(0, bottomRightMargins.x()), qMax(0, bottomRightMargins.y()));
7801 if (!safeAreaMargins.isNull() && assumedSafeWidget) {
7802 QLayout *layout = assumedSafeWidget->parentWidget()->layout();
7803 qWarning() << layout <<
"is laying out" << assumedSafeWidget
7804 <<
"outside of the contents rect of" << layout->parentWidget();
7809 return safeAreaMargins;
8035void QWidgetPrivate::show_helper()
8038 data.in_show =
true;
8040 sendPendingMoveAndResizeEvents();
8043 q->setAttribute(Qt::WA_WState_Visible);
8046 showChildren(
false);
8050 const bool isWindow = q->isWindow();
8051#if QT_CONFIG(graphicsview)
8052 bool isEmbedded = isWindow && q->graphicsProxyWidget() !=
nullptr;
8054 bool isEmbedded =
false;
8060 if (isWindow && !isEmbedded) {
8061 if ((q->windowType() == Qt::Tool) || (q->windowType() == Qt::Popup) || q->windowType() == Qt::ToolTip) {
8063 if (q->parentWidget() && q->parentWidget()->window()->testAttribute(Qt::WA_KeyboardFocusChange))
8064 q->setAttribute(Qt::WA_KeyboardFocusChange);
8066 while (QApplication::activePopupWidget()) {
8067 if (!QApplication::activePopupWidget()->close())
8075#if QT_CONFIG(graphicsview)
8077 if (!isEmbedded && !bypassGraphicsProxyWidget(q)) {
8078 QGraphicsProxyWidget *ancestorProxy = nearestGraphicsProxyWidget(q->parentWidget());
8079 if (ancestorProxy) {
8081 ancestorProxy->d_func()->embedSubWindow(q);
8086 Q_UNUSED(isEmbedded);
8090 QShowEvent showEvent;
8091 QCoreApplication::sendEvent(q, &showEvent);
8095 if (!isEmbedded && q->windowType() == Qt::Popup)
8096 qApp->d_func()->openPopup(q);
8098#if QT_CONFIG(accessibility)
8099 if (q->windowType() != Qt::ToolTip) {
8100 QAccessibleEvent event(q, QAccessible::ObjectShow);
8101 QAccessible::updateAccessibility(&event);
8105 if (QApplicationPrivate::hidden_focus_widget == q) {
8106 QApplicationPrivate::hidden_focus_widget =
nullptr;
8107 q->setFocus(Qt::OtherFocusReason);
8113 if (!
qApp->d_func()->in_exec && q->windowType() == Qt::SplashScreen)
8114 QCoreApplication::processEvents();
8116 data.in_show =
false;
8119void QWidgetPrivate::show_sys()
8123 auto window = qobject_cast<QWidgetWindow *>(windowHandle());
8125 if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
8126 invalidateBackingStore(q->rect());
8127 q->setAttribute(Qt::WA_Mapped);
8129 if (window && q->isWindow()
8130#if QT_CONFIG(graphicsview)
8131 && (!extra || !extra->proxyWidget)
8133 && q->windowModality() != Qt::NonModal) {
8134 QGuiApplicationPrivate::showModalWindow(window);
8139 if (renderToTexture && !q->isWindow())
8140 QCoreApplication::postEvent(q->parentWidget(),
new QUpdateLaterEvent(q->geometry()));
8142 QCoreApplication::postEvent(q,
new QUpdateLaterEvent(q->rect()));
8144 if ((!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow))
8145 || q->testAttribute(Qt::WA_OutsideWSRange)) {
8151 fixPosIncludesFrame();
8152 QRect geomRect = q->geometry();
8153 if (!q->isWindow()) {
8154 QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint());
8155 geomRect.moveTopLeft(topLeftOfWindow);
8157 const QRect windowRect = window->geometry();
8158 if (windowRect != geomRect) {
8159 if (q->testAttribute(Qt::WA_Moved)
8160 || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowManagement))
8161 window->setGeometry(geomRect);
8163 window->resize(geomRect.size());
8167 qt_qpa_set_cursor(q,
false);
8169 invalidateBackingStore(q->rect());
8170 window->setNativeWindowVisibility(
true);
8172 if (window->isTopLevel()) {
8173 const QPoint crectTopLeft = q->data->crect.topLeft();
8174 const QPoint windowTopLeft = window->geometry().topLeft();
8175 if (crectTopLeft == QPoint(0, 0) && windowTopLeft != crectTopLeft)
8176 q->data->crect.moveTopLeft(windowTopLeft);
8335void QWidgetPrivate::setVisible(
bool visible)
8338 qCDebug(lcWidgetShowHide) <<
"Setting visibility of" << q
8339 <<
"with attributes" << WidgetAttributes{q}
8340 <<
"to" << visible <<
"via QWidgetPrivate";
8344 if (!q->isWindow() && q->parentWidget() && q->parentWidget()->isVisible()
8345 && !q->parentWidget()->testAttribute(Qt::WA_WState_Created))
8346 q->parentWidget()->window()->d_func()->createRecursively();
8349 QWidget *pw = q->parentWidget();
8350 if (!q->testAttribute(Qt::WA_WState_Created)
8351 && (q->isWindow() || pw->testAttribute(Qt::WA_WState_Created))) {
8355 bool wasResized = q->testAttribute(Qt::WA_Resized);
8356 Qt::WindowStates initialWindowState = q->windowState();
8359 q->ensurePolished();
8362 bool needUpdateGeometry = !q->isWindow() && q->testAttribute(Qt::WA_WState_Hidden);
8364 q->setAttribute(Qt::WA_WState_Hidden,
false);
8366 if (needUpdateGeometry)
8367 updateGeometry_helper(
true);
8373 if (!q->isWindow()) {
8374 QWidget *parent = q->parentWidget();
8375 while (parent && parent->isVisible() && parent->d_func()->layout && !parent->data->in_show) {
8376 parent->d_func()->layout->activate();
8377 if (parent->isWindow())
8379 parent = parent->parentWidget();
8382 parent->d_func()->setDirtyOpaqueRegion();
8387 && (q->isWindow() || !q->parentWidget()->d_func()->layout)) {
8388 if (q->isWindow()) {
8390 if (q->windowState() != initialWindowState)
8391 q->setWindowState(initialWindowState);
8395 q->setAttribute(Qt::WA_Resized,
false);
8398 q->setAttribute(Qt::WA_KeyboardFocusChange,
false);
8400 if (q->isWindow() || q->parentWidget()->isVisible()) {
8403 qApp->d_func()->sendSyntheticEnterLeave(q);
8406 QEvent showToParentEvent(QEvent::ShowToParent);
8407 QCoreApplication::sendEvent(q, &showToParentEvent);
8409 if (QApplicationPrivate::hidden_focus_widget == q)
8410 QApplicationPrivate::hidden_focus_widget =
nullptr;
8416 if (!q->isWindow() && q->parentWidget())
8417 q->parentWidget()->d_func()->setDirtyOpaqueRegion();
8419 if (!q->testAttribute(Qt::WA_WState_Hidden)) {
8420 q->setAttribute(Qt::WA_WState_Hidden);
8425 if (!q->isWindow() && q->parentWidget()) {
8426 if (q->parentWidget()->d_func()->layout)
8427 q->parentWidget()->d_func()->layout->invalidate();
8428 else if (q->parentWidget()->isVisible())
8429 QCoreApplication::postEvent(q->parentWidget(),
new QEvent(QEvent::LayoutRequest));
8432 QEvent hideToParentEvent(QEvent::HideToParent);
8433 QCoreApplication::sendEvent(q, &hideToParentEvent);
8934bool QWidget::event(QEvent *event)
8940 switch(event->type()) {
8941 case QEvent::TabletPress:
8942 case QEvent::TabletRelease:
8943 case QEvent::TabletMove:
8944 case QEvent::MouseButtonPress:
8945 case QEvent::MouseButtonRelease:
8946 case QEvent::MouseButtonDblClick:
8947 case QEvent::MouseMove:
8948 case QEvent::TouchBegin:
8949 case QEvent::TouchUpdate:
8950 case QEvent::TouchEnd:
8951 case QEvent::TouchCancel:
8952 case QEvent::ContextMenu:
8953 case QEvent::KeyPress:
8954 case QEvent::KeyRelease:
8955#if QT_CONFIG(wheelevent)
8963 switch (event->type()) {
8964 case QEvent::PlatformSurface: {
8966 switch (
static_cast<QPlatformSurfaceEvent*>(event)->surfaceEventType()) {
8967 case QPlatformSurfaceEvent::SurfaceCreated:
8968 if (!testAttribute(Qt::WA_WState_Created))
8971 case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
8972 if (testAttribute(Qt::WA_WState_Created)) {
8975 destroy(
false,
false);
8981 case QEvent::MouseMove:
8982 mouseMoveEvent((QMouseEvent*)event);
8985 case QEvent::MouseButtonPress:
8986 mousePressEvent((QMouseEvent*)event);
8989 case QEvent::MouseButtonRelease:
8990 mouseReleaseEvent((QMouseEvent*)event);
8993 case QEvent::MouseButtonDblClick:
8994 mouseDoubleClickEvent((QMouseEvent*)event);
8996#if QT_CONFIG(wheelevent)
8998 wheelEvent((QWheelEvent*)event);
9001#if QT_CONFIG(tabletevent)
9002 case QEvent::TabletMove:
9003 if (
static_cast<QTabletEvent *>(event)->buttons() == Qt::NoButton && !testAttribute(Qt::WA_TabletTracking))
9006 case QEvent::TabletPress:
9007 case QEvent::TabletRelease:
9008 tabletEvent((QTabletEvent*)event);
9011 case QEvent::KeyPress: {
9012 QKeyEvent *k =
static_cast<QKeyEvent *>(event);
9014 if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) {
9015 if (k->key() == Qt::Key_Backtab
9016 || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier)))
9017 res = focusNextPrevChild(
false);
9018 else if (k->key() == Qt::Key_Tab)
9019 res = focusNextPrevChild(
true);
9024#if QT_CONFIG(whatsthis)
9025 if (!k->isAccepted()
9026 && k->modifiers() & Qt::ShiftModifier && k->key() == Qt::Key_F1
9027 && d->whatsThis.size()) {
9028 QWhatsThis::showText(mapToGlobal(inputMethodQuery(Qt::ImCursorRectangle).toRect().center()), d->whatsThis,
this);
9035 case QEvent::KeyRelease:
9036 keyReleaseEvent((QKeyEvent*)event);
9038 case QEvent::ShortcutOverride:
9041 case QEvent::InputMethod:
9042 inputMethodEvent((QInputMethodEvent *) event);
9045 case QEvent::InputMethodQuery: {
9046 QInputMethodQueryEvent *query =
static_cast<QInputMethodQueryEvent *>(event);
9047 Qt::InputMethodQueries queries = query->queries();
9048 for (uint i = 0; i < 32; ++i) {
9049 Qt::InputMethodQuery q = (Qt::InputMethodQuery)(
int)(queries & (1<<i));
9051 QVariant v = inputMethodQuery(q);
9052 if (q == Qt::ImEnabled && !v.isValid() && isEnabled()) {
9059 v = QVariant(testAttribute(Qt::WA_InputMethodEnabled));
9061 query->setValue(q, v);
9068 case QEvent::PolishRequest:
9072 case QEvent::Polish: {
9073 style()->polish(
this);
9074 setAttribute(Qt::WA_WState_Polished);
9075 if (!QApplication::font(
this).isCopyOf(QApplication::font()))
9077 if (!QApplication::palette(
this).isCopyOf(QGuiApplication::palette()))
9078 d->resolvePalette();
9082 case QEvent::ApplicationWindowIconChange:
9083 if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon)) {
9084 d->setWindowIcon_sys();
9085 d->setWindowIcon_helper();
9088 case QEvent::FocusIn:
9089 focusInEvent((QFocusEvent*)event);
9090 d->updateWidgetTransform(event);
9093 case QEvent::FocusOut:
9094 focusOutEvent((QFocusEvent*)event);
9098#if QT_CONFIG(statustip)
9099 if (d->statusTip.size()) {
9100 QStatusTipEvent tip(d->statusTip);
9101 QCoreApplication::sendEvent(
const_cast<QWidget *>(
this), &tip);
9104 enterEvent(
static_cast<QEnterEvent*>(event));
9108#if QT_CONFIG(statustip)
9109 if (d->statusTip.size()) {
9111 QStatusTipEvent tip(empty);
9112 QCoreApplication::sendEvent(
const_cast<QWidget *>(
this), &tip);
9118 case QEvent::HoverEnter:
9119 case QEvent::HoverLeave:
9127 paintEvent((QPaintEvent*)event);
9131 moveEvent((QMoveEvent*)event);
9132 d->updateWidgetTransform(event);
9135 case QEvent::Resize:
9136 resizeEvent((QResizeEvent*)event);
9137 d->updateWidgetTransform(event);
9141 closeEvent((QCloseEvent *)event);
9144#ifndef QT_NO_CONTEXTMENU
9145 case QEvent::ContextMenu:
9146 switch (data->context_menu_policy) {
9147 case Qt::PreventContextMenu:
9149 case Qt::DefaultContextMenu:
9150 contextMenuEvent(
static_cast<QContextMenuEvent *>(event));
9152 case Qt::CustomContextMenu:
9153 emit customContextMenuRequested(
static_cast<QContextMenuEvent *>(event)->pos());
9156 case Qt::ActionsContextMenu:
9157 if (d->actions.size()) {
9158 QMenu::exec(d->actions,
static_cast<QContextMenuEvent *>(event)->globalPos(),
9171#if QT_CONFIG(draganddrop)
9173 dropEvent((QDropEvent*) event);
9176 case QEvent::DragEnter:
9177 dragEnterEvent((QDragEnterEvent*) event);
9180 case QEvent::DragMove:
9181 dragMoveEvent((QDragMoveEvent*) event);
9184 case QEvent::DragLeave:
9185 dragLeaveEvent((QDragLeaveEvent*) event);
9190 showEvent((QShowEvent*) event);
9194 hideEvent((QHideEvent*) event);
9197 case QEvent::ShowWindowRequest:
9202 case QEvent::ApplicationFontChange:
9205 case QEvent::ApplicationPaletteChange:
9206 d->resolvePalette();
9209 case QEvent::ToolBarChange:
9210 case QEvent::ActivationChange:
9211 case QEvent::EnabledChange:
9212 case QEvent::FontChange:
9213 case QEvent::StyleChange:
9214 case QEvent::PaletteChange:
9215 case QEvent::WindowTitleChange:
9216 case QEvent::IconTextChange:
9217 case QEvent::ModifiedChange:
9218 case QEvent::MouseTrackingChange:
9219 case QEvent::TabletTrackingChange:
9220 case QEvent::ParentChange:
9221 case QEvent::LocaleChange:
9222 case QEvent::MacSizeChange:
9223 case QEvent::ContentsRectChange:
9224 case QEvent::ThemeChange:
9225 case QEvent::ReadOnlyChange:
9229 case QEvent::WindowStateChange: {
9230 const bool wasMinimized =
static_cast<
const QWindowStateChangeEvent *>(event)->oldState() & Qt::WindowMinimized;
9231 if (wasMinimized != isMinimized()) {
9232 QWidget *widget =
const_cast<QWidget *>(
this);
9235 if (!d->childrenShownByExpose) {
9237 d->showChildren(
true);
9238 QShowEvent showEvent;
9239 QCoreApplication::sendSpontaneousEvent(widget, &showEvent);
9241 d->childrenHiddenByWState =
false;
9243 QHideEvent hideEvent;
9244 QCoreApplication::sendSpontaneousEvent(widget, &hideEvent);
9245 d->hideChildren(
true);
9246 d->childrenHiddenByWState =
true;
9248 d->childrenShownByExpose =
false;
9254 case QEvent::WindowActivate:
9255 case QEvent::WindowDeactivate: {
9256 if (isVisible() && !palette().isEqual(QPalette::Active, QPalette::Inactive))
9258 QList<QObject*> childList = d->children;
9259 for (
int i = 0; i < childList.size(); ++i) {
9260 QWidget *w = qobject_cast<QWidget *>(childList.at(i));
9261 if (w && w->isVisible() && !w->isWindow())
9262 QCoreApplication::sendEvent(w, event);
9266 case QEvent::LanguageChange:
9269 QList<QObject*> childList = d->children;
9270 for (
int i = 0; i < childList.size(); ++i) {
9271 QObject *o = childList.at(i);
9273 QCoreApplication::sendEvent(o, event);
9279 case QEvent::ApplicationLayoutDirectionChange:
9280 d->resolveLayoutDirection();
9283 case QEvent::LayoutDirectionChange:
9285 d->layout->invalidate();
9289 case QEvent::UpdateRequest:
9290 d->syncBackingStore();
9292 case QEvent::UpdateLater:
9293 update(
static_cast<QUpdateLaterEvent*>(event)->region());
9295 case QEvent::StyleAnimationUpdate:
9296 if (isVisible() && !window()->isMinimized()) {
9302 case QEvent::WindowBlocked:
9303 case QEvent::WindowUnblocked:
9304 if (!d->children.isEmpty()) {
9305 QWidget *modalWidget = QApplication::activeModalWidget();
9306 for (
int i = 0; i < d->children.size(); ++i) {
9307 QObject *o = d->children.at(i);
9308 if (o && o != modalWidget && o->isWidgetType()) {
9309 QWidget *w =
static_cast<QWidget *>(o);
9312 QCoreApplication::sendEvent(w, event);
9317#if QT_CONFIG(tooltip)
9318 case QEvent::ToolTip:
9319 if (!d->toolTip.isEmpty())
9320 QToolTip::showText(
static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip,
this, QRect(), d->toolTipDuration);
9325#if QT_CONFIG(whatsthis)
9326 case QEvent::WhatsThis:
9327 if (d->whatsThis.size())
9328 QWhatsThis::showText(
static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis,
this);
9332 case QEvent::QueryWhatsThis:
9333 if (d->whatsThis.isEmpty())
9337 case QEvent::EmbeddingControl:
9338 d->topData()->frameStrut.setCoords(0 ,0, 0, 0);
9339 data->fstrut_dirty =
false;
9342 case QEvent::ActionAdded:
9343 case QEvent::ActionRemoved:
9344 case QEvent::ActionChanged:
9345 actionEvent((QActionEvent*)event);
9349 case QEvent::KeyboardLayoutChange:
9354 QList<QObject*> childList = d->children;
9355 for (
int i = 0; i < childList.size(); ++i) {
9356 QWidget *w = qobject_cast<QWidget *>(childList.at(i));
9357 if (w && w->isVisible() && !w->isWindow())
9358 QCoreApplication::sendEvent(w, event);
9362 case QEvent::TouchBegin:
9363 case QEvent::TouchUpdate:
9364 case QEvent::TouchEnd:
9365 case QEvent::TouchCancel:
9370#ifndef QT_NO_GESTURES
9371 case QEvent::Gesture:
9375 case QEvent::ScreenChangeInternal:
9376 if (
const QTLWExtra *te = d->maybeTopData()) {
9377 const QWindow *win = te->window;
9378 d->setWinId((win && win->handle()) ? win->handle()->winId() : 0);
9381 case QEvent::DevicePixelRatioChange:
9382 if (d->data.fnt.d->dpi != logicalDpiY())
9383 d->updateFont(d->data.fnt);
9384 d->renderToTextureReallyDirty = 1;
9386 case QEvent::DynamicPropertyChange: {
9387 const QByteArray &propName =
static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
9388 if (propName.size() == 13 && !qstrncmp(propName,
"_q_customDpi", 12)) {
9389 uint value = property(propName.constData()).toUInt();
9392 const char axis = propName.at(12);
9394 d->extra->customDpiX = value;
9395 else if (axis ==
'Y')
9396 d->extra->customDpiY = value;
9397 d->updateFont(d->data.fnt);
9399 if (windowHandle() && !qstrncmp(propName,
"_q_platform_", 12))
9400 windowHandle()->setProperty(propName, property(propName));
9404 return QObject::event(event);
10709void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
10712 Q_ASSERT_X(
this != parent, Q_FUNC_INFO,
"Cannot parent a QWidget to itself");
10714 const auto checkForParentChildLoops = qScopeGuard([&](){
10716 auto p = parentWidget();
10718 if (++depth == QObjectPrivate::CheckForParentChildLoopsWarnDepth) {
10719 qWarning(
"QWidget %p (class: '%s', object name: '%s') may have a loop in its parent-child chain; "
10720 "this is undefined behavior",
10721 this, metaObject()->className(), qPrintable(objectName()));
10723 p = p->parentWidget();
10728 const bool resized = testAttribute(Qt::WA_Resized);
10729 const bool wasCreated = testAttribute(Qt::WA_WState_Created);
10730 QWidget *oldtlw = window();
10732 QWidget *oldParentWithWindow = d->closestParentWidgetWithWindowHandle();
10734 if (f & Qt::Window)
10735 d->data.fstrut_dirty =
true;
10737 bool newParent = (parent != parentWidget());
10739 if (newParent && parent) {
10740 if (testAttribute(Qt::WA_NativeWindow) && !QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings))
10741 parent->d_func()->enforceNativeChildren();
10742 else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
10743 setAttribute(Qt::WA_NativeWindow);
10747 if (!testAttribute(Qt::WA_WState_Hidden)) {
10762 setAttribute(Qt::WA_WState_ExplicitShowHide,
false);
10765 QEvent e(QEvent::ParentAboutToChange);
10766 QCoreApplication::sendEvent(
this, &e);
10772 const bool oldWidgetUsesRhiFlush = oldParentWithWindow ? oldParentWithWindow->d_func()->usesRhiFlush
10773 : oldtlw->d_func()->usesRhiFlush;
10774 if (oldWidgetUsesRhiFlush && ((!parent && parentWidget()) || (parent && parent->window() != oldtlw)))
10775 qSendWindowChangeToTextureChildrenRecursively(
this, QEvent::WindowAboutToChangeInternal);
10779 if (newParent && isAncestorOf(focusWidget()) && !(f & Qt::Window))
10780 focusWidget()->clearFocus();
10782 d->setParent_sys(parent, f);
10784 if (d->textureChildSeen && parent) {
10786 QWidgetPrivate::get(parent)->setTextureChildSeen();
10789 if (QWidgetRepaintManager *oldPaintManager = oldtlw->d_func()->maybeRepaintManager()) {
10791 oldPaintManager->removeDirtyWidget(
this);
10794 oldPaintManager->moveStaticWidgets(
this);
10797 d->reparentFocusWidgets(oldtlw);
10798 setAttribute(Qt::WA_Resized, resized);
10800 const bool useStyleSheetPropagationInWidgetStyles =
10801 QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
10803 if (!useStyleSheetPropagationInWidgetStyles && !testAttribute(Qt::WA_StyleSheet)
10804 && (!parent || !parent->testAttribute(Qt::WA_StyleSheet))) {
10807 const auto pd = parent->d_func();
10808 d->inheritedFontResolveMask = pd->directFontResolveMask | pd->inheritedFontResolveMask;
10809 d->inheritedPaletteResolveMask = pd->directPaletteResolveMask | pd->inheritedPaletteResolveMask;
10812 d->resolvePalette();
10814 d->resolveLayoutDirection();
10815 d->resolveLocale();
10821 if (newParent || !wasCreated
10822#if QT_CONFIG(opengles2)
10823 || (f & Qt::MSWindowsOwnDC)
10828 if (!testAttribute(Qt::WA_ForceDisabled))
10829 d->setEnabled_helper(parent ? parent->isEnabled() :
true);
10830 if (!testAttribute(Qt::WA_ForceUpdatesDisabled))
10831 d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() :
true);
10836 if (parent && d->sendChildEvents) {
10837 QChildEvent e(QEvent::ChildAdded,
this);
10838 QCoreApplication::sendEvent(parent, &e);
10841 if (parent && d->sendChildEvents && d->polished) {
10842 QChildEvent e(QEvent::ChildPolished,
this);
10843 QCoreApplication::sendEvent(parent, &e);
10846 QEvent e(QEvent::ParentChange);
10847 QCoreApplication::sendEvent(
this, &e);
10852 if (oldWidgetUsesRhiFlush && oldtlw != window())
10853 qSendWindowChangeToTextureChildrenRecursively(
this, QEvent::WindowChangeInternal);
10856 if (isWindow() || parentWidget()->isVisible())
10857 setAttribute(Qt::WA_WState_Hidden,
true);
10858 else if (!testAttribute(Qt::WA_WState_ExplicitShowHide))
10859 setAttribute(Qt::WA_WState_Hidden,
false);
10862 d->updateIsOpaque();
10864#if QT_CONFIG(graphicsview)
10867 if (oldtlw->graphicsProxyWidget()) {
10868 if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(oldtlw))
10869 ancestorProxy->d_func()->unembedSubWindow(
this);
10871 if (isWindow() && parent && !graphicsProxyWidget() && !bypassGraphicsProxyWidget(
this)) {
10872 if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(parent))
10873 ancestorProxy->d_func()->embedSubWindow(
this);
10877 if (d->extra && d->extra->hasWindowContainer)
10878 QWindowContainer::parentWasChanged(
this);
10880 QWidget *newParentWithWindow = d->closestParentWidgetWithWindowHandle();
10881 if (newParentWithWindow && newParentWithWindow != oldParentWithWindow) {
10883 qCDebug(lcWidgetPainting) <<
"Evaluating whether reparenting of" <<
this
10884 <<
"into" << parent <<
"requires RHI enablement for" << newParentWithWindow;
10886 QPlatformBackingStoreRhiConfig rhiConfig;
10887 QSurface::SurfaceType surfaceType = QSurface::RasterSurface;
10893 if (q_evaluateRhiConfig(
this, &rhiConfig, &surfaceType)) {
10897 if (q_evaluateRhiConfig(newParentWithWindow,
nullptr,
nullptr)) {
10900 auto *existingWindow = newParentWithWindow->windowHandle();
10901 auto existingSurfaceType = existingWindow->surfaceType();
10902 if (existingSurfaceType != surfaceType) {
10903 qCDebug(lcWidgetPainting)
10904 <<
"Recreating" << existingWindow
10905 <<
"with current type" << existingSurfaceType
10906 <<
"to support" << surfaceType;
10907 const auto windowStateBeforeDestroy = newParentWithWindow->windowState();
10908 const auto visibilityBeforeDestroy = newParentWithWindow->isVisible();
10909 const auto positionBeforeDestroy = newParentWithWindow->pos();
10910 newParentWithWindow->d_func()->recreate();
10911 Q_ASSERT(newParentWithWindow->windowHandle());
10912 newParentWithWindow->windowHandle()->setWindowStates(windowStateBeforeDestroy);
10913 newParentWithWindow->move(positionBeforeDestroy);
10914 QWidgetPrivate::get(newParentWithWindow)->setVisible(visibilityBeforeDestroy);
10915 }
else if (
auto *backingStore = newParentWithWindow->backingStore()) {
10918 backingStore->handle()->createRhi(existingWindow, rhiConfig);
10920 QWidgetPrivate::get(newParentWithWindow)->usesRhiFlush =
true;
10926#if QT_CONFIG(accessibility)
10927 if (QGuiApplicationPrivate::is_app_running && !QGuiApplicationPrivate::is_app_closing) {
10928 QAccessibleEvent qaEvent(
this, QAccessible::ParentChanged);
10929 QAccessible::updateAccessibility(&qaEvent);
10935void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
10939 Qt::WindowFlags oldFlags = data.window_flags;
10940 bool wasCreated = q->testAttribute(Qt::WA_WState_Created);
10942 QScreen *targetScreen =
nullptr;
10948 targetScreen = q->parentWidget()->window()->screen();
10951 const bool destroyWindow = (
10953 (oldFlags & Qt::Window) && !(f & Qt::Window)
10955 && wasCreated && !q->testAttribute(Qt::WA_NativeWindow)
10958 if (parent != newparent) {
10960 QObjectPrivate::setParent_helper(newparent);
10962 if (q->windowHandle())
10963 q->windowHandle()->setFlags(f);
10967 QWidget *parentWithWindow = closestParentWidgetWithWindowHandle();
10970 if (destroyWindow) {
10971 reparentWidgetWindowChildren(parentWithWindow);
10981 reparentWidgetWindows(parentWithWindow, f);
10985 bool explicitlyHidden = isExplicitlyHidden();
10987 if (destroyWindow) {
10988 if (extra && extra->hasWindowContainer)
10989 QWindowContainer::toplevelAboutToBeDestroyed(q);
10993 if (!q->windowHandle()->children().isEmpty()) {
10994 QWidget *parentWithWindow = closestParentWidgetWithWindowHandle();
10995 QWindow *newParentWindow = parentWithWindow ? parentWithWindow->windowHandle() :
nullptr;
10996 for (QObject *child : q->windowHandle()->children()) {
10997 if (QWindow *childWindow = qobject_cast<QWindow *>(child)) {
10998 qCWarning(lcWidgetWindow) <<
"Reparenting" << childWindow
10999 <<
"before destroying" <<
this;
11000 childWindow->setParent(newParentWindow);
11008 q->destroy(
true,
false);
11012 data.window_flags = f;
11013 q->setAttribute(Qt::WA_WState_Created,
false);
11014 q->setAttribute(Qt::WA_WState_Visible,
false);
11015 q->setAttribute(Qt::WA_WState_Hidden,
false);
11017 if (newparent && wasCreated && (q->testAttribute(Qt::WA_NativeWindow) || (f & Qt::Window)))
11020 if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
11021 q->setAttribute(Qt::WA_WState_Hidden);
11022 q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
11025 if (!newparent && targetScreen) {
11027 if (q->testAttribute(Qt::WA_WState_Created))
11028 q->windowHandle()->setScreen(targetScreen);
11030 topData()->initialScreen = targetScreen;
11369void QWidget::setAttribute(Qt::WidgetAttribute attribute,
bool on)
11373 if (attribute == Qt::WA_ContentsMarginsRespectsSafeArea) {
11375 auto *topExtra = d->topData();
11376 topExtra->explicitContentsMarginsRespectsSafeArea =
true;
11380 if (testAttribute(attribute) == on)
11383 static_assert(
sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount -
sizeof(uint)*8),
11384 "QWidget::setAttribute(WidgetAttribute, bool): "
11385 "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
11388 if (attribute == Qt::WA_PaintOnScreen && on && !inherits(
"QGLWidget")) {
11391 if (d->noPaintOnScreen)
11397 if (attribute == Qt::WA_NativeWindow && !d->mustHaveWindowHandle) {
11398 QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();
11399 if (!platformIntegration->hasCapability(QPlatformIntegration::NativeWidgets))
11403 setAttribute_internal(attribute, on, data, d);
11405 switch (attribute) {
11407#if QT_CONFIG(draganddrop)
11408 case Qt::WA_AcceptDrops: {
11409 if (on && !testAttribute(Qt::WA_DropSiteRegistered))
11410 setAttribute(Qt::WA_DropSiteRegistered,
true);
11411 else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)))
11412 setAttribute(Qt::WA_DropSiteRegistered,
false);
11413 QEvent e(QEvent::AcceptDropsChange);
11414 QCoreApplication::sendEvent(
this, &e);
11417 case Qt::WA_DropSiteRegistered: {
11418 for (
int i = 0; i < d->children.size(); ++i) {
11419 QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
11420 if (w && !w->isWindow() && !w->testAttribute(Qt::WA_AcceptDrops) && w->testAttribute(Qt::WA_DropSiteRegistered) != on)
11421 w->setAttribute(Qt::WA_DropSiteRegistered, on);
11427 case Qt::WA_NoChildEventsForParent:
11428 d->sendChildEvents = !on;
11430 case Qt::WA_NoChildEventsFromChildren:
11431 d->receiveChildEvents = !on;
11433 case Qt::WA_MacNormalSize:
11434 case Qt::WA_MacSmallSize:
11435 case Qt::WA_MacMiniSize:
11439 const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize,
11440 Qt::WA_MacMiniSize };
11441 for (
int i = 0; i < 3; ++i) {
11442 if (MacSizes[i] != attribute)
11443 setAttribute_internal(MacSizes[i],
false, data, d);
11445 d->macUpdateSizeAttribute();
11449 case Qt::WA_ShowModal:
11452 data->window_modality = Qt::NonModal;
11453 }
else if (data->window_modality == Qt::NonModal) {
11456 data->window_modality = Qt::ApplicationModal;
11461 if (testAttribute(Qt::WA_WState_Created)) {
11466 case Qt::WA_MouseTracking: {
11467 QEvent e(QEvent::MouseTrackingChange);
11468 QCoreApplication::sendEvent(
this, &e);
11470 case Qt::WA_TabletTracking: {
11471 QEvent e(QEvent::TabletTrackingChange);
11472 QCoreApplication::sendEvent(
this, &e);
11474 case Qt::WA_NativeWindow: {
11475 d->createTLExtra();
11477 d->createTLSysExtra();
11479 QWidget *focusWidget = d->effectiveFocusWidget();
11480 if (on && !internalWinId() &&
this == QGuiApplication::focusObject()
11481 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
11482 QGuiApplication::inputMethod()->commit();
11483 QGuiApplication::inputMethod()->update(Qt::ImEnabled);
11485 if (!QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
11486 parentWidget()->d_func()->enforceNativeChildren();
11487 if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
11489 if (isEnabled() && focusWidget->isEnabled() &&
this == QGuiApplication::focusObject()
11490 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
11491 QGuiApplication::inputMethod()->update(Qt::ImEnabled);
11496 case Qt::WA_PaintOnScreen:
11497 d->updateIsOpaque();
11499 case Qt::WA_OpaquePaintEvent:
11500 d->updateIsOpaque();
11502 case Qt::WA_NoSystemBackground:
11503 d->updateIsOpaque();
11505 case Qt::WA_UpdatesDisabled:
11506 d->updateSystemBackground();
11508 case Qt::WA_TransparentForMouseEvents:
11510 case Qt::WA_InputMethodEnabled: {
11512 if (QGuiApplication::focusObject() ==
this) {
11514 QGuiApplication::inputMethod()->commit();
11515 QGuiApplication::inputMethod()->update(Qt::ImEnabled);
11520 case Qt::WA_WindowPropagation:
11521 d->resolvePalette();
11523 d->resolveLocale();
11525 case Qt::WA_DontShowOnScreen: {
11526 if (on && isVisible()) {
11536 case Qt::WA_X11NetWmWindowTypeDesktop:
11537 case Qt::WA_X11NetWmWindowTypeDock:
11538 case Qt::WA_X11NetWmWindowTypeToolBar:
11539 case Qt::WA_X11NetWmWindowTypeMenu:
11540 case Qt::WA_X11NetWmWindowTypeUtility:
11541 case Qt::WA_X11NetWmWindowTypeSplash:
11542 case Qt::WA_X11NetWmWindowTypeDialog:
11543 case Qt::WA_X11NetWmWindowTypeDropDownMenu:
11544 case Qt::WA_X11NetWmWindowTypePopupMenu:
11545 case Qt::WA_X11NetWmWindowTypeToolTip:
11546 case Qt::WA_X11NetWmWindowTypeNotification:
11547 case Qt::WA_X11NetWmWindowTypeCombo:
11548 case Qt::WA_X11NetWmWindowTypeDND:
11549 d->setNetWmWindowTypes();
11552 case Qt::WA_StaticContents:
11553 if (QWidgetRepaintManager *repaintManager = d->maybeRepaintManager()) {
11555 repaintManager->addStaticWidget(
this);
11557 repaintManager->removeStaticWidget(
this);
11560 case Qt::WA_TranslucentBackground:
11562 setAttribute(Qt::WA_NoSystemBackground);
11563 d->updateIsTranslucent();
11566 case Qt::WA_AcceptTouchEvents:
13152void QWidgetPrivate::setNetWmWindowTypes(
bool skipIfMissing)
13157 if (!q->windowHandle())
13160 QXcbWindow::WindowTypes wmWindowType = QXcbWindow::None;
13161 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDesktop))
13162 wmWindowType |= QXcbWindow::Desktop;
13163 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock))
13164 wmWindowType |= QXcbWindow::Dock;
13165 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolBar))
13166 wmWindowType |= QXcbWindow::Toolbar;
13167 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeMenu))
13168 wmWindowType |= QXcbWindow::Menu;
13169 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeUtility))
13170 wmWindowType |= QXcbWindow::Utility;
13171 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeSplash))
13172 wmWindowType |= QXcbWindow::Splash;
13173 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDialog))
13174 wmWindowType |= QXcbWindow::Dialog;
13175 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu))
13176 wmWindowType |= QXcbWindow::DropDownMenu;
13177 if (q->testAttribute(Qt::WA_X11NetWmWindowTypePopupMenu))
13178 wmWindowType |= QXcbWindow::PopupMenu;
13179 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolTip))
13180 wmWindowType |= QXcbWindow::Tooltip;
13181 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeNotification))
13182 wmWindowType |= QXcbWindow::Notification;
13183 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeCombo))
13184 wmWindowType |= QXcbWindow::Combo;
13185 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDND))
13186 wmWindowType |= QXcbWindow::Dnd;
13188 if (wmWindowType == QXcbWindow::None && skipIfMissing)
13191 if (
auto *xcbWindow =
dynamic_cast<QXcbWindow*>(q->windowHandle()->handle()))
13192 xcbWindow->setWindowType(wmWindowType);
13194 Q_UNUSED(skipIfMissing);