diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-05-27 09:45:52 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-05-27 10:46:17 (GMT) |
commit | 73e7d0cbed0261715f534d95f81055bf97ce4314 (patch) | |
tree | c47c09db97ea0feac9e6dad40ea2e68105abd2c2 /src/gui/kernel | |
parent | 855022d6108f6b3c90832e742217c50550af717d (diff) | |
download | Qt-73e7d0cbed0261715f534d95f81055bf97ce4314.zip Qt-73e7d0cbed0261715f534d95f81055bf97ce4314.tar.gz Qt-73e7d0cbed0261715f534d95f81055bf97ce4314.tar.bz2 |
Make WA_TranslucentBackground work on QGLWidget for X11
This patch enables QGLWidget's to have an ARGB visual on X11, alowing GL
rendering on semi-transparent windows.
Reviewed-By: Trond
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qwidget_x11.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index b35740a..7e41ea1 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -893,15 +893,28 @@ void QWidgetPrivate::x11UpdateIsOpaque() int screen = xinfo.screen(); if (topLevel && X11->use_xrender && X11->argbVisuals[screen] && xinfo.depth() != 32) { - // recreate widget - QPoint pos = q->pos(); - bool visible = q->isVisible(); - if (visible) - q->hide(); - q->setParent(q->parentWidget(), q->windowFlags()); - q->move(pos); - if (visible) - q->show(); + + if (q->inherits("QGLWidget")) { + // We send QGLWidgets a ParentChange event which causes them to + // recreate their GL context, which in turn causes them to choose + // their visual again. Now that WA_TranslucentBackground is set, + // QGLContext::chooseVisual will select an ARGB visual. + QEvent e(QEvent::ParentChange); + QApplication::sendEvent(q, &e); + } + else { + // For regular widgets, reparent them with their parent which + // also triggers a recreation of the native window + QPoint pos = q->pos(); + bool visible = q->isVisible(); + if (visible) + q->hide(); + + q->setParent(q->parentWidget(), q->windowFlags()); + q->move(pos); + if (visible) + q->show(); + } } #endif } |