4804void QWidgetPrivate::updateFont(
const QFont &font)
4807#if QT_CONFIG(style_stylesheet)
4808 const QStyleSheetStyle* cssStyle;
4809 cssStyle = extra ? qt_styleSheet(extra->style) :
nullptr;
4810 const bool useStyleSheetPropagationInWidgetStyles =
4811 QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
4814 data.fnt = QFont(font, q);
4817#if QT_CONFIG(graphicsview)
4818 if (!q->parentWidget() && extra && extra->proxyWidget) {
4819 QGraphicsProxyWidget *p = extra->proxyWidget;
4820 inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolveMask();
4823 if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
4824 inheritedFontResolveMask = 0;
4826 uint newMask = data.fnt.resolveMask() | inheritedFontResolveMask;
4830 directFontResolveMask = data.fnt.resolveMask();
4831 data.fnt.setResolveMask(newMask);
4833 for (
int i = 0; i < children.size(); ++i) {
4834 QWidget *w = qobject_cast<QWidget*>(children.at(i));
4837#if QT_CONFIG(style_stylesheet)
4838 }
else if (!useStyleSheetPropagationInWidgetStyles && w->testAttribute(Qt::WA_StyleSheet)) {
4841 cssStyle->updateStyleSheetFont(w);
4843 }
else if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {
4845 QWidgetPrivate *wd = w->d_func();
4846 wd->inheritedFontResolveMask = newMask;
4852#if QT_CONFIG(style_stylesheet)
4853 if (!useStyleSheetPropagationInWidgetStyles && cssStyle) {
4854 cssStyle->updateStyleSheetFont(q);
4858 QEvent e(QEvent::FontChange);
4859 QCoreApplication::sendEvent(q, &e);
5139void QWidget::render(QPainter *painter,
const QPoint &targetOffset,
5140 const QRegion &sourceRegion, RenderFlags renderFlags)
5142 if (Q_UNLIKELY(!painter)) {
5143 qWarning(
"QWidget::render: Null pointer to painter");
5147 if (Q_UNLIKELY(!painter->isActive())) {
5148 qWarning(
"QWidget::render: Cannot render with an inactive painter");
5152 const qreal opacity = painter->opacity();
5153 if (qFuzzyIsNull(opacity))
5157 const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;
5158 const QRegion toBePainted = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)
5160 if (toBePainted.isEmpty())
5165 d->extra->inRenderWithPainter =
true;
5167 QPaintEngine *engine = painter->paintEngine();
5169 QPaintEnginePrivate *enginePriv = engine->d_func();
5170 Q_ASSERT(enginePriv);
5171 QPaintDevice *target = engine->paintDevice();
5175 if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) {
5176 d->render_helper(painter, targetOffset, toBePainted, renderFlags);
5177 d->extra->inRenderWithPainter = inRenderWithPainter;
5182 QPainter *oldPainter = d->sharedPainter();
5183 d->setSharedPainter(painter);
5186 const QTransform oldTransform = enginePriv->systemTransform;
5187 const QRegion oldSystemClip = enginePriv->systemClip;
5188 const QRegion oldBaseClip = enginePriv->baseSystemClip;
5189 const QRegion oldSystemViewport = enginePriv->systemViewport;
5190 const Qt::LayoutDirection oldLayoutDirection = painter->layoutDirection();
5193 if (painter->hasClipping()) {
5194 const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion());
5195 enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip);
5197 enginePriv->setSystemViewport(oldSystemClip);
5199 painter->setLayoutDirection(layoutDirection());
5201 d->render(target, targetOffset, toBePainted, renderFlags);
5204 enginePriv->baseSystemClip = oldBaseClip;
5205 enginePriv->setSystemTransformAndViewport(oldTransform, oldSystemViewport);
5206 enginePriv->systemStateChanged();
5207 painter->setLayoutDirection(oldLayoutDirection);
5210 d->setSharedPainter(oldPainter);
5212 d->extra->inRenderWithPainter = inRenderWithPainter;
5353QRegion QWidgetPrivate::prepareToRender(
const QRegion ®ion, QWidget::RenderFlags renderFlags)
5356 const bool isVisible = q->isVisible();
5359 if (!isVisible && !isAboutToShow()) {
5360 QWidget *topLevel = q->window();
5361 (
void)topLevel->d_func()->topData();
5362 topLevel->ensurePolished();
5366 QWidget *widget = q;
5367 QWidgetList hiddenWidgets;
5369 if (widget->isHidden()) {
5370 widget->setAttribute(Qt::WA_WState_Hidden,
false);
5371 hiddenWidgets.append(widget);
5372 if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
5373 widget->d_func()->updateGeometry_helper(
true);
5375 widget = widget->parentWidget();
5379 if (topLevel->d_func()->layout)
5380 topLevel->d_func()->layout->activate();
5383 QTLWExtra *topLevelExtra = topLevel->d_func()->maybeTopData();
5384 if (topLevelExtra && !topLevelExtra->sizeAdjusted
5385 && !topLevel->testAttribute(Qt::WA_Resized)) {
5386 topLevel->adjustSize();
5387 topLevel->setAttribute(Qt::WA_Resized,
false);
5391 topLevel->d_func()->activateChildLayoutsRecursively();
5394 for (
int i = 0; i < hiddenWidgets.size(); ++i) {
5395 QWidget *widget = hiddenWidgets.at(i);
5396 widget->setAttribute(Qt::WA_WState_Hidden);
5397 if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
5398 widget->parentWidget()->d_func()->layout->invalidate();
5400 }
else if (isVisible) {
5401 q->window()->d_func()->sendPendingMoveAndResizeEvents(
true,
true);
5405 QRegion toBePainted = !region.isEmpty() ? region : QRegion(q->rect());
5406 if (!(renderFlags & QWidget::IgnoreMask) && extra && extra->hasMask)
5407 toBePainted &= extra->mask;
5411void QWidgetPrivate::render_helper(QPainter *painter,
const QPoint &targetOffset,
const QRegion &toBePainted,
5412 QWidget::RenderFlags renderFlags)
5415 Q_ASSERT(!toBePainted.isEmpty());
5418 const QTransform originalTransform = painter->worldTransform();
5419 const bool useDeviceCoordinates = originalTransform.isScaling();
5420 if (!useDeviceCoordinates) {
5422 const QRect rect = toBePainted.boundingRect();
5423 const QSize size = rect.size();
5427 const qreal pixmapDevicePixelRatio = painter->device()->devicePixelRatio();
5428 QPixmap pixmap(size * pixmapDevicePixelRatio);
5429 pixmap.setDevicePixelRatio(pixmapDevicePixelRatio);
5431 if (!(renderFlags & QWidget::DrawWindowBackground) || !isOpaque)
5432 pixmap.fill(Qt::transparent);
5433 q->render(&pixmap, QPoint(), toBePainted, renderFlags);
5435 const bool restore = !(painter->renderHints() & QPainter::SmoothPixmapTransform);
5436 painter->setRenderHints(QPainter::SmoothPixmapTransform,
true);
5438 painter->drawPixmap(targetOffset, pixmap);
5441 painter->setRenderHints(QPainter::SmoothPixmapTransform,
false);
5445 QTransform transform = originalTransform;
5446 transform.translate(targetOffset.x(), targetOffset.y());
5448 QPaintDevice *device = painter->device();
5452 const QRectF rect(toBePainted.boundingRect());
5453 QRect deviceRect = transform.mapRect(QRectF(0, 0, rect.width(), rect.height())).toAlignedRect();
5454 deviceRect &= QRect(0, 0, device->width(), device->height());
5456 QPixmap pixmap(deviceRect.size());
5457 pixmap.fill(Qt::transparent);
5460 QPainter pixmapPainter(&pixmap);
5461 pixmapPainter.setRenderHints(painter->renderHints());
5462 transform *= QTransform::fromTranslate(-deviceRect.x(), -deviceRect.y());
5463 pixmapPainter.setTransform(transform);
5465 q->render(&pixmapPainter, QPoint(), toBePainted, renderFlags);
5466 pixmapPainter.end();
5469 painter->setTransform(QTransform());
5470 painter->drawPixmap(deviceRect.topLeft(), pixmap);
5471 painter->setTransform(originalTransform);
5475void QWidgetPrivate::drawWidget(QPaintDevice *pdev,
const QRegion &rgn,
const QPoint &offset, DrawWidgetFlags flags,
5476 QPainter *sharedPainter, QWidgetRepaintManager *repaintManager)
5483 qCInfo(lcWidgetPainting) <<
"Drawing" << rgn <<
"of" << q <<
"at" << offset
5484 <<
"into paint device" << pdev <<
"with" << flags;
5486 const bool asRoot = flags & DrawAsRoot;
5487 bool onScreen = shouldPaintOnScreen();
5489#if QT_CONFIG(graphicseffect)
5490 if (graphicsEffect && graphicsEffect->isEnabled()) {
5491 QGraphicsEffectSource *source = graphicsEffect->d_func()->source;
5492 QWidgetEffectSourcePrivate *sourced =
static_cast<QWidgetEffectSourcePrivate *>
5494 if (!sourced->context) {
5495 const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
5496 QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
5497 sourced->context = &context;
5498 if (!sharedPainter) {
5499 setSystemClip(pdev->paintEngine(), pdev->devicePixelRatio(), effectRgn.translated(offset));
5501 p.translate(offset);
5502 context.painter = &p;
5503 graphicsEffect->draw(&p);
5504 setSystemClip(pdev->paintEngine(), 1, QRegion());
5506 context.painter = sharedPainter;
5507 if (sharedPainter->worldTransform() != sourced->lastEffectTransform) {
5508 sourced->invalidateCache();
5509 sourced->lastEffectTransform = sharedPainter->worldTransform();
5511 sharedPainter->save();
5512 sharedPainter->translate(offset);
5513 setSystemClip(sharedPainter->paintEngine(), sharedPainter->device()->devicePixelRatio(), effectRgn.translated(offset));
5514 graphicsEffect->draw(sharedPainter);
5515 setSystemClip(sharedPainter->paintEngine(), 1, QRegion());
5516 sharedPainter->restore();
5518 sourced->context =
nullptr;
5521 repaintManager->markNeedsFlush(q, effectRgn, offset);
5527 flags = flags & ~UseEffectRegionBounds;
5529 const bool alsoOnScreen = flags & DrawPaintOnScreen;
5530 const bool recursive = flags & DrawRecursive;
5531 const bool alsoInvisible = flags & DrawInvisible;
5533 Q_ASSERT(sharedPainter ? sharedPainter->isActive() :
true);
5535 QRegion toBePainted(rgn);
5536 if (asRoot && !alsoInvisible)
5537 toBePainted &= clipRect();
5538 if (!(flags & DontSubtractOpaqueChildren))
5539 subtractOpaqueChildren(toBePainted, q->rect());
5541 if (!toBePainted.isEmpty()) {
5542 if (!onScreen || alsoOnScreen) {
5544 if (Q_UNLIKELY(q->testAttribute(Qt::WA_WState_InPaintEvent)))
5545 qWarning(
"QWidget::repaint: Recursive repaint detected");
5546 q->setAttribute(Qt::WA_WState_InPaintEvent);
5549 QPaintEngine *paintEngine = pdev->paintEngine();
5551 setRedirected(pdev, -offset);
5554 setSystemClip(pdev->paintEngine(), pdev->devicePixelRatio(), toBePainted);
5556 paintEngine->d_func()->systemRect = q->data->crect;
5559 if ((asRoot || q->autoFillBackground() || onScreen || q->testAttribute(Qt::WA_StyledBackground))
5560 && !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {
5561 beginBackingStorePainting();
5563 p.setRenderHint(QPainter::SmoothPixmapTransform);
5564 paintBackground(&p, toBePainted, (asRoot || onScreen) ? (flags | DrawAsRoot) : DrawWidgetFlags());
5565 endBackingStorePainting();
5569 setSystemClip(pdev->paintEngine(), pdev->devicePixelRatio(), toBePainted.translated(offset));
5571 if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) {
5572 beginBackingStorePainting();
5574 QColor tint = q->palette().window().color();
5575 tint.setAlphaF(.6f);
5576 p.fillRect(toBePainted.boundingRect(), tint);
5577 endBackingStorePainting();
5582 qDebug() <<
"painting" << q <<
"opaque ==" << isOpaque();
5583 qDebug() <<
"clipping to" << toBePainted <<
"location == " << offset
5584 <<
"geometry ==" << QRect(q->mapTo(q->window(), QPoint(0, 0)), q->size());
5587 bool skipPaintEvent =
false;
5588 if (renderToTexture) {
5591 beginBackingStorePainting();
5592 if (!q->testAttribute(Qt::WA_AlwaysStackOnTop) && repaintManager) {
5594 p.setCompositionMode(QPainter::CompositionMode_Source);
5595 p.fillRect(q->rect(), Qt::transparent);
5596 }
else if (!repaintManager) {
5598 QImage img = grabFramebuffer();
5601 if (img.format() == QImage::Format_RGB32)
5602 img.reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied);
5604 p.drawImage(q->rect(), img);
5605 skipPaintEvent =
true;
5607 endBackingStorePainting();
5608 if (renderToTextureReallyDirty)
5609 renderToTextureReallyDirty = 0;
5611 skipPaintEvent =
true;
5614 if (!skipPaintEvent) {
5616 sendPaintEvent(toBePainted);
5620 repaintManager->markNeedsFlush(q, toBePainted, offset);
5624 restoreRedirected();
5626 paintEngine->d_func()->systemRect = QRect();
5628 paintEngine->d_func()->currentClipDevice =
nullptr;
5630 setSystemClip(pdev->paintEngine(), 1, QRegion());
5632 q->setAttribute(Qt::WA_WState_InPaintEvent,
false);
5633 if (Q_UNLIKELY(q->paintingActive()))
5634 qWarning(
"QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
5636 if (paintEngine && paintEngine->autoDestruct()) {
5639 }
else if (q->isWindow()) {
5640 QPaintEngine *engine = pdev->paintEngine();
5643 p.setClipRegion(toBePainted);
5644 const QBrush bg = q->palette().brush(QPalette::Window);
5645 if (bg.style() == Qt::TexturePattern)
5646 p.drawTiledPixmap(q->rect(), bg.texture());
5648 p.fillRect(q->rect(), bg);
5650 if (engine->autoDestruct())
5656 if (recursive && !children.isEmpty()) {
5657 paintSiblingsRecursive(pdev, children, children.size() - 1, rgn, offset, flags & ~DrawAsRoot,
5658 sharedPainter, repaintManager);
5672void QWidgetPrivate::render(QPaintDevice *target,
const QPoint &targetOffset,
5673 const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
5675 if (Q_UNLIKELY(!target)) {
5676 qWarning(
"QWidget::render: null pointer to paint device");
5680 const bool inRenderWithPainter = extra && extra->inRenderWithPainter;
5681 QRegion paintRegion = !inRenderWithPainter
5682 ? prepareToRender(sourceRegion, renderFlags)
5684 if (paintRegion.isEmpty())
5687 QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() :
nullptr;
5691 if (target->devType() == QInternal::Widget) {
5692 QWidgetPrivate *targetPrivate =
static_cast<QWidget *>(target)->d_func();
5693 if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) {
5694 QPainter *targetPainter = targetPrivate->sharedPainter();
5695 if (targetPainter && targetPainter->isActive())
5696 setSharedPainter(targetPainter);
5703 QPoint offset = targetOffset;
5704 offset -= paintRegion.boundingRect().topLeft();
5705 QPoint redirectionOffset;
5706 QPaintDevice *redirected =
nullptr;
5708 if (target->devType() == QInternal::Widget)
5709 redirected =
static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset);
5712 target = redirected;
5713 offset -= redirectionOffset;
5716 if (!inRenderWithPainter) {
5717 if (QPaintEngine *targetEngine = target->paintEngine()) {
5718 const QRegion targetSystemClip = targetEngine->systemClip();
5719 if (!targetSystemClip.isEmpty())
5720 paintRegion &= targetSystemClip.translated(-offset);
5725 DrawWidgetFlags flags = DrawPaintOnScreen | DrawInvisible;
5726 if (renderFlags & QWidget::DrawWindowBackground)
5727 flags |= DrawAsRoot;
5729 if (renderFlags & QWidget::DrawChildren)
5730 flags |= DrawRecursive;
5732 flags |= DontSubtractOpaqueChildren;
5734 flags |= DontSetCompositionMode;
5737 drawWidget(target, paintRegion, offset, flags, sharedPainter());
5740 if (oldSharedPainter)
5741 setSharedPainter(oldSharedPainter);
5744void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev,
const QObjectList& siblings,
int index,
const QRegion &rgn,
5745 const QPoint &offset, DrawWidgetFlags flags
5746 , QPainter *sharedPainter, QWidgetRepaintManager *repaintManager)
5748 QWidget *w =
nullptr;
5750 bool dirtyBoundingRect =
true;
5751 const bool exludeOpaqueChildren = (flags & DontDrawOpaqueChildren);
5752 const bool excludeNativeChildren = (flags & DontDrawNativeChildren);
5755 QWidget *x = qobject_cast<QWidget*>(siblings.at(index));
5756 if (x && !(exludeOpaqueChildren && x->d_func()->isOpaque) && !x->isHidden() && !x->isWindow()
5757 && !(excludeNativeChildren && x->internalWinId())) {
5758 if (dirtyBoundingRect) {
5759 boundingRect = rgn.boundingRect();
5760 dirtyBoundingRect =
false;
5763 if (qRectIntersects(boundingRect, x->d_func()->effectiveRectFor(x->data->crect))) {
5769 }
while (index >= 0);
5774 QWidgetPrivate *wd = w->d_func();
5775 const QPoint widgetPos(w->data->crect.topLeft());
5776 const bool hasMask = wd->extra && wd->extra->hasMask && !wd->graphicsEffect;
5780 wr -= hasMask ? wd->extra->mask.translated(widgetPos) : w->data->crect;
5781 paintSiblingsRecursive(pdev, siblings, --index, wr, offset, flags,
5782 sharedPainter, repaintManager);
5785 if (w->updatesEnabled()
5786#if QT_CONFIG(graphicsview)
5787 && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget)
5790 QRegion wRegion(rgn);
5791 wRegion &= wd->effectiveRectFor(w->data->crect);
5792 wRegion.translate(-widgetPos);
5794 wRegion &= wd->extra->mask;
5795 wd->drawWidget(pdev, wRegion, offset + widgetPos, flags, sharedPainter, repaintManager);
6547void QWidget::setFocus(Qt::FocusReason reason)
6552 QWidget *f = d_func()->deepestFocusProxy();
6556 if (QApplication::focusWidget() == f)
6559#if QT_CONFIG(graphicsview)
6560 QWidget *previousProxyFocus =
nullptr;
6561 if (
const auto &topData = window()->d_func()->extra) {
6562 if (topData->proxyWidget && topData->proxyWidget->hasFocus()) {
6563 previousProxyFocus = topData->proxyWidget->widget()->focusWidget();
6564 if (previousProxyFocus && previousProxyFocus->focusProxy())
6565 previousProxyFocus = previousProxyFocus->focusProxy();
6566 if (previousProxyFocus == f && !topData->proxyWidget->d_func()->proxyIsGivingFocus)
6572#if QT_CONFIG(graphicsview)
6574 if (
const auto &topData = window()->d_func()->extra) {
6575 if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) {
6576 f->d_func()->updateFocusChild();
6577 topData->proxyWidget->d_func()->focusFromWidgetToProxy = 1;
6578 topData->proxyWidget->setFocus(reason);
6579 topData->proxyWidget->d_func()->focusFromWidgetToProxy = 0;
6584 if (f->isActiveWindow()) {
6585 QWidget *prev = QApplicationPrivate::focus_widget;
6587 if (reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
6588 && prev->testAttribute(Qt::WA_InputMethodEnabled)) {
6589 QGuiApplication::inputMethod()->commit();
6592 if (reason != Qt::NoFocusReason) {
6593 QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, reason);
6594 QCoreApplication::sendEvent(prev, &focusAboutToChange);
6598 f->d_func()->updateFocusChild();
6600 QApplicationPrivate::setFocusWidget(f, reason);
6601#if QT_CONFIG(accessibility)
6603 if (!(f->inherits(
"QMenuBar") || f->inherits(
"QMenu") || f->inherits(
"QMenuItem")))
6605 QAccessibleEvent event(f, QAccessible::Focus);
6606 QAccessible::updateAccessibility(&event);
6609#if QT_CONFIG(graphicsview)
6610 if (
const auto &topData = window()->d_func()->extra) {
6611 if (topData->proxyWidget) {
6612 if (previousProxyFocus && previousProxyFocus != f) {
6614 QFocusEvent event(QEvent::FocusOut, reason);
6615 QPointer<QWidget> that = previousProxyFocus;
6616 QCoreApplication::sendEvent(previousProxyFocus, &event);
6618 QCoreApplication::sendEvent(that->style(), &event);
6621#if QT_CONFIG(graphicsview)
6623 if (
const auto &topData = window()->d_func()->extra)
6624 if (topData->proxyWidget && topData->proxyWidget->hasFocus())
6625 topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget();
6628 QFocusEvent event(QEvent::FocusIn, reason);
6629 QPointer<QWidget> that = f;
6630 QCoreApplication::sendEvent(f, &event);
6632 QCoreApplication::sendEvent(that->style(), &event);
6638 f->d_func()->updateFocusChild();
7032void QWidget::setTabOrder(QWidget* first, QWidget *second)
7034 if (!first || !second || first == second
7035 || first->focusPolicy() == Qt::NoFocus
7036 || second->focusPolicy() == Qt::NoFocus)
7039 if (Q_UNLIKELY(first->window() != second->window())) {
7040 qWarning(
"QWidget::setTabOrder: 'first' and 'second' must be in the same window");
7044 const auto determineLastFocusChild = [](QWidget *target, QWidget *noFurtherThan)
7050 QWidget *lastFocusChild = target;
7052 QWidget *focusProxy = target->d_func()->deepestFocusProxy();
7059 for (
auto *object : target->children()) {
7060 QWidget *w = qobject_cast<QWidget*>(object);
7061 if (w && w->focusProxy() == target) {
7066 }
else if (target->isAncestorOf(focusProxy)) {
7067 lastFocusChild = focusProxy;
7068 for (QWidget *focusNext = lastFocusChild->nextInFocusChain();
7069 focusNext != focusProxy && target->isAncestorOf(focusNext) && focusNext->window() == focusProxy->window();
7070 focusNext = focusNext->nextInFocusChain()) {
7071 if (focusNext == noFurtherThan)
7073 if (focusNext->focusPolicy() != Qt::NoFocus)
7074 lastFocusChild = focusNext;
7077 return lastFocusChild;
7080 QWidget *lastFocusChildOfFirst = determineLastFocusChild(first, second);
7081 if (lastFocusChildOfFirst == second)
7082 lastFocusChildOfFirst = first;
7083 QWidget *lastFocusChildOfSecond = determineLastFocusChild(second, first);
7084 if (lastFocusChildOfSecond == first)
7085 lastFocusChildOfSecond = second;
7088 QWidget *oldPrev = second->previousInFocusChain();
7089 QWidget *prevWithFocus = oldPrev;
7090 while (prevWithFocus->focusPolicy() == Qt::NoFocus)
7091 prevWithFocus = prevWithFocus->previousInFocusChain();
7092 if (prevWithFocus == first)
7094 const QWidgetList chain = QWidgetPrivate::takeFromFocusChain(second, lastFocusChildOfSecond);
7095 QWidgetPrivate::insertIntoFocusChain(chain, QWidgetPrivate::FocusDirection::Next, lastFocusChildOfFirst);
7261void QWidgetPrivate::setGeometry_sys(
int x,
int y,
int w,
int h,
bool isMove)
7265 w = qMin(w,extra->maxw);
7266 h = qMin(h,extra->maxh);
7267 w = qMax(w,extra->minw);
7268 h = qMax(h,extra->minh);
7271 if (q->isWindow() && q->windowHandle()) {
7272 QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration();
7273 if (!integration->hasCapability(QPlatformIntegration::NonFullScreenWindows)) {
7276 w = q->windowHandle()->width();
7277 h = q->windowHandle()->height();
7281 QPoint oldp = q->geometry().topLeft();
7282 QSize olds = q->size();
7283 QRect r(x, y, w, h);
7285 bool isResize = olds != r.size();
7287 isMove = oldp != r.topLeft();
7292 if (r.size() == olds && oldp == r.topLeft())
7295 if (!data.in_set_window_state) {
7296 q->data->window_state &= ~Qt::WindowMaximized;
7297 q->data->window_state &= ~Qt::WindowFullScreen;
7299 topData()->normalGeometry = QRect(0, 0, -1, -1);
7302 QPoint oldPos = q->pos();
7305 bool needsShow =
false;
7307 if (q->isWindow() || q->windowHandle()) {
7308 if (!(data.window_state & Qt::WindowFullScreen) && (w == 0 || h == 0)) {
7309 q->setAttribute(Qt::WA_OutsideWSRange,
true);
7312 data.crect = QRect(x, y, w, h);
7313 }
else if (q->testAttribute(Qt::WA_OutsideWSRange)) {
7314 q->setAttribute(Qt::WA_OutsideWSRange,
false);
7319 if (q->isVisible()) {
7320 if (!q->testAttribute(Qt::WA_DontShowOnScreen) && !q->testAttribute(Qt::WA_OutsideWSRange)) {
7321 if (QWindow *win = q->windowHandle()) {
7322 if (q->isWindow()) {
7323 if (isResize && !isMove)
7325 else if (isMove && !isResize)
7326 win->setPosition(x, y);
7328 win->setGeometry(q->geometry());
7330 QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint());
7331 win->setGeometry(QRect(posInNativeParent,r.size()));
7338 if (!q->isWindow()) {
7339 if (renderToTexture) {
7340 QRegion updateRegion(q->geometry());
7341 updateRegion += QRect(oldPos, olds);
7342 q->parentWidget()->d_func()->invalidateBackingStore(updateRegion);
7343 }
else if (isMove && !isResize) {
7344 moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y());
7346 invalidateBackingStore_resizeHelper(oldPos, olds);
7352 QMoveEvent e(q->pos(), oldPos);
7353 QCoreApplication::sendEvent(q, &e);
7356 QResizeEvent e(r.size(), olds);
7357 QCoreApplication::sendEvent(q, &e);
7358 if (q->windowHandle())
7362 if (isMove && q->pos() != oldPos)
7363 q->setAttribute(Qt::WA_PendingMoveEvent,
true);
7365 q->setAttribute(Qt::WA_PendingResizeEvent,
true);
7368#if QT_CONFIG(accessibility)
7369 if (QAccessible::isActive() && q->isVisible()) {
7370 QAccessibleEvent event(q, QAccessible::LocationChanged);
7371 QAccessible::updateAccessibility(&event);
7505bool QWidget::restoreGeometry(
const QByteArray &geometry)
7507 if (geometry.size() < 4)
7509 QDataStream stream(geometry);
7510 stream.setVersion(QDataStream::Qt_4_0);
7512 const quint32 magicNumber = 0x1D9D0CB;
7513 quint32 storedMagicNumber;
7514 stream >> storedMagicNumber;
7515 if (storedMagicNumber != magicNumber)
7518 const quint16 currentMajorVersion = 3;
7519 quint16 majorVersion = 0;
7520 quint16 minorVersion = 0;
7522 stream >> majorVersion >> minorVersion;
7524 if (majorVersion > currentMajorVersion)
7528 QRect restoredFrameGeometry;
7529 QRect restoredGeometry;
7530 QRect restoredNormalGeometry;
7531 qint32 restoredScreenNumber;
7534 qint32 restoredScreenWidth = 0;
7536 stream >> restoredFrameGeometry
7537 >> restoredNormalGeometry
7538 >> restoredScreenNumber
7542 if (majorVersion > 1)
7543 stream >> restoredScreenWidth;
7544 if (majorVersion > 2)
7545 stream >> restoredGeometry;
7549 if (restoredScreenNumber >= qMax(QGuiApplication::screens().size(), 1))
7550 restoredScreenNumber = 0;
7551 const QScreen *restoredScreen = QGuiApplication::screens().value(restoredScreenNumber,
nullptr);
7552 const qreal screenWidthF = restoredScreen ? qreal(restoredScreen->geometry().width()) : 0;
7555 if (restoredScreenWidth) {
7556 const qreal factor = qreal(restoredScreenWidth) / screenWidthF;
7557 if (factor < 0.8 || factor > 1.25)
7562 if (!maximized && !fullScreen && qreal(restoredFrameGeometry.width()) / screenWidthF > 1.5)
7566 const int frameHeight = QApplication::style()
7567 ? QApplication::style()->pixelMetric(QStyle::PM_TitleBarHeight,
nullptr,
this)
7570 if (!restoredNormalGeometry.isValid())
7571 restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint());
7572 if (!restoredNormalGeometry.isValid()) {
7574 restoredNormalGeometry.setSize(restoredNormalGeometry
7576 .expandedTo(d_func()->adjustedSize()));
7579 const QRect availableGeometry = restoredScreen ? restoredScreen->availableGeometry()
7587 QWidgetPrivate::checkRestoredGeometry(availableGeometry, &restoredGeometry, frameHeight);
7588 QWidgetPrivate::checkRestoredGeometry(availableGeometry, &restoredNormalGeometry, frameHeight);
7590 if (maximized || fullScreen) {
7593 Qt::WindowStates ws = windowState();
7595 setGeometry(restoredNormalGeometry);
7597 if (ws & Qt::WindowFullScreen) {
7599 move(availableGeometry.topLeft());
7600 }
else if (ws & Qt::WindowMaximized) {
7604 if (restoredScreen != screen()) {
7605 setWindowState(Qt::WindowNoState);
7606 setGeometry(restoredNormalGeometry);
7609 setGeometry(restoredNormalGeometry);
7613 ws |= Qt::WindowMaximized;
7615 ws |= Qt::WindowFullScreen;
7617 d_func()->topData()->normalGeometry = restoredNormalGeometry;
7619 setWindowState(windowState() & ~(Qt::WindowMaximized | Qt::WindowFullScreen));
7622 if (majorVersion > 2)
7623 setGeometry(restoredGeometry);
7625 setGeometry(restoredNormalGeometry);
7728QMargins QWidgetPrivate::safeAreaMargins()
const
7732#if QT_CONFIG(graphicsview)
7735 if (nearestGraphicsProxyWidget(q))
7739 QWidget *nativeWidget = q->window();
7740 if (!nativeWidget->windowHandle())
7743 QMargins safeAreaMargins = nativeWidget->windowHandle()->safeAreaMargins();
7745 if (!q->isWindow()) {
7753 if (safeAreaMargins.isNull())
7760 const QWidget *assumedSafeWidget =
nullptr;
7761 for (
const QWidget *w = q; w != nativeWidget; w = w->parentWidget()) {
7762 QWidget *parentWidget = w->parentWidget();
7763 if (!parentWidget->testAttribute(Qt::WA_ContentsMarginsRespectsSafeArea))
7766 if (parentWidget->testAttribute(Qt::WA_LayoutOnEntireRect))
7769 QLayout *layout = parentWidget->layout();
7773 if (layout->geometry().isNull())
7776 if (layout->indexOf(w) < 0)
7779 assumedSafeWidget = w;
7783#if !defined(QT_DEBUG)
7784 if (assumedSafeWidget) {
7795 QPoint topLeftMargins = q->mapFrom(nativeWidget, QPoint(safeAreaMargins.left(), safeAreaMargins.top()));
7796 QRect widgetRect = q->isVisible() ? q->visibleRegion().boundingRect() : q->rect();
7797 QPoint bottomRightMargins = widgetRect.bottomRight() - q->mapFrom(nativeWidget,
7798 nativeWidget->rect().bottomRight() - QPoint(safeAreaMargins.right(), safeAreaMargins.bottom()));
7801 safeAreaMargins = QMargins(qMax(0, topLeftMargins.x()), qMax(0, topLeftMargins.y()),
7802 qMax(0, bottomRightMargins.x()), qMax(0, bottomRightMargins.y()));
7804 if (!safeAreaMargins.isNull() && assumedSafeWidget) {
7805 QLayout *layout = assumedSafeWidget->parentWidget()->layout();
7806 qWarning() << layout <<
"is laying out" << assumedSafeWidget
7807 <<
"outside of the contents rect of" << layout->parentWidget();
7812 return safeAreaMargins;
8038void QWidgetPrivate::show_helper()
8041 data.in_show =
true;
8043 sendPendingMoveAndResizeEvents();
8046 q->setAttribute(Qt::WA_WState_Visible);
8049 showChildren(
false);
8053 const bool isWindow = q->isWindow();
8054#if QT_CONFIG(graphicsview)
8055 bool isEmbedded = isWindow && q->graphicsProxyWidget() !=
nullptr;
8057 bool isEmbedded =
false;
8063 if (isWindow && !isEmbedded) {
8064 if ((q->windowType() == Qt::Tool) || (q->windowType() == Qt::Popup) || q->windowType() == Qt::ToolTip) {
8066 if (q->parentWidget() && q->parentWidget()->window()->testAttribute(Qt::WA_KeyboardFocusChange))
8067 q->setAttribute(Qt::WA_KeyboardFocusChange);
8069 while (QApplication::activePopupWidget()) {
8070 if (!QApplication::activePopupWidget()->close())
8078#if QT_CONFIG(graphicsview)
8080 if (!isEmbedded && !bypassGraphicsProxyWidget(q)) {
8081 QGraphicsProxyWidget *ancestorProxy = nearestGraphicsProxyWidget(q->parentWidget());
8082 if (ancestorProxy) {
8084 ancestorProxy->d_func()->embedSubWindow(q);
8089 Q_UNUSED(isEmbedded);
8093 QShowEvent showEvent;
8094 QCoreApplication::sendEvent(q, &showEvent);
8098 if (!isEmbedded && q->windowType() == Qt::Popup)
8099 qApp->d_func()->openPopup(q);
8101#if QT_CONFIG(accessibility)
8102 if (q->windowType() != Qt::ToolTip) {
8103 QAccessibleEvent event(q, QAccessible::ObjectShow);
8104 QAccessible::updateAccessibility(&event);
8108 if (QApplicationPrivate::hidden_focus_widget == q) {
8109 QApplicationPrivate::hidden_focus_widget =
nullptr;
8110 q->setFocus(Qt::OtherFocusReason);
8116 if (!
qApp->d_func()->in_exec && q->windowType() == Qt::SplashScreen)
8117 QCoreApplication::processEvents();
8119 data.in_show =
false;
8122void QWidgetPrivate::show_sys()
8126 auto window = qobject_cast<QWidgetWindow *>(windowHandle());
8128 if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
8129 invalidateBackingStore(q->rect());
8130 q->setAttribute(Qt::WA_Mapped);
8132 if (window && q->isWindow()
8133#if QT_CONFIG(graphicsview)
8134 && (!extra || !extra->proxyWidget)
8136 && q->windowModality() != Qt::NonModal) {
8137 QGuiApplicationPrivate::showModalWindow(window);
8142 if (renderToTexture && !q->isWindow())
8143 QCoreApplication::postEvent(q->parentWidget(),
new QUpdateLaterEvent(q->geometry()));
8145 QCoreApplication::postEvent(q,
new QUpdateLaterEvent(q->rect()));
8147 if ((!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow))
8148 || q->testAttribute(Qt::WA_OutsideWSRange)) {
8154 fixPosIncludesFrame();
8155 QRect geomRect = q->geometry();
8156 if (!q->isWindow()) {
8157 QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint());
8158 geomRect.moveTopLeft(topLeftOfWindow);
8160 const QRect windowRect = window->geometry();
8161 if (windowRect != geomRect) {
8162 if (q->testAttribute(Qt::WA_Moved)
8163 || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowManagement))
8164 window->setGeometry(geomRect);
8166 window->resize(geomRect.size());
8170 qt_qpa_set_cursor(q,
false);
8172 invalidateBackingStore(q->rect());
8173 window->setNativeWindowVisibility(
true);
8175 if (window->isTopLevel()) {
8176 const QPoint crectTopLeft = q->data->crect.topLeft();
8177 const QPoint windowTopLeft = window->geometry().topLeft();
8178 if (crectTopLeft == QPoint(0, 0) && windowTopLeft != crectTopLeft)
8179 q->data->crect.moveTopLeft(windowTopLeft);
8338void QWidgetPrivate::setVisible(
bool visible)
8341 qCDebug(lcWidgetShowHide) <<
"Setting visibility of" << q
8342 <<
"with attributes" << WidgetAttributes{q}
8343 <<
"to" << visible <<
"via QWidgetPrivate";
8347 if (!q->isWindow() && q->parentWidget() && q->parentWidget()->isVisible()
8348 && !q->parentWidget()->testAttribute(Qt::WA_WState_Created))
8349 q->parentWidget()->window()->d_func()->createRecursively();
8352 QWidget *pw = q->parentWidget();
8353 if (!q->testAttribute(Qt::WA_WState_Created)
8354 && (q->isWindow() || pw->testAttribute(Qt::WA_WState_Created))) {
8358 bool wasResized = q->testAttribute(Qt::WA_Resized);
8359 Qt::WindowStates initialWindowState = q->windowState();
8362 q->ensurePolished();
8365 bool needUpdateGeometry = !q->isWindow() && q->testAttribute(Qt::WA_WState_Hidden);
8367 q->setAttribute(Qt::WA_WState_Hidden,
false);
8369 if (needUpdateGeometry)
8370 updateGeometry_helper(
true);
8376 if (!q->isWindow()) {
8377 QWidget *parent = q->parentWidget();
8378 while (parent && parent->isVisible() && parent->d_func()->layout && !parent->data->in_show) {
8379 parent->d_func()->layout->activate();
8380 if (parent->isWindow())
8382 parent = parent->parentWidget();
8385 parent->d_func()->setDirtyOpaqueRegion();
8390 && (q->isWindow() || !q->parentWidget()->d_func()->layout)) {
8391 if (q->isWindow()) {
8393 if (q->windowState() != initialWindowState)
8394 q->setWindowState(initialWindowState);
8398 q->setAttribute(Qt::WA_Resized,
false);
8401 q->setAttribute(Qt::WA_KeyboardFocusChange,
false);
8403 if (q->isWindow() || q->parentWidget()->isVisible()) {
8406 qApp->d_func()->sendSyntheticEnterLeave(q);
8409 QEvent showToParentEvent(QEvent::ShowToParent);
8410 QCoreApplication::sendEvent(q, &showToParentEvent);
8412 if (QApplicationPrivate::hidden_focus_widget == q)
8413 QApplicationPrivate::hidden_focus_widget =
nullptr;
8419 if (!q->isWindow() && q->parentWidget())
8420 q->parentWidget()->d_func()->setDirtyOpaqueRegion();
8422 if (!q->testAttribute(Qt::WA_WState_Hidden)) {
8423 q->setAttribute(Qt::WA_WState_Hidden);
8428 if (!q->isWindow() && q->parentWidget()) {
8429 if (q->parentWidget()->d_func()->layout)
8430 q->parentWidget()->d_func()->layout->invalidate();
8431 else if (q->parentWidget()->isVisible())
8432 QCoreApplication::postEvent(q->parentWidget(),
new QEvent(QEvent::LayoutRequest));
8435 QEvent hideToParentEvent(QEvent::HideToParent);
8436 QCoreApplication::sendEvent(q, &hideToParentEvent);
8937bool QWidget::event(QEvent *event)
8943 switch(event->type()) {
8944 case QEvent::TabletPress:
8945 case QEvent::TabletRelease:
8946 case QEvent::TabletMove:
8947 case QEvent::MouseButtonPress:
8948 case QEvent::MouseButtonRelease:
8949 case QEvent::MouseButtonDblClick:
8950 case QEvent::MouseMove:
8951 case QEvent::TouchBegin:
8952 case QEvent::TouchUpdate:
8953 case QEvent::TouchEnd:
8954 case QEvent::TouchCancel:
8955 case QEvent::ContextMenu:
8956 case QEvent::KeyPress:
8957 case QEvent::KeyRelease:
8958#if QT_CONFIG(wheelevent)
8966 switch (event->type()) {
8967 case QEvent::PlatformSurface: {
8969 switch (
static_cast<QPlatformSurfaceEvent*>(event)->surfaceEventType()) {
8970 case QPlatformSurfaceEvent::SurfaceCreated:
8971 if (!testAttribute(Qt::WA_WState_Created))
8974 case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
8975 if (testAttribute(Qt::WA_WState_Created)) {
8978 destroy(
false,
false);
8984 case QEvent::MouseMove:
8985 mouseMoveEvent((QMouseEvent*)event);
8988 case QEvent::MouseButtonPress:
8989 mousePressEvent((QMouseEvent*)event);
8992 case QEvent::MouseButtonRelease:
8993 mouseReleaseEvent((QMouseEvent*)event);
8996 case QEvent::MouseButtonDblClick:
8997 mouseDoubleClickEvent((QMouseEvent*)event);
8999#if QT_CONFIG(wheelevent)
9001 wheelEvent((QWheelEvent*)event);
9004#if QT_CONFIG(tabletevent)
9005 case QEvent::TabletMove:
9006 if (
static_cast<QTabletEvent *>(event)->buttons() == Qt::NoButton && !testAttribute(Qt::WA_TabletTracking))
9009 case QEvent::TabletPress:
9010 case QEvent::TabletRelease:
9011 tabletEvent((QTabletEvent*)event);
9014 case QEvent::KeyPress: {
9015 QKeyEvent *k =
static_cast<QKeyEvent *>(event);
9017 if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) {
9018 if (k->key() == Qt::Key_Backtab
9019 || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier)))
9020 res = focusNextPrevChild(
false);
9021 else if (k->key() == Qt::Key_Tab)
9022 res = focusNextPrevChild(
true);
9027#if QT_CONFIG(whatsthis)
9028 if (!k->isAccepted()
9029 && k->modifiers() & Qt::ShiftModifier && k->key() == Qt::Key_F1
9030 && d->whatsThis.size()) {
9031 QWhatsThis::showText(mapToGlobal(inputMethodQuery(Qt::ImCursorRectangle).toRect().center()), d->whatsThis,
this);
9038 case QEvent::KeyRelease:
9039 keyReleaseEvent((QKeyEvent*)event);
9041 case QEvent::ShortcutOverride:
9044 case QEvent::InputMethod:
9045 inputMethodEvent((QInputMethodEvent *) event);
9048 case QEvent::InputMethodQuery: {
9049 QInputMethodQueryEvent *query =
static_cast<QInputMethodQueryEvent *>(event);
9050 Qt::InputMethodQueries queries = query->queries();
9051 for (uint i = 0; i < 32; ++i) {
9052 Qt::InputMethodQuery q = (Qt::InputMethodQuery)(
int)(queries & (1<<i));
9054 QVariant v = inputMethodQuery(q);
9055 if (q == Qt::ImEnabled && !v.isValid() && isEnabled()) {
9062 v = QVariant(testAttribute(Qt::WA_InputMethodEnabled));
9064 query->setValue(q, v);
9071 case QEvent::PolishRequest:
9075 case QEvent::Polish: {
9076 style()->polish(
this);
9077 setAttribute(Qt::WA_WState_Polished);
9078 if (!QApplication::font(
this).isCopyOf(QApplication::font()))
9080 if (!QApplication::palette(
this).isCopyOf(QGuiApplication::palette()))
9081 d->resolvePalette();
9085 case QEvent::ApplicationWindowIconChange:
9086 if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon)) {
9087 d->setWindowIcon_sys();
9088 d->setWindowIcon_helper();
9091 case QEvent::FocusIn:
9092 focusInEvent((QFocusEvent*)event);
9093 d->updateWidgetTransform(event);
9096 case QEvent::FocusOut:
9097 focusOutEvent((QFocusEvent*)event);
9101#if QT_CONFIG(statustip)
9102 if (d->statusTip.size()) {
9103 QStatusTipEvent tip(d->statusTip);
9104 QCoreApplication::sendEvent(
const_cast<QWidget *>(
this), &tip);
9107 enterEvent(
static_cast<QEnterEvent*>(event));
9111#if QT_CONFIG(statustip)
9112 if (d->statusTip.size()) {
9114 QStatusTipEvent tip(empty);
9115 QCoreApplication::sendEvent(
const_cast<QWidget *>(
this), &tip);
9121 case QEvent::HoverEnter:
9122 case QEvent::HoverLeave:
9130 paintEvent((QPaintEvent*)event);
9134 moveEvent((QMoveEvent*)event);
9135 d->updateWidgetTransform(event);
9138 case QEvent::Resize:
9139 resizeEvent((QResizeEvent*)event);
9140 d->updateWidgetTransform(event);
9144 closeEvent((QCloseEvent *)event);
9147#ifndef QT_NO_CONTEXTMENU
9148 case QEvent::ContextMenu:
9149 switch (data->context_menu_policy) {
9150 case Qt::PreventContextMenu:
9152 case Qt::DefaultContextMenu:
9153 contextMenuEvent(
static_cast<QContextMenuEvent *>(event));
9155 case Qt::CustomContextMenu:
9156 emit customContextMenuRequested(
static_cast<QContextMenuEvent *>(event)->pos());
9159 case Qt::ActionsContextMenu:
9160 if (d->actions.size()) {
9161 QMenu::exec(d->actions,
static_cast<QContextMenuEvent *>(event)->globalPos(),
9174#if QT_CONFIG(draganddrop)
9176 dropEvent((QDropEvent*) event);
9179 case QEvent::DragEnter:
9180 dragEnterEvent((QDragEnterEvent*) event);
9183 case QEvent::DragMove:
9184 dragMoveEvent((QDragMoveEvent*) event);
9187 case QEvent::DragLeave:
9188 dragLeaveEvent((QDragLeaveEvent*) event);
9193 showEvent((QShowEvent*) event);
9197 hideEvent((QHideEvent*) event);
9200 case QEvent::ShowWindowRequest:
9205 case QEvent::ApplicationFontChange:
9208 case QEvent::ApplicationPaletteChange:
9209 d->resolvePalette();
9212 case QEvent::ToolBarChange:
9213 case QEvent::ActivationChange:
9214 case QEvent::EnabledChange:
9215 case QEvent::FontChange:
9216 case QEvent::StyleChange:
9217 case QEvent::PaletteChange:
9218 case QEvent::WindowTitleChange:
9219 case QEvent::IconTextChange:
9220 case QEvent::ModifiedChange:
9221 case QEvent::MouseTrackingChange:
9222 case QEvent::TabletTrackingChange:
9223 case QEvent::ParentChange:
9224 case QEvent::LocaleChange:
9225 case QEvent::MacSizeChange:
9226 case QEvent::ContentsRectChange:
9227 case QEvent::ThemeChange:
9228 case QEvent::ReadOnlyChange:
9232 case QEvent::WindowStateChange: {
9233 const bool wasMinimized =
static_cast<
const QWindowStateChangeEvent *>(event)->oldState() & Qt::WindowMinimized;
9234 if (wasMinimized != isMinimized()) {
9235 QWidget *widget =
const_cast<QWidget *>(
this);
9238 if (!d->childrenShownByExpose) {
9240 d->showChildren(
true);
9241 QShowEvent showEvent;
9242 QCoreApplication::sendSpontaneousEvent(widget, &showEvent);
9244 d->childrenHiddenByWState =
false;
9246 QHideEvent hideEvent;
9247 QCoreApplication::sendSpontaneousEvent(widget, &hideEvent);
9248 d->hideChildren(
true);
9249 d->childrenHiddenByWState =
true;
9251 d->childrenShownByExpose =
false;
9257 case QEvent::WindowActivate:
9258 case QEvent::WindowDeactivate: {
9259 if (isVisible() && !palette().isEqual(QPalette::Active, QPalette::Inactive))
9261 QList<QObject*> childList = d->children;
9262 for (
int i = 0; i < childList.size(); ++i) {
9263 QWidget *w = qobject_cast<QWidget *>(childList.at(i));
9264 if (w && w->isVisible() && !w->isWindow())
9265 QCoreApplication::sendEvent(w, event);
9269 case QEvent::LanguageChange:
9272 QList<QObject*> childList = d->children;
9273 for (
int i = 0; i < childList.size(); ++i) {
9274 QObject *o = childList.at(i);
9276 QCoreApplication::sendEvent(o, event);
9282 case QEvent::ApplicationLayoutDirectionChange:
9283 d->resolveLayoutDirection();
9286 case QEvent::LayoutDirectionChange:
9288 d->layout->invalidate();
9292 case QEvent::UpdateRequest:
9293 d->syncBackingStore();
9295 case QEvent::UpdateLater:
9296 update(
static_cast<QUpdateLaterEvent*>(event)->region());
9298 case QEvent::StyleAnimationUpdate:
9299 if (isVisible() && !window()->isMinimized()) {
9305 case QEvent::WindowBlocked:
9306 case QEvent::WindowUnblocked:
9307 if (!d->children.isEmpty()) {
9308 QWidget *modalWidget = QApplication::activeModalWidget();
9309 for (
int i = 0; i < d->children.size(); ++i) {
9310 QObject *o = d->children.at(i);
9311 if (o && o != modalWidget && o->isWidgetType()) {
9312 QWidget *w =
static_cast<QWidget *>(o);
9315 QCoreApplication::sendEvent(w, event);
9320#if QT_CONFIG(tooltip)
9321 case QEvent::ToolTip:
9322 if (!d->toolTip.isEmpty())
9323 QToolTip::showText(
static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip,
this, QRect(), d->toolTipDuration);
9328#if QT_CONFIG(whatsthis)
9329 case QEvent::WhatsThis:
9330 if (d->whatsThis.size())
9331 QWhatsThis::showText(
static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis,
this);
9335 case QEvent::QueryWhatsThis:
9336 if (d->whatsThis.isEmpty())
9340 case QEvent::EmbeddingControl:
9341 d->topData()->frameStrut.setCoords(0 ,0, 0, 0);
9342 data->fstrut_dirty =
false;
9345 case QEvent::ActionAdded:
9346 case QEvent::ActionRemoved:
9347 case QEvent::ActionChanged:
9348 actionEvent((QActionEvent*)event);
9352 case QEvent::KeyboardLayoutChange:
9357 QList<QObject*> childList = d->children;
9358 for (
int i = 0; i < childList.size(); ++i) {
9359 QWidget *w = qobject_cast<QWidget *>(childList.at(i));
9360 if (w && w->isVisible() && !w->isWindow())
9361 QCoreApplication::sendEvent(w, event);
9365 case QEvent::TouchBegin:
9366 case QEvent::TouchUpdate:
9367 case QEvent::TouchEnd:
9368 case QEvent::TouchCancel:
9373#ifndef QT_NO_GESTURES
9374 case QEvent::Gesture:
9378 case QEvent::ScreenChangeInternal:
9379 if (
const QTLWExtra *te = d->maybeTopData()) {
9380 const QWindow *win = te->window;
9381 d->setWinId((win && win->handle()) ? win->handle()->winId() : 0);
9384 case QEvent::DevicePixelRatioChange:
9385 if (d->data.fnt.d->dpi != logicalDpiY())
9386 d->updateFont(d->data.fnt);
9387 d->renderToTextureReallyDirty = 1;
9389 case QEvent::DynamicPropertyChange: {
9390 const QByteArray &propName =
static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
9391 if (propName.size() == 13 && !qstrncmp(propName,
"_q_customDpi", 12)) {
9392 uint value = property(propName.constData()).toUInt();
9395 const char axis = propName.at(12);
9397 d->extra->customDpiX = value;
9398 else if (axis ==
'Y')
9399 d->extra->customDpiY = value;
9400 d->updateFont(d->data.fnt);
9402 if (windowHandle() && !qstrncmp(propName,
"_q_platform_", 12))
9403 windowHandle()->setProperty(propName, property(propName));
9407 return QObject::event(event);
10712void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
10715 Q_ASSERT_X(
this != parent, Q_FUNC_INFO,
"Cannot parent a QWidget to itself");
10717 const auto checkForParentChildLoops = qScopeGuard([&](){
10719 auto p = parentWidget();
10721 if (++depth == QObjectPrivate::CheckForParentChildLoopsWarnDepth) {
10722 qWarning(
"QWidget %p (class: '%s', object name: '%s') may have a loop in its parent-child chain; "
10723 "this is undefined behavior",
10724 this, metaObject()->className(), qPrintable(objectName()));
10726 p = p->parentWidget();
10731 const bool resized = testAttribute(Qt::WA_Resized);
10732 const bool wasCreated = testAttribute(Qt::WA_WState_Created);
10733 QWidget *oldtlw = window();
10735 QWidget *oldParentWithWindow = d->closestParentWidgetWithWindowHandle();
10737 if (f & Qt::Window)
10738 d->data.fstrut_dirty =
true;
10740 bool newParent = (parent != parentWidget());
10742 if (newParent && parent) {
10743 if (testAttribute(Qt::WA_NativeWindow) && !QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings))
10744 parent->d_func()->enforceNativeChildren();
10745 else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
10746 setAttribute(Qt::WA_NativeWindow);
10750 if (!testAttribute(Qt::WA_WState_Hidden)) {
10765 setAttribute(Qt::WA_WState_ExplicitShowHide,
false);
10768 QEvent e(QEvent::ParentAboutToChange);
10769 QCoreApplication::sendEvent(
this, &e);
10775 const bool oldWidgetUsesRhiFlush = oldParentWithWindow ? oldParentWithWindow->d_func()->usesRhiFlush
10776 : oldtlw->d_func()->usesRhiFlush;
10777 if (oldWidgetUsesRhiFlush && ((!parent && parentWidget()) || (parent && parent->window() != oldtlw)))
10778 qSendWindowChangeToTextureChildrenRecursively(
this, QEvent::WindowAboutToChangeInternal);
10782 if (newParent && isAncestorOf(focusWidget()) && !(f & Qt::Window))
10783 focusWidget()->clearFocus();
10785 d->setParent_sys(parent, f);
10787 if (d->textureChildSeen && parent) {
10789 QWidgetPrivate::get(parent)->setTextureChildSeen();
10792 if (QWidgetRepaintManager *oldPaintManager = oldtlw->d_func()->maybeRepaintManager()) {
10794 oldPaintManager->removeDirtyWidget(
this);
10797 oldPaintManager->moveStaticWidgets(
this);
10800 d->reparentFocusWidgets(oldtlw);
10801 setAttribute(Qt::WA_Resized, resized);
10803 const bool useStyleSheetPropagationInWidgetStyles =
10804 QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
10806 if (!useStyleSheetPropagationInWidgetStyles && !testAttribute(Qt::WA_StyleSheet)
10807 && (!parent || !parent->testAttribute(Qt::WA_StyleSheet))) {
10810 const auto pd = parent->d_func();
10811 d->inheritedFontResolveMask = pd->directFontResolveMask | pd->inheritedFontResolveMask;
10812 d->inheritedPaletteResolveMask = pd->directPaletteResolveMask | pd->inheritedPaletteResolveMask;
10815 d->resolvePalette();
10817 d->resolveLayoutDirection();
10818 d->resolveLocale();
10824 if (newParent || !wasCreated
10825#if QT_CONFIG(opengles2)
10826 || (f & Qt::MSWindowsOwnDC)
10831 if (!testAttribute(Qt::WA_ForceDisabled))
10832 d->setEnabled_helper(parent ? parent->isEnabled() :
true);
10833 if (!testAttribute(Qt::WA_ForceUpdatesDisabled))
10834 d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() :
true);
10839 if (parent && d->sendChildEvents) {
10840 QChildEvent e(QEvent::ChildAdded,
this);
10841 QCoreApplication::sendEvent(parent, &e);
10844 if (parent && d->sendChildEvents && d->polished) {
10845 QChildEvent e(QEvent::ChildPolished,
this);
10846 QCoreApplication::sendEvent(parent, &e);
10849 QEvent e(QEvent::ParentChange);
10850 QCoreApplication::sendEvent(
this, &e);
10855 if (oldWidgetUsesRhiFlush && oldtlw != window())
10856 qSendWindowChangeToTextureChildrenRecursively(
this, QEvent::WindowChangeInternal);
10859 if (isWindow() || parentWidget()->isVisible())
10860 setAttribute(Qt::WA_WState_Hidden,
true);
10861 else if (!testAttribute(Qt::WA_WState_ExplicitShowHide))
10862 setAttribute(Qt::WA_WState_Hidden,
false);
10865 d->updateIsOpaque();
10867#if QT_CONFIG(graphicsview)
10870 if (oldtlw->graphicsProxyWidget()) {
10871 if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(oldtlw))
10872 ancestorProxy->d_func()->unembedSubWindow(
this);
10874 if (isWindow() && parent && !graphicsProxyWidget() && !bypassGraphicsProxyWidget(
this)) {
10875 if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(parent))
10876 ancestorProxy->d_func()->embedSubWindow(
this);
10880 if (d->extra && d->extra->hasWindowContainer)
10881 QWindowContainer::parentWasChanged(
this);
10883 QWidget *newParentWithWindow = d->closestParentWidgetWithWindowHandle();
10884 if (newParentWithWindow && newParentWithWindow != oldParentWithWindow) {
10886 qCDebug(lcWidgetPainting) <<
"Evaluating whether reparenting of" <<
this
10887 <<
"into" << parent <<
"requires RHI enablement for" << newParentWithWindow;
10889 QPlatformBackingStoreRhiConfig rhiConfig;
10890 QSurface::SurfaceType surfaceType = QSurface::RasterSurface;
10896 if (q_evaluateRhiConfig(
this, &rhiConfig, &surfaceType)) {
10900 if (q_evaluateRhiConfig(newParentWithWindow,
nullptr,
nullptr)) {
10903 auto *existingWindow = newParentWithWindow->windowHandle();
10904 auto existingSurfaceType = existingWindow->surfaceType();
10905 if (existingSurfaceType != surfaceType) {
10906 qCDebug(lcWidgetPainting)
10907 <<
"Recreating" << existingWindow
10908 <<
"with current type" << existingSurfaceType
10909 <<
"to support" << surfaceType;
10910 const auto windowStateBeforeDestroy = newParentWithWindow->windowState();
10911 const auto visibilityBeforeDestroy = newParentWithWindow->isVisible();
10912 const auto positionBeforeDestroy = newParentWithWindow->pos();
10913 newParentWithWindow->d_func()->recreate();
10914 Q_ASSERT(newParentWithWindow->windowHandle());
10915 newParentWithWindow->windowHandle()->setWindowStates(windowStateBeforeDestroy);
10916 newParentWithWindow->move(positionBeforeDestroy);
10917 QWidgetPrivate::get(newParentWithWindow)->setVisible(visibilityBeforeDestroy);
10918 }
else if (
auto *backingStore = newParentWithWindow->backingStore()) {
10921 backingStore->handle()->createRhi(existingWindow, rhiConfig);
10923 QWidgetPrivate::get(newParentWithWindow)->usesRhiFlush =
true;
10929#if QT_CONFIG(accessibility)
10930 if (QGuiApplicationPrivate::is_app_running && !QGuiApplicationPrivate::is_app_closing) {
10931 QAccessibleEvent qaEvent(
this, QAccessible::ParentChanged);
10932 QAccessible::updateAccessibility(&qaEvent);
10938void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
10942 Qt::WindowFlags oldFlags = data.window_flags;
10943 bool wasCreated = q->testAttribute(Qt::WA_WState_Created);
10945 QScreen *targetScreen =
nullptr;
10951 targetScreen = q->parentWidget()->window()->screen();
10954 const bool destroyWindow = (
10956 (oldFlags & Qt::Window) && !(f & Qt::Window)
10958 && wasCreated && !q->testAttribute(Qt::WA_NativeWindow)
10961 if (parent != newparent) {
10963 QObjectPrivate::setParent_helper(newparent);
10965 if (q->windowHandle())
10966 q->windowHandle()->setFlags(f);
10970 QWidget *parentWithWindow = closestParentWidgetWithWindowHandle();
10973 if (destroyWindow) {
10974 reparentWidgetWindowChildren(parentWithWindow);
10984 reparentWidgetWindows(parentWithWindow, f);
10988 bool explicitlyHidden = isExplicitlyHidden();
10990 if (destroyWindow) {
10991 if (extra && extra->hasWindowContainer)
10992 QWindowContainer::toplevelAboutToBeDestroyed(q);
10996 if (!q->windowHandle()->children().isEmpty()) {
10997 QWidget *parentWithWindow = closestParentWidgetWithWindowHandle();
10998 QWindow *newParentWindow = parentWithWindow ? parentWithWindow->windowHandle() :
nullptr;
10999 for (QObject *child : q->windowHandle()->children()) {
11000 if (QWindow *childWindow = qobject_cast<QWindow *>(child)) {
11001 qCWarning(lcWidgetWindow) <<
"Reparenting" << childWindow
11002 <<
"before destroying" <<
this;
11003 childWindow->setParent(newParentWindow);
11011 q->destroy(
true,
false);
11015 data.window_flags = f;
11016 q->setAttribute(Qt::WA_WState_Created,
false);
11017 q->setAttribute(Qt::WA_WState_Visible,
false);
11018 q->setAttribute(Qt::WA_WState_Hidden,
false);
11020 if (newparent && wasCreated && (q->testAttribute(Qt::WA_NativeWindow) || (f & Qt::Window)))
11023 if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
11024 q->setAttribute(Qt::WA_WState_Hidden);
11025 q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
11028 if (!newparent && targetScreen) {
11030 if (q->testAttribute(Qt::WA_WState_Created))
11031 q->windowHandle()->setScreen(targetScreen);
11033 topData()->initialScreen = targetScreen;
11372void QWidget::setAttribute(Qt::WidgetAttribute attribute,
bool on)
11376 if (attribute == Qt::WA_ContentsMarginsRespectsSafeArea) {
11378 auto *topExtra = d->topData();
11379 topExtra->explicitContentsMarginsRespectsSafeArea =
true;
11383 if (testAttribute(attribute) == on)
11386 static_assert(
sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount -
sizeof(uint)*8),
11387 "QWidget::setAttribute(WidgetAttribute, bool): "
11388 "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
11391 if (attribute == Qt::WA_PaintOnScreen && on && !inherits(
"QGLWidget")) {
11394 if (d->noPaintOnScreen)
11400 if (attribute == Qt::WA_NativeWindow && !d->mustHaveWindowHandle) {
11401 QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();
11402 if (!platformIntegration->hasCapability(QPlatformIntegration::NativeWidgets))
11406 setAttribute_internal(attribute, on, data, d);
11408 switch (attribute) {
11410#if QT_CONFIG(draganddrop)
11411 case Qt::WA_AcceptDrops: {
11412 if (on && !testAttribute(Qt::WA_DropSiteRegistered))
11413 setAttribute(Qt::WA_DropSiteRegistered,
true);
11414 else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)))
11415 setAttribute(Qt::WA_DropSiteRegistered,
false);
11416 QEvent e(QEvent::AcceptDropsChange);
11417 QCoreApplication::sendEvent(
this, &e);
11420 case Qt::WA_DropSiteRegistered: {
11421 for (
int i = 0; i < d->children.size(); ++i) {
11422 QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
11423 if (w && !w->isWindow() && !w->testAttribute(Qt::WA_AcceptDrops) && w->testAttribute(Qt::WA_DropSiteRegistered) != on)
11424 w->setAttribute(Qt::WA_DropSiteRegistered, on);
11430 case Qt::WA_NoChildEventsForParent:
11431 d->sendChildEvents = !on;
11433 case Qt::WA_NoChildEventsFromChildren:
11434 d->receiveChildEvents = !on;
11436 case Qt::WA_MacNormalSize:
11437 case Qt::WA_MacSmallSize:
11438 case Qt::WA_MacMiniSize:
11442 const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize,
11443 Qt::WA_MacMiniSize };
11444 for (
int i = 0; i < 3; ++i) {
11445 if (MacSizes[i] != attribute)
11446 setAttribute_internal(MacSizes[i],
false, data, d);
11448 d->macUpdateSizeAttribute();
11452 case Qt::WA_ShowModal:
11455 data->window_modality = Qt::NonModal;
11456 }
else if (data->window_modality == Qt::NonModal) {
11459 data->window_modality = Qt::ApplicationModal;
11464 if (testAttribute(Qt::WA_WState_Created)) {
11469 case Qt::WA_MouseTracking: {
11470 QEvent e(QEvent::MouseTrackingChange);
11471 QCoreApplication::sendEvent(
this, &e);
11473 case Qt::WA_TabletTracking: {
11474 QEvent e(QEvent::TabletTrackingChange);
11475 QCoreApplication::sendEvent(
this, &e);
11477 case Qt::WA_NativeWindow: {
11478 d->createTLExtra();
11480 d->createTLSysExtra();
11482 QWidget *focusWidget = d->effectiveFocusWidget();
11483 if (on && !internalWinId() &&
this == QGuiApplication::focusObject()
11484 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
11485 QGuiApplication::inputMethod()->commit();
11486 QGuiApplication::inputMethod()->update(Qt::ImEnabled);
11488 if (!QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
11489 parentWidget()->d_func()->enforceNativeChildren();
11490 if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
11492 if (isEnabled() && focusWidget->isEnabled() &&
this == QGuiApplication::focusObject()
11493 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
11494 QGuiApplication::inputMethod()->update(Qt::ImEnabled);
11499 case Qt::WA_PaintOnScreen:
11500 d->updateIsOpaque();
11502 case Qt::WA_OpaquePaintEvent:
11503 d->updateIsOpaque();
11505 case Qt::WA_NoSystemBackground:
11506 d->updateIsOpaque();
11508 case Qt::WA_UpdatesDisabled:
11509 d->updateSystemBackground();
11511 case Qt::WA_TransparentForMouseEvents:
11513 case Qt::WA_InputMethodEnabled: {
11515 if (QGuiApplication::focusObject() ==
this) {
11517 QGuiApplication::inputMethod()->commit();
11518 QGuiApplication::inputMethod()->update(Qt::ImEnabled);
11523 case Qt::WA_WindowPropagation:
11524 d->resolvePalette();
11526 d->resolveLocale();
11528 case Qt::WA_DontShowOnScreen: {
11529 if (on && isVisible()) {
11539 case Qt::WA_X11NetWmWindowTypeDesktop:
11540 case Qt::WA_X11NetWmWindowTypeDock:
11541 case Qt::WA_X11NetWmWindowTypeToolBar:
11542 case Qt::WA_X11NetWmWindowTypeMenu:
11543 case Qt::WA_X11NetWmWindowTypeUtility:
11544 case Qt::WA_X11NetWmWindowTypeSplash:
11545 case Qt::WA_X11NetWmWindowTypeDialog:
11546 case Qt::WA_X11NetWmWindowTypeDropDownMenu:
11547 case Qt::WA_X11NetWmWindowTypePopupMenu:
11548 case Qt::WA_X11NetWmWindowTypeToolTip:
11549 case Qt::WA_X11NetWmWindowTypeNotification:
11550 case Qt::WA_X11NetWmWindowTypeCombo:
11551 case Qt::WA_X11NetWmWindowTypeDND:
11552 d->setNetWmWindowTypes();
11555 case Qt::WA_StaticContents:
11556 if (QWidgetRepaintManager *repaintManager = d->maybeRepaintManager()) {
11558 repaintManager->addStaticWidget(
this);
11560 repaintManager->removeStaticWidget(
this);
11563 case Qt::WA_TranslucentBackground:
11565 setAttribute(Qt::WA_NoSystemBackground);
11566 d->updateIsTranslucent();
11569 case Qt::WA_AcceptTouchEvents:
13155void QWidgetPrivate::setNetWmWindowTypes(
bool skipIfMissing)
13160 if (!q->windowHandle())
13163 QXcbWindow::WindowTypes wmWindowType = QXcbWindow::None;
13164 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDesktop))
13165 wmWindowType |= QXcbWindow::Desktop;
13166 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock))
13167 wmWindowType |= QXcbWindow::Dock;
13168 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolBar))
13169 wmWindowType |= QXcbWindow::Toolbar;
13170 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeMenu))
13171 wmWindowType |= QXcbWindow::Menu;
13172 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeUtility))
13173 wmWindowType |= QXcbWindow::Utility;
13174 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeSplash))
13175 wmWindowType |= QXcbWindow::Splash;
13176 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDialog))
13177 wmWindowType |= QXcbWindow::Dialog;
13178 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu))
13179 wmWindowType |= QXcbWindow::DropDownMenu;
13180 if (q->testAttribute(Qt::WA_X11NetWmWindowTypePopupMenu))
13181 wmWindowType |= QXcbWindow::PopupMenu;
13182 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolTip))
13183 wmWindowType |= QXcbWindow::Tooltip;
13184 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeNotification))
13185 wmWindowType |= QXcbWindow::Notification;
13186 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeCombo))
13187 wmWindowType |= QXcbWindow::Combo;
13188 if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDND))
13189 wmWindowType |= QXcbWindow::Dnd;
13191 if (wmWindowType == QXcbWindow::None && skipIfMissing)
13194 if (
auto *xcbWindow =
dynamic_cast<QXcbWindow*>(q->windowHandle()->handle()))
13195 xcbWindow->setWindowType(wmWindowType);
13197 Q_UNUSED(skipIfMissing);