diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-07-24 14:54:55 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-07-24 15:02:59 (GMT) |
commit | f74b368c08f9bd1f638f32bccdb4da6dbd89cfea (patch) | |
tree | ee5926965809ea1b3e948f399097ce61e3e342c3 /src/opengl | |
parent | 365cbdf74aa0f5933bf938922ebb48fa8e37d8ce (diff) | |
download | Qt-f74b368c08f9bd1f638f32bccdb4da6dbd89cfea.zip Qt-f74b368c08f9bd1f638f32bccdb4da6dbd89cfea.tar.gz Qt-f74b368c08f9bd1f638f32bccdb4da6dbd89cfea.tar.bz2 |
Add an ARGB check for EGL-provided X visuals
Don't just assume they're going to be ARGB just because the config has
an alpha channel. This makes QGLWidgets with WA_TranslucentBackground
set work again on the rx71 when running under xcompmgr.
Reviewed-By: Trustme
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl_x11egl.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 99b026d..c6904fe 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -258,7 +258,8 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, // If the application has set WA_TranslucentBackground and not explicitly set // the alpha buffer size to zero, modify the format so it have an alpha channel QGLFormat& fmt = d->glcx->d_func()->glFormat; - if (testAttribute(Qt::WA_TranslucentBackground) && fmt.alphaBufferSize() == -1) + const bool useArgbVisual = testAttribute(Qt::WA_TranslucentBackground); + if (useArgbVisual && fmt.alphaBufferSize() == -1) fmt.setAlphaBufferSize(1); bool createFailed = false; @@ -297,8 +298,24 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, int matchingCount = 0; chosenVisualInfo = XGetVisualInfo(x11Info().display(), VisualIDMask, &vi, &matchingCount); if (chosenVisualInfo) { - qDebug("Using X Visual ID (%d) provided by EGL", (int)vi.visualid); - vi = *chosenVisualInfo; + if (useArgbVisual) { + // Check to make sure the visual provided by EGL is ARGB + XRenderPictFormat *format; + format = XRenderFindVisualFormat(x11Info().display(), chosenVisualInfo->visual); + if (format->type == PictTypeDirect && format->direct.alphaMask) { + qDebug("Using opaque X Visual ID (%d) provided by EGL", (int)vi.visualid); + vi = *chosenVisualInfo; + } + else { + qWarning("Warning: EGL suggested using X visual ID %d for config %d, but this is not ARGB", + nativeVisualId, (int)qeglCtx->config()); + vi.visualid = 0; + } + } + else { + qDebug("Using opaque X Visual ID (%d) provided by EGL", (int)vi.visualid); + vi = *chosenVisualInfo; + } XFree(chosenVisualInfo); } else { |