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);
7501bool QWidget::restoreGeometry(
const QByteArray &geometry)
7503 if (geometry.size() < 4)
7505 QDataStream stream(geometry);
7506 stream.setVersion(QDataStream::Qt_4_0);
7508 const quint32 magicNumber = 0x1D9D0CB;
7509 quint32 storedMagicNumber;
7510 stream >> storedMagicNumber;
7511 if (storedMagicNumber != magicNumber)
7514 const quint16 currentMajorVersion = 3;
7515 quint16 majorVersion = 0;
7516 quint16 minorVersion = 0;
7518 stream >> majorVersion >> minorVersion;
7520 if (majorVersion > currentMajorVersion)
7524 QRect restoredFrameGeometry;
7525 QRect restoredGeometry;
7526 QRect restoredNormalGeometry;
7527 qint32 restoredScreenNumber;
7530 qint32 restoredScreenWidth = 0;
7532 stream >> restoredFrameGeometry
7533 >> restoredNormalGeometry
7534 >> restoredScreenNumber
7538 if (majorVersion > 1)
7539 stream >> restoredScreenWidth;
7540 if (majorVersion > 2)
7541 stream >> restoredGeometry;
7545 if (restoredScreenNumber >= qMax(QGuiApplication::screens().size(), 1))
7546 restoredScreenNumber = 0;
7547 const QScreen *restoredScreen = QGuiApplication::screens().value(restoredScreenNumber,
nullptr);
7548 const qreal screenWidthF = restoredScreen ? qreal(restoredScreen->geometry().width()) : 0;
7551 if (restoredScreenWidth) {
7552 const qreal factor = qreal(restoredScreenWidth) / screenWidthF;
7553 if (factor < 0.8 || factor > 1.25)
7558 if (!maximized && !fullScreen && qreal(restoredFrameGeometry.width()) / screenWidthF > 1.5)
7562 const int frameHeight = QApplication::style()
7563 ? QApplication::style()->pixelMetric(QStyle::PM_TitleBarHeight,
nullptr,
this)
7566 if (!restoredNormalGeometry.isValid())
7567 restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint());
7568 if (!restoredNormalGeometry.isValid()) {
7570 restoredNormalGeometry.setSize(restoredNormalGeometry
7572 .expandedTo(d_func()->adjustedSize()));
7575 const QRect availableGeometry = restoredScreen ? restoredScreen->availableGeometry()
7583 QWidgetPrivate::checkRestoredGeometry(availableGeometry, &restoredGeometry, frameHeight);
7584 QWidgetPrivate::checkRestoredGeometry(availableGeometry, &restoredNormalGeometry, frameHeight);
7586 if (maximized || fullScreen) {
7589 Qt::WindowStates ws = windowState();
7591 setGeometry(restoredNormalGeometry);
7593 if (ws & Qt::WindowFullScreen) {
7595 move(availableGeometry.topLeft());
7596 }
else if (ws & Qt::WindowMaximized) {
7600 if (restoredScreen != screen()) {
7601 setWindowState(Qt::WindowNoState);
7602 setGeometry(restoredNormalGeometry);
7605 setGeometry(restoredNormalGeometry);
7609 ws |= Qt::WindowMaximized;
7611 ws |= Qt::WindowFullScreen;
7613 d_func()->topData()->normalGeometry = restoredNormalGeometry;
7615 setWindowState(windowState() & ~(Qt::WindowMaximized | Qt::WindowFullScreen));
7618 if (majorVersion > 2)
7619 setGeometry(restoredGeometry);
7621 setGeometry(restoredNormalGeometry);
7724QMargins QWidgetPrivate::safeAreaMargins()
const
7728#if QT_CONFIG(graphicsview)
7731 if (nearestGraphicsProxyWidget(q))
7735 QWidget *nativeWidget = q->window();
7736 if (!nativeWidget->windowHandle())
7739 QMargins safeAreaMargins = nativeWidget->windowHandle()->safeAreaMargins();
7741 if (!q->isWindow()) {
7749 if (safeAreaMargins.isNull())
7756 const QWidget *assumedSafeWidget =
nullptr;
7757 for (
const QWidget *w = q; w != nativeWidget; w = w->parentWidget()) {
7758 QWidget *parentWidget = w->parentWidget();
7759 if (!parentWidget->testAttribute(Qt::WA_ContentsMarginsRespectsSafeArea))
7762 if (parentWidget->testAttribute(Qt::WA_LayoutOnEntireRect))
7765 QLayout *layout = parentWidget->layout();
7769 if (layout->geometry().isNull())
7772 if (layout->indexOf(w) < 0)
7775 assumedSafeWidget = w;
7779#if !defined(QT_DEBUG)
7780 if (assumedSafeWidget) {
7791 QPoint topLeftMargins = q->mapFrom(nativeWidget, QPoint(safeAreaMargins.left(), safeAreaMargins.top()));
7792 QRect widgetRect = q->isVisible() ? q->visibleRegion().boundingRect() : q->rect();
7793 QPoint bottomRightMargins = widgetRect.bottomRight() - q->mapFrom(nativeWidget,
7794 nativeWidget->rect().bottomRight() - QPoint(safeAreaMargins.right(), safeAreaMargins.bottom()));
7797 safeAreaMargins = QMargins(qMax(0, topLeftMargins.x()), qMax(0, topLeftMargins.y()),
7798 qMax(0, bottomRightMargins.x()), qMax(0, bottomRightMargins.y()));
7800 if (!safeAreaMargins.isNull() && assumedSafeWidget) {
7801 QLayout *layout = assumedSafeWidget->parentWidget()->layout();
7802 qWarning() << layout <<
"is laying out" << assumedSafeWidget
7803 <<
"outside of the contents rect of" << layout->parentWidget();
7808 return safeAreaMargins;
8034void QWidgetPrivate::show_helper()
8037 data.in_show =
true;
8039 sendPendingMoveAndResizeEvents();
8042 q->setAttribute(Qt::WA_WState_Visible);
8045 showChildren(
false);
8049 const bool isWindow = q->isWindow();
8050#if QT_CONFIG(graphicsview)
8051 bool isEmbedded = isWindow && q->graphicsProxyWidget() !=
nullptr;
8053 bool isEmbedded =
false;
8059 if (isWindow && !isEmbedded) {
8060 if ((q->windowType() == Qt::Tool) || (q->windowType() == Qt::Popup) || q->windowType() == Qt::ToolTip) {
8062 if (q->parentWidget() && q->parentWidget()->window()->testAttribute(Qt::WA_KeyboardFocusChange))
8063 q->setAttribute(Qt::WA_KeyboardFocusChange);
8065 while (QApplication::activePopupWidget()) {
8066 if (!QApplication::activePopupWidget()->close())
8074#if QT_CONFIG(graphicsview)
8076 if (!isEmbedded && !bypassGraphicsProxyWidget(q)) {
8077 QGraphicsProxyWidget *ancestorProxy = nearestGraphicsProxyWidget(q->parentWidget());
8078 if (ancestorProxy) {
8080 ancestorProxy->d_func()->embedSubWindow(q);
8085 Q_UNUSED(isEmbedded);
8089 QShowEvent showEvent;
8090 QCoreApplication::sendEvent(q, &showEvent);
8094 if (!isEmbedded && q->windowType() == Qt::Popup)
8095 qApp->d_func()->openPopup(q);
8097#if QT_CONFIG(accessibility)
8098 if (q->windowType() != Qt::ToolTip) {
8099 QAccessibleEvent event(q, QAccessible::ObjectShow);
8100 QAccessible::updateAccessibility(&event);
8104 if (QApplicationPrivate::hidden_focus_widget == q) {
8105 QApplicationPrivate::hidden_focus_widget =
nullptr;
8106 q->setFocus(Qt::OtherFocusReason);
8112 if (!
qApp->d_func()->in_exec && q->windowType() == Qt::SplashScreen)
8113 QCoreApplication::processEvents();
8115 data.in_show =
false;
8118void QWidgetPrivate::show_sys()
8122 auto window = qobject_cast<QWidgetWindow *>(windowHandle());
8124 if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
8125 invalidateBackingStore(q->rect());
8126 q->setAttribute(Qt::WA_Mapped);
8128 if (window && q->isWindow()
8129#if QT_CONFIG(graphicsview)
8130 && (!extra || !extra->proxyWidget)
8132 && q->windowModality() != Qt::NonModal) {
8133 QGuiApplicationPrivate::showModalWindow(window);
8138 if (renderToTexture && !q->isWindow())
8139 QCoreApplication::postEvent(q->parentWidget(),
new QUpdateLaterEvent(q->geometry()));
8141 QCoreApplication::postEvent(q,
new QUpdateLaterEvent(q->rect()));
8143 if ((!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow))
8144 || q->testAttribute(Qt::WA_OutsideWSRange)) {
8150 fixPosIncludesFrame();
8151 QRect geomRect = q->geometry();
8152 if (!q->isWindow()) {
8153 QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint());
8154 geomRect.moveTopLeft(topLeftOfWindow);
8156 const QRect windowRect = window->geometry();
8157 if (windowRect != geomRect) {
8158 if (q->testAttribute(Qt::WA_Moved)
8159 || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowManagement))
8160 window->setGeometry(geomRect);
8162 window->resize(geomRect.size());
8166 qt_qpa_set_cursor(q,
false);
8168 invalidateBackingStore(q->rect());
8169 window->setNativeWindowVisibility(
true);
8171 if (window->isTopLevel()) {
8172 const QPoint crectTopLeft = q->data->crect.topLeft();
8173 const QPoint windowTopLeft = window->geometry().topLeft();
8174 if (crectTopLeft == QPoint(0, 0) && windowTopLeft != crectTopLeft)
8175 q->data->crect.moveTopLeft(windowTopLeft);
8334void QWidgetPrivate::setVisible(
bool visible)
8337 qCDebug(lcWidgetShowHide) <<
"Setting visibility of" << q
8338 <<
"with attributes" << WidgetAttributes{q}
8339 <<
"to" << visible <<
"via QWidgetPrivate";
8343 if (!q->isWindow() && q->parentWidget() && q->parentWidget()->isVisible()
8344 && !q->parentWidget()->testAttribute(Qt::WA_WState_Created))
8345 q->parentWidget()->window()->d_func()->createRecursively();
8348 QWidget *pw = q->parentWidget();
8349 if (!q->testAttribute(Qt::WA_WState_Created)
8350 && (q->isWindow() || pw->testAttribute(Qt::WA_WState_Created))) {
8354 bool wasResized = q->testAttribute(Qt::WA_Resized);
8355 Qt::WindowStates initialWindowState = q->windowState();
8358 q->ensurePolished();
8361 bool needUpdateGeometry = !q->isWindow() && q->testAttribute(Qt::WA_WState_Hidden);
8363 q->setAttribute(Qt::WA_WState_Hidden,
false);
8365 if (needUpdateGeometry)
8366 updateGeometry_helper(
true);
8372 if (!q->isWindow()) {
8373 QWidget *parent = q->parentWidget();
8374 while (parent && parent->isVisible() && parent->d_func()->layout && !parent->data->in_show) {
8375 parent->d_func()->layout->activate();
8376 if (parent->isWindow())
8378 parent = parent->parentWidget();
8381 parent->d_func()->setDirtyOpaqueRegion();
8386 && (q->isWindow() || !q->parentWidget()->d_func()->layout)) {
8387 if (q->isWindow()) {
8389 if (q->windowState() != initialWindowState)
8390 q->setWindowState(initialWindowState);
8394 q->setAttribute(Qt::WA_Resized,
false);
8397 q->setAttribute(Qt::WA_KeyboardFocusChange,
false);
8399 if (q->isWindow() || q->parentWidget()->isVisible()) {
8402 qApp->d_func()->sendSyntheticEnterLeave(q);
8405 QEvent showToParentEvent(QEvent::ShowToParent);
8406 QCoreApplication::sendEvent(q, &showToParentEvent);
8408 if (QApplicationPrivate::hidden_focus_widget == q)
8409 QApplicationPrivate::hidden_focus_widget =
nullptr;
8415 if (!q->isWindow() && q->parentWidget())
8416 q->parentWidget()->d_func()->setDirtyOpaqueRegion();
8418 if (!q->testAttribute(Qt::WA_WState_Hidden)) {
8419 q->setAttribute(Qt::WA_WState_Hidden);
8424 if (!q->isWindow() && q->parentWidget()) {
8425 if (q->parentWidget()->d_func()->layout)
8426 q->parentWidget()->d_func()->layout->invalidate();
8427 else if (q->parentWidget()->isVisible())
8428 QCoreApplication::postEvent(q->parentWidget(),
new QEvent(QEvent::LayoutRequest));
8431 QEvent hideToParentEvent(QEvent::HideToParent);
8432 QCoreApplication::sendEvent(q, &hideToParentEvent);
8933bool QWidget::event(QEvent *event)
8939 switch(event->type()) {
8940 case QEvent::TabletPress:
8941 case QEvent::TabletRelease:
8942 case QEvent::TabletMove:
8943 case QEvent::MouseButtonPress:
8944 case QEvent::MouseButtonRelease:
8945 case QEvent::MouseButtonDblClick:
8946 case QEvent::MouseMove:
8947 case QEvent::TouchBegin:
8948 case QEvent::TouchUpdate:
8949 case QEvent::TouchEnd:
8950 case QEvent::TouchCancel:
8951 case QEvent::ContextMenu:
8952 case QEvent::KeyPress:
8953 case QEvent::KeyRelease:
8954#if QT_CONFIG(wheelevent)
8962 switch (event->type()) {
8963 case QEvent::PlatformSurface: {
8965 switch (
static_cast<QPlatformSurfaceEvent*>(event)->surfaceEventType()) {
8966 case QPlatformSurfaceEvent::SurfaceCreated:
8967 if (!testAttribute(Qt::WA_WState_Created))
8970 case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
8971 if (testAttribute(Qt::WA_WState_Created)) {
8974 destroy(
false,
false);
8980 case QEvent::MouseMove:
8981 mouseMoveEvent((QMouseEvent*)event);
8984 case QEvent::MouseButtonPress:
8985 mousePressEvent((QMouseEvent*)event);
8988 case QEvent::MouseButtonRelease:
8989 mouseReleaseEvent((QMouseEvent*)event);
8992 case QEvent::MouseButtonDblClick:
8993 mouseDoubleClickEvent((QMouseEvent*)event);
8995#if QT_CONFIG(wheelevent)
8997 wheelEvent((QWheelEvent*)event);
9000#if QT_CONFIG(tabletevent)
9001 case QEvent::TabletMove:
9002 if (
static_cast<QTabletEvent *>(event)->buttons() == Qt::NoButton && !testAttribute(Qt::WA_TabletTracking))
9005 case QEvent::TabletPress:
9006 case QEvent::TabletRelease:
9007 tabletEvent((QTabletEvent*)event);
9010 case QEvent::KeyPress: {
9011 QKeyEvent *k =
static_cast<QKeyEvent *>(event);
9013 if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) {
9014 if (k->key() == Qt::Key_Backtab
9015 || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier)))
9016 res = focusNextPrevChild(
false);
9017 else if (k->key() == Qt::Key_Tab)
9018 res = focusNextPrevChild(
true);
9023#if QT_CONFIG(whatsthis)
9024 if (!k->isAccepted()
9025 && k->modifiers() & Qt::ShiftModifier && k->key() == Qt::Key_F1
9026 && d->whatsThis.size()) {
9027 QWhatsThis::showText(mapToGlobal(inputMethodQuery(Qt::ImCursorRectangle).toRect().center()), d->whatsThis,
this);
9034 case QEvent::KeyRelease:
9035 keyReleaseEvent((QKeyEvent*)event);
9037 case QEvent::ShortcutOverride:
9040 case QEvent::InputMethod:
9041 inputMethodEvent((QInputMethodEvent *) event);
9044 case QEvent::InputMethodQuery: {
9045 QInputMethodQueryEvent *query =
static_cast<QInputMethodQueryEvent *>(event);
9046 Qt::InputMethodQueries queries = query->queries();
9047 for (uint i = 0; i < 32; ++i) {
9048 Qt::InputMethodQuery q = (Qt::InputMethodQuery)(
int)(queries & (1<<i));
9050 QVariant v = inputMethodQuery(q);
9051 if (q == Qt::ImEnabled && !v.isValid() && isEnabled()) {
9058 v = QVariant(testAttribute(Qt::WA_InputMethodEnabled));
9060 query->setValue(q, v);
9067 case QEvent::PolishRequest:
9071 case QEvent::Polish: {
9072 style()->polish(
this);
9073 setAttribute(Qt::WA_WState_Polished);
9074 if (!QApplication::font(
this).isCopyOf(QApplication::font()))
9076 if (!QApplication::palette(
this).isCopyOf(QGuiApplication::palette()))
9077 d->resolvePalette();
9081 case QEvent::ApplicationWindowIconChange:
9082 if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon)) {
9083 d->setWindowIcon_sys();
9084 d->setWindowIcon_helper();
9087 case QEvent::FocusIn:
9088 focusInEvent((QFocusEvent*)event);
9089 d->updateWidgetTransform(event);
9092 case QEvent::FocusOut:
9093 focusOutEvent((QFocusEvent*)event);
9097#if QT_CONFIG(statustip)
9098 if (d->statusTip.size()) {
9099 QStatusTipEvent tip(d->statusTip);
9100 QCoreApplication::sendEvent(
const_cast<QWidget *>(
this), &tip);
9103 enterEvent(
static_cast<QEnterEvent*>(event));
9107#if QT_CONFIG(statustip)
9108 if (d->statusTip.size()) {
9110 QStatusTipEvent tip(empty);
9111 QCoreApplication::sendEvent(
const_cast<QWidget *>(
this), &tip);
9117 case QEvent::HoverEnter:
9118 case QEvent::HoverLeave:
9126 paintEvent((QPaintEvent*)event);
9130 moveEvent((QMoveEvent*)event);
9131 d->updateWidgetTransform(event);
9134 case QEvent::Resize:
9135 resizeEvent((QResizeEvent*)event);
9136 d->updateWidgetTransform(event);
9140 closeEvent((QCloseEvent *)event);
9143#ifndef QT_NO_CONTEXTMENU
9144 case QEvent::ContextMenu:
9145 switch (data->context_menu_policy) {
9146 case Qt::PreventContextMenu:
9148 case Qt::DefaultContextMenu:
9149 contextMenuEvent(
static_cast<QContextMenuEvent *>(event));
9151 case Qt::CustomContextMenu:
9152 emit customContextMenuRequested(
static_cast<QContextMenuEvent *>(event)->pos());
9155 case Qt::ActionsContextMenu:
9156 if (d->actions.size()) {
9157 QMenu::exec(d->actions,
static_cast<QContextMenuEvent *>(event)->globalPos(),
9170#if QT_CONFIG(draganddrop)
9172 dropEvent((QDropEvent*) event);
9175 case QEvent::DragEnter:
9176 dragEnterEvent((QDragEnterEvent*) event);
9179 case QEvent::DragMove:
9180 dragMoveEvent((QDragMoveEvent*) event);
9183 case QEvent::DragLeave:
9184 dragLeaveEvent((QDragLeaveEvent*) event);
9189 showEvent((QShowEvent*) event);
9193 hideEvent((QHideEvent*) event);
9196 case QEvent::ShowWindowRequest:
9201 case QEvent::ApplicationFontChange:
9204 case QEvent::ApplicationPaletteChange:
9205 d->resolvePalette();
9208 case QEvent::ToolBarChange:
9209 case QEvent::ActivationChange:
9210 case QEvent::EnabledChange:
9211 case QEvent::FontChange:
9212 case QEvent::StyleChange:
9213 case QEvent::PaletteChange:
9214 case QEvent::WindowTitleChange:
9215 case QEvent::IconTextChange:
9216 case QEvent::ModifiedChange:
9217 case QEvent::MouseTrackingChange:
9218 case QEvent::TabletTrackingChange:
9219 case QEvent::ParentChange:
9220 case QEvent::LocaleChange:
9221 case QEvent::MacSizeChange:
9222 case QEvent::ContentsRectChange:
9223 case QEvent::ThemeChange:
9224 case QEvent::ReadOnlyChange:
9228 case QEvent::WindowStateChange: {
9229 const bool wasMinimized =
static_cast<
const QWindowStateChangeEvent *>(event)->oldState() & Qt::WindowMinimized;
9230 if (wasMinimized != isMinimized()) {
9231 QWidget *widget =
const_cast<QWidget *>(
this);
9234 if (!d->childrenShownByExpose) {
9236 d->showChildren(
true);
9237 QShowEvent showEvent;
9238 QCoreApplication::sendSpontaneousEvent(widget, &showEvent);
9240 d->childrenHiddenByWState =
false;
9242 QHideEvent hideEvent;
9243 QCoreApplication::sendSpontaneousEvent(widget, &hideEvent);
9244 d->hideChildren(
true);
9245 d->childrenHiddenByWState =
true;
9247 d->childrenShownByExpose =
false;
9253 case QEvent::WindowActivate:
9254 case QEvent::WindowDeactivate: {
9255 if (isVisible() && !palette().isEqual(QPalette::Active, QPalette::Inactive))
9257 QList<QObject*> childList = d->children;
9258 for (
int i = 0; i < childList.size(); ++i) {
9259 QWidget *w = qobject_cast<QWidget *>(childList.at(i));
9260 if (w && w->isVisible() && !w->isWindow())
9261 QCoreApplication::sendEvent(w, event);
9265 case QEvent::LanguageChange:
9268 QList<QObject*> childList = d->children;
9269 for (
int i = 0; i < childList.size(); ++i) {
9270 QObject *o = childList.at(i);
9272 QCoreApplication::sendEvent(o, event);
9278 case QEvent::ApplicationLayoutDirectionChange:
9279 d->resolveLayoutDirection();
9282 case QEvent::LayoutDirectionChange:
9284 d->layout->invalidate();
9288 case QEvent::UpdateRequest:
9289 d->syncBackingStore();
9291 case QEvent::UpdateLater:
9292 update(
static_cast<QUpdateLaterEvent*>(event)->region());
9294 case QEvent::StyleAnimationUpdate:
9295 if (isVisible() && !window()->isMinimized()) {
9301 case QEvent::WindowBlocked:
9302 case QEvent::WindowUnblocked:
9303 if (!d->children.isEmpty()) {
9304 QWidget *modalWidget = QApplication::activeModalWidget();
9305 for (
int i = 0; i < d->children.size(); ++i) {
9306 QObject *o = d->children.at(i);
9307 if (o && o != modalWidget && o->isWidgetType()) {
9308 QWidget *w =
static_cast<QWidget *>(o);
9311 QCoreApplication::sendEvent(w, event);
9316#if QT_CONFIG(tooltip)
9317 case QEvent::ToolTip:
9318 if (!d->toolTip.isEmpty())
9319 QToolTip::showText(
static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip,
this, QRect(), d->toolTipDuration);
9324#if QT_CONFIG(whatsthis)
9325 case QEvent::WhatsThis:
9326 if (d->whatsThis.size())
9327 QWhatsThis::showText(
static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis,
this);
9331 case QEvent::QueryWhatsThis:
9332 if (d->whatsThis.isEmpty())
9336 case QEvent::EmbeddingControl:
9337 d->topData()->frameStrut.setCoords(0 ,0, 0, 0);
9338 data->fstrut_dirty =
false;
9341 case QEvent::ActionAdded:
9342 case QEvent::ActionRemoved:
9343 case QEvent::ActionChanged:
9344 actionEvent((QActionEvent*)event);
9348 case QEvent::KeyboardLayoutChange:
9353 QList<QObject*> childList = d->children;
9354 for (
int i = 0; i < childList.size(); ++i) {
9355 QWidget *w = qobject_cast<QWidget *>(childList.at(i));
9356 if (w && w->isVisible() && !w->isWindow())
9357 QCoreApplication::sendEvent(w, event);
9361 case QEvent::TouchBegin:
9362 case QEvent::TouchUpdate:
9363 case QEvent::TouchEnd:
9364 case QEvent::TouchCancel:
9369#ifndef QT_NO_GESTURES
9370 case QEvent::Gesture:
9374 case QEvent::ScreenChangeInternal:
9375 if (
const QTLWExtra *te = d->maybeTopData()) {
9376 const QWindow *win = te->window;
9377 d->setWinId((win && win->handle()) ? win->handle()->winId() : 0);
9380 case QEvent::DevicePixelRatioChange:
9381 if (d->data.fnt.d->dpi != logicalDpiY())
9382 d->updateFont(d->data.fnt);
9383 d->renderToTextureReallyDirty = 1;
9385 case QEvent::DynamicPropertyChange: {
9386 const QByteArray &propName =
static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
9387 if (propName.size() == 13 && !qstrncmp(propName,
"_q_customDpi", 12)) {
9388 uint value = property(propName.constData()).toUInt();
9391 const char axis = propName.at(12);
9393 d->extra->customDpiX = value;
9394 else if (axis ==
'Y')
9395 d->extra->customDpiY = value;
9396 d->updateFont(d->data.fnt);
9398 if (windowHandle() && !qstrncmp(propName,
"_q_platform_", 12))
9399 windowHandle()->setProperty(propName, property(propName));
9403 return QObject::event(event);
10715void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
10718 Q_ASSERT_X(
this != parent, Q_FUNC_INFO,
"Cannot parent a QWidget to itself");
10720 const auto checkForParentChildLoops = qScopeGuard([&](){
10722 auto p = parentWidget();
10724 if (++depth == QObjectPrivate::CheckForParentChildLoopsWarnDepth) {
10725 qWarning(
"QWidget %p (class: '%s', object name: '%s') may have a loop in its parent-child chain; "
10726 "this is undefined behavior",
10727 this, metaObject()->className(), qPrintable(objectName()));
10729 p = p->parentWidget();
10734 const bool resized = testAttribute(Qt::WA_Resized);
10735 const bool wasCreated = testAttribute(Qt::WA_WState_Created);
10736 QWidget *oldtlw = window();
10738 QWidget *oldParentWithWindow = d->closestParentWidgetWithWindowHandle();
10740 if (f & Qt::Window)
10741 d->data.fstrut_dirty =
true;
10743 bool newParent = (parent != parentWidget());
10745 if (newParent && parent) {
10746 if (testAttribute(Qt::WA_NativeWindow) && !QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings))
10747 parent->d_func()->enforceNativeChildren();
10748 else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
10749 setAttribute(Qt::WA_NativeWindow);
10753 if (!testAttribute(Qt::WA_WState_Hidden)) {
10768 setAttribute(Qt::WA_WState_ExplicitShowHide,
false);
10771 QEvent e(QEvent::ParentAboutToChange);
10772 QCoreApplication::sendEvent(
this, &e);
10778 const bool oldWidgetUsesRhiFlush = oldParentWithWindow ? oldParentWithWindow->d_func()->usesRhiFlush
10779 : oldtlw->d_func()->usesRhiFlush;
10780 if (oldWidgetUsesRhiFlush && ((!parent && parentWidget()) || (parent && parent->window() != oldtlw)))
10781 qSendWindowChangeToTextureChildrenRecursively(
this, QEvent::WindowAboutToChangeInternal);
10785 if (newParent && isAncestorOf(focusWidget()) && !(f & Qt::Window))
10786 focusWidget()->clearFocus();
10788 d->setParent_sys(parent, f);
10790 if (d->textureChildSeen && parent) {
10792 QWidgetPrivate::get(parent)->setTextureChildSeen();
10795 if (QWidgetRepaintManager *oldPaintManager = oldtlw->d_func()->maybeRepaintManager()) {
10797 oldPaintManager->removeDirtyWidget(
this);
10800 oldPaintManager->moveStaticWidgets(
this);
10803 d->reparentFocusWidgets(oldtlw);
10804 setAttribute(Qt::WA_Resized, resized);
10806 const bool useStyleSheetPropagationInWidgetStyles =
10807 QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
10809 if (!useStyleSheetPropagationInWidgetStyles && !testAttribute(Qt::WA_StyleSheet)
10810 && (!parent || !parent->testAttribute(Qt::WA_StyleSheet))) {
10813 const auto pd = parent->d_func();
10814 d->inheritedFontResolveMask = pd->directFontResolveMask | pd->inheritedFontResolveMask;
10815 d->inheritedPaletteResolveMask = pd->directPaletteResolveMask | pd->inheritedPaletteResolveMask;
10818 d->resolvePalette();
10820 d->resolveLayoutDirection();
10821 d->resolveLocale();
10827 if (newParent || !wasCreated
10828#if QT_CONFIG(opengles2)
10829 || (f & Qt::MSWindowsOwnDC)
10834 if (!testAttribute(Qt::WA_ForceDisabled))
10835 d->setEnabled_helper(parent ? parent->isEnabled() :
true);
10836 if (!testAttribute(Qt::WA_ForceUpdatesDisabled))
10837 d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() :
true);
10842 if (parent && d->sendChildEvents) {
10843 QChildEvent e(QEvent::ChildAdded,
this);
10844 QCoreApplication::sendEvent(parent, &e);
10847 if (parent && d->sendChildEvents && d->polished) {
10848 QChildEvent e(QEvent::ChildPolished,
this);
10849 QCoreApplication::sendEvent(parent, &e);
10852 QEvent e(QEvent::ParentChange);
10853 QCoreApplication::sendEvent(
this, &e);
10858 if (oldWidgetUsesRhiFlush && oldtlw != window())
10859 qSendWindowChangeToTextureChildrenRecursively(
this, QEvent::WindowChangeInternal);
10862 if (isWindow() || parentWidget()->isVisible())
10863 setAttribute(Qt::WA_WState_Hidden,
true);
10864 else if (!testAttribute(Qt::WA_WState_ExplicitShowHide))
10865 setAttribute(Qt::WA_WState_Hidden,
false);
10868 d->updateIsOpaque();
10870#if QT_CONFIG(graphicsview)
10873 if (oldtlw->graphicsProxyWidget()) {
10874 if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(oldtlw))
10875 ancestorProxy->d_func()->unembedSubWindow(
this);
10877 if (isWindow() && parent && !graphicsProxyWidget() && !bypassGraphicsProxyWidget(
this)) {
10878 if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(parent))
10879 ancestorProxy->d_func()->embedSubWindow(
this);
10883 if (d->extra && d->extra->hasWindowContainer)
10884 QWindowContainer::parentWasChanged(
this);
10886 QWidget *newParentWithWindow = d->closestParentWidgetWithWindowHandle();
10887 if (newParentWithWindow && newParentWithWindow != oldParentWithWindow) {
10889 qCDebug(lcWidgetPainting) <<
"Evaluating whether reparenting of" <<
this
10890 <<
"into" << parent <<
"requires RHI enablement for" << newParentWithWindow;
10892 QPlatformBackingStoreRhiConfig rhiConfig;
10893 QSurface::SurfaceType surfaceType = QSurface::RasterSurface;
10899 if (q_evaluateRhiConfig(
this, &rhiConfig, &surfaceType)) {
10903 if (q_evaluateRhiConfig(newParentWithWindow,
nullptr,
nullptr)) {
10906 auto *existingWindow = newParentWithWindow->windowHandle();
10907 auto existingSurfaceType = existingWindow->surfaceType();
10908 if (existingSurfaceType != surfaceType) {
10909 qCDebug(lcWidgetPainting)
10910 <<
"Recreating" << existingWindow
10911 <<
"with current type" << existingSurfaceType
10912 <<
"to support" << surfaceType;
10913 const auto windowStateBeforeDestroy = newParentWithWindow->windowState();
10914 const auto visibilityBeforeDestroy = newParentWithWindow->isVisible();
10915 const auto positionBeforeDestroy = newParentWithWindow->pos();
10916 newParentWithWindow->d_func()->recreate();
10917 Q_ASSERT(newParentWithWindow->windowHandle());
10918 newParentWithWindow->windowHandle()->setWindowStates(windowStateBeforeDestroy);
10919 newParentWithWindow->move(positionBeforeDestroy);
10920 QWidgetPrivate::get(newParentWithWindow)->setVisible(visibilityBeforeDestroy);
10921 }
else if (
auto *backingStore = newParentWithWindow->backingStore()) {
10924 backingStore->handle()->createRhi(existingWindow, rhiConfig);
10926 QWidgetPrivate::get(newParentWithWindow)->usesRhiFlush =
true;
10932#if QT_CONFIG(accessibility)
10933 if (QGuiApplicationPrivate::is_app_running && !QGuiApplicationPrivate::is_app_closing) {
10934 QAccessibleEvent qaEvent(
this, QAccessible::ParentChanged);
10935 QAccessible::updateAccessibility(&qaEvent);
10941void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
10945 Qt::WindowFlags oldFlags = data.window_flags;
10946 bool wasCreated = q->testAttribute(Qt::WA_WState_Created);
10948 QScreen *targetScreen =
nullptr;
10954 targetScreen = q->parentWidget()->window()->screen();
10957 const bool destroyWindow = (
10959 (oldFlags & Qt::Window) && !(f & Qt::Window)
10961 && wasCreated && !q->testAttribute(Qt::WA_NativeWindow)
10964 if (parent != newparent) {
10966 QObjectPrivate::setParent_helper(newparent);
10968 if (q->windowHandle())
10969 q->windowHandle()->setFlags(f);
10973 QWidget *parentWithWindow = closestParentWidgetWithWindowHandle();
10976 if (destroyWindow) {
10977 reparentWidgetWindowChildren(parentWithWindow);
10987 reparentWidgetWindows(parentWithWindow, f);
10991 bool explicitlyHidden = isExplicitlyHidden();
10993 if (destroyWindow) {
10994 if (extra && extra->hasWindowContainer)
10995 QWindowContainer::toplevelAboutToBeDestroyed(q);
10999 if (!q->windowHandle()->children().isEmpty()) {
11000 QWidget *parentWithWindow = closestParentWidgetWithWindowHandle();
11001 QWindow *newParentWindow = parentWithWindow ? parentWithWindow->windowHandle() :
nullptr;
11002 for (QObject *child : q->windowHandle()->children()) {
11003 if (QWindow *childWindow = qobject_cast<QWindow *>(child)) {
11004 qCWarning(lcWidgetWindow) <<
"Reparenting" << childWindow
11005 <<
"before destroying" <<
this;
11006 childWindow->setParent(newParentWindow);
11014 q->destroy(
true,
false);
11018 data.window_flags = f;
11019 q->setAttribute(Qt::WA_WState_Created,
false);
11020 q->setAttribute(Qt::WA_WState_Visible,
false);
11021 q->setAttribute(Qt::WA_WState_Hidden,
false);
11023 if (newparent && wasCreated && (q->testAttribute(Qt::WA_NativeWindow) || (f & Qt::Window)))
11026 if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
11027 q->setAttribute(Qt::WA_WState_Hidden);
11028 q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
11031 if (!newparent && targetScreen) {
11033 if (q->testAttribute(Qt::WA_WState_Created))
11034 q->windowHandle()->setScreen(targetScreen);
11036 topData()->initialScreen = targetScreen;
11375void QWidget::setAttribute(Qt::WidgetAttribute attribute,
bool on)
11379 if (attribute == Qt::WA_ContentsMarginsRespectsSafeArea) {
11381 auto *topExtra = d->topData();
11382 topExtra->explicitContentsMarginsRespectsSafeArea =
true;
11386 if (testAttribute(attribute) == on)
11389 static_assert(
sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount -
sizeof(uint)*8),
11390 "QWidget::setAttribute(WidgetAttribute, bool): "
11391 "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
11394 if (attribute == Qt::WA_PaintOnScreen && on && !inherits(
"QGLWidget")) {
11397 if (d->noPaintOnScreen)
11403 if (attribute == Qt::WA_NativeWindow && !d->mustHaveWindowHandle) {
11404 QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();
11405 if (!platformIntegration->hasCapability(QPlatformIntegration::NativeWidgets))
11409 setAttribute_internal(attribute, on, data, d);
11411 switch (attribute) {
11413#if QT_CONFIG(draganddrop)
11414 case Qt::WA_AcceptDrops: {
11415 if (on && !testAttribute(Qt::WA_DropSiteRegistered))
11416 setAttribute(Qt::WA_DropSiteRegistered,
true);
11417 else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)))
11418 setAttribute(Qt::WA_DropSiteRegistered,
false);
11419 QEvent e(QEvent::AcceptDropsChange);
11420 QCoreApplication::sendEvent(
this, &e);
11423 case Qt::WA_DropSiteRegistered: {
11424 for (
int i = 0; i < d->children.size(); ++i) {
11425 QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
11426 if (w && !w->isWindow() && !w->testAttribute(Qt::WA_AcceptDrops) && w->testAttribute(Qt::WA_DropSiteRegistered) != on)
11427 w->setAttribute(Qt::WA_DropSiteRegistered, on);
11433 case Qt::WA_NoChildEventsForParent:
11434 d->sendChildEvents = !on;
11436 case Qt::WA_NoChildEventsFromChildren:
11437 d->receiveChildEvents = !on;
11439 case Qt::WA_MacNormalSize:
11440 case Qt::WA_MacSmallSize:
11441 case Qt::WA_MacMiniSize:
11445 const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize,
11446 Qt::WA_MacMiniSize };
11447 for (
int i = 0; i < 3; ++i) {
11448 if (MacSizes[i] != attribute)
11449 setAttribute_internal(MacSizes[i],
false, data, d);
11451 d->macUpdateSizeAttribute();
11455 case Qt::WA_ShowModal:
11458 data->window_modality = Qt::NonModal;
11459 }
else if (data->window_modality == Qt::NonModal) {
11462 data->window_modality = Qt::ApplicationModal;
11467 if (testAttribute(Qt::WA_WState_Created)) {
11472 case Qt::WA_MouseTracking: {
11473 QEvent e(QEvent::MouseTrackingChange);
11474 QCoreApplication::sendEvent(
this, &e);
11476 case Qt::WA_TabletTracking: {
11477 QEvent e(QEvent::TabletTrackingChange);
11478 QCoreApplication::sendEvent(
this, &e);
11480 case Qt::WA_NativeWindow: {
11481 d->createTLExtra();
11483 d->createTLSysExtra();
11485 QWidget *focusWidget = d->effectiveFocusWidget();
11486 if (on && !internalWinId() &&
this == QGuiApplication::focusObject()
11487 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
11488 QGuiApplication::inputMethod()->commit();
11489 QGuiApplication::inputMethod()->update(Qt::ImEnabled);
11491 if (!QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
11492 parentWidget()->d_func()->enforceNativeChildren();
11493 if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
11495 if (isEnabled() && focusWidget->isEnabled() &&
this == QGuiApplication::focusObject()
11496 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
11497 QGuiApplication::inputMethod()->update(Qt::ImEnabled);
11502 case Qt::WA_PaintOnScreen:
11503 d->updateIsOpaque();
11505 case Qt::WA_OpaquePaintEvent:
11506 d->updateIsOpaque();
11508 case Qt::WA_NoSystemBackground:
11509 d->updateIsOpaque();
11511 case Qt::WA_UpdatesDisabled:
11512 d->updateSystemBackground();
11514 case Qt::WA_TransparentForMouseEvents:
11516 case Qt::WA_InputMethodEnabled: {
11518 if (QGuiApplication::focusObject() ==
this) {
11520 QGuiApplication::inputMethod()->commit();
11521 QGuiApplication::inputMethod()->update(Qt::ImEnabled);
11526 case Qt::WA_WindowPropagation:
11527 d->resolvePalette();
11529 d->resolveLocale();
11531 case Qt::WA_DontShowOnScreen: {
11532 if (on && isVisible()) {
11542 case Qt::WA_X11NetWmWindowTypeDesktop:
11543 case Qt::WA_X11NetWmWindowTypeDock:
11544 case Qt::WA_X11NetWmWindowTypeToolBar:
11545 case Qt::WA_X11NetWmWindowTypeMenu:
11546 case Qt::WA_X11NetWmWindowTypeUtility:
11547 case Qt::WA_X11NetWmWindowTypeSplash:
11548 case Qt::WA_X11NetWmWindowTypeDialog:
11549 case Qt::WA_X11NetWmWindowTypeDropDownMenu:
11550 case Qt::WA_X11NetWmWindowTypePopupMenu:
11551 case Qt::WA_X11NetWmWindowTypeToolTip:
11552 case Qt::WA_X11NetWmWindowTypeNotification:
11553 case Qt::WA_X11NetWmWindowTypeCombo:
11554 case Qt::WA_X11NetWmWindowTypeDND:
11555 d->setNetWmWindowTypes();
11558 case Qt::WA_StaticContents:
11559 if (QWidgetRepaintManager *repaintManager = d->maybeRepaintManager()) {
11561 repaintManager->addStaticWidget(
this);
11563 repaintManager->removeStaticWidget(
this);
11566 case Qt::WA_TranslucentBackground:
11568 setAttribute(Qt::WA_NoSystemBackground);
11569 d->updateIsTranslucent();
11572 case Qt::WA_AcceptTouchEvents:
13158void QWidgetPrivate::setNetWmWindowTypes(
bool skipIfMissing)
13163 if (!q->windowHandle())
13166 QXcbWindow::WindowTypes wmWindowType = QXcbWindow::None;
13167 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDesktop))
13168 wmWindowType |= QXcbWindow::Desktop;
13169 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock))
13170 wmWindowType |= QXcbWindow::Dock;
13171 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolBar))
13172 wmWindowType |= QXcbWindow::Toolbar;
13173 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeMenu))
13174 wmWindowType |= QXcbWindow::Menu;
13175 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeUtility))
13176 wmWindowType |= QXcbWindow::Utility;
13177 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeSplash))
13178 wmWindowType |= QXcbWindow::Splash;
13179 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDialog))
13180 wmWindowType |= QXcbWindow::Dialog;
13181 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu))
13182 wmWindowType |= QXcbWindow::DropDownMenu;
13183 if (q->testAttribute(Qt::WA_X11NetWmWindowTypePopupMenu))
13184 wmWindowType |= QXcbWindow::PopupMenu;
13185 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolTip))
13186 wmWindowType |= QXcbWindow::Tooltip;
13187 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeNotification))
13188 wmWindowType |= QXcbWindow::Notification;
13189 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeCombo))
13190 wmWindowType |= QXcbWindow::Combo;
13191 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDND))
13192 wmWindowType |= QXcbWindow::Dnd;
13194 if (wmWindowType == QXcbWindow::None && skipIfMissing)
13197 if (
auto *xcbWindow =
dynamic_cast<QXcbWindow*>(q->windowHandle()->handle()))
13198 xcbWindow->setWindowType(wmWindowType);
13200 Q_UNUSED(skipIfMissing);