diff options
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index e692a985eb..43ce9a82f7 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5492,18 +5492,22 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP //paint the background if ((asRoot || q->autoFillBackground() || onScreen || q->testAttribute(Qt::WA_StyledBackground)) && !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) { + beginBackingStorePainting(); QPainter p(q); paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0); + endBackingStorePainting(); } if (!sharedPainter) setSystemClip(pdev, toBePainted.translated(offset)); if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) { + beginBackingStorePainting(); QPainter p(q); QColor tint = q->palette().window().color(); tint.setAlphaF(qreal(.6)); p.fillRect(toBePainted.boundingRect(), tint); + endBackingStorePainting(); } } @@ -5513,24 +5517,30 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP << "geometry ==" << QRect(q->mapTo(q->window(), QPoint(0, 0)), q->size()); #endif + bool grabbed = false; +#ifndef QT_NO_OPENGL if (renderToTexture) { // This widget renders into a texture which is composed later. We just need to // punch a hole in the backingstore, so the texture will be visible. -#ifndef QT_NO_OPENGL - QPainter p(q); - - if (backingStore) { - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(q->rect(), Qt::transparent); - } else { - // We are not drawing to a backingstore: fall back to QImage - p.drawImage(q->rect(), grabFramebuffer()); + if (!q->testAttribute(Qt::WA_AlwaysStackOnTop)) { + beginBackingStorePainting(); + QPainter p(q); + if (backingStore) { + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(q->rect(), Qt::transparent); + } else { + // We are not drawing to a backingstore: fall back to QImage + p.drawImage(q->rect(), grabFramebuffer()); + grabbed = true; + } + endBackingStorePainting(); } -#endif - } else { + } +#endif // QT_NO_OPENGL + + if (!grabbed) { //actually send the paint event - QPaintEvent e(toBePainted); - QCoreApplication::sendSpontaneousEvent(q, &e); + sendPaintEvent(toBePainted); } // Native widgets need to be marked dirty on screen so painting will be done in correct context @@ -5586,6 +5596,13 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP } } +void QWidgetPrivate::sendPaintEvent(const QRegion &toBePainted) +{ + Q_Q(QWidget); + QPaintEvent e(toBePainted); + QCoreApplication::sendSpontaneousEvent(q, &e); +} + void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags) { @@ -11968,7 +11985,7 @@ QOpenGLContext *QWidgetPrivate::shareContext() const } QWidgetPrivate *that = const_cast<QWidgetPrivate *>(this); if (!extra->topextra->shareContext) { - QOpenGLContext *ctx = new QOpenGLContext(); + QOpenGLContext *ctx = new QOpenGLContext; ctx->setShareContext(QOpenGLContextPrivate::globalShareContext()); ctx->setFormat(extra->topextra->window->format()); ctx->create(); @@ -11978,6 +11995,24 @@ QOpenGLContext *QWidgetPrivate::shareContext() const #endif // QT_NO_OPENGL } +#ifndef QT_NO_OPENGL +void QWidgetPrivate::sendComposeStatus(QWidget *w, bool end) +{ + QWidgetPrivate *wd = QWidgetPrivate::get(w); + if (!wd->textureChildSeen) + return; + if (end) + wd->endCompose(); + else + wd->beginCompose(); + for (int i = 0; i < wd->children.size(); ++i) { + w = qobject_cast<QWidget *>(wd->children.at(i)); + if (w && !w->isWindow() && !w->isHidden() && QWidgetPrivate::get(w)->textureChildSeen) + sendComposeStatus(w, end); + } +} +#endif // QT_NO_OPENGL + Q_WIDGETS_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget) { return widget->data; |