diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-05-19 14:18:21 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-05-19 14:52:54 (GMT) |
commit | 6241e39cff9311c943430ff2f31236b13618f2ac (patch) | |
tree | 471d4e01c1e3a4d2e67f189de5a384aa98526521 /src/plugins/platforms/xcb | |
parent | a3b627e1c5ce03a2500ab35c64729b1995639dcc (diff) | |
download | Qt-6241e39cff9311c943430ff2f31236b13618f2ac.zip Qt-6241e39cff9311c943430ff2f31236b13618f2ac.tar.gz Qt-6241e39cff9311c943430ff2f31236b13618f2ac.tar.bz2 |
Full translucent background support in xcb and xlib backend.
Make sure to pick an alpha visual also for non-GL surface types, and to
ask for alpha in the window format if the WA_TranslucentBackground
attribute is set.
Reviewed-by: Janusz Lewandowski
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 3 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 3365c22..0dd29eb 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -113,7 +113,8 @@ QXcbWindow::QXcbWindow(QWidget *tlw) #if defined(XCB_USE_GLX) || defined(XCB_USE_EGL) if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL - && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) + && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL) + || tlw->platformWindowFormat().alpha()) { #if defined(XCB_USE_GLX) XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat()); diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 38c01f9..88a54dc 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -54,6 +54,7 @@ #include <stdio.h> #include <qdebug.h> +#include <qpainter.h> class QXcbShmImage : public QXcbObject { @@ -189,6 +190,16 @@ QPaintDevice *QXcbWindowSurface::paintDevice() void QXcbWindowSurface::beginPaint(const QRegion ®ion) { m_image->preparePaint(region); + + if (m_image->image()->hasAlphaChannel()) { + QPainter p(m_image->image()); + p.setCompositionMode(QPainter::CompositionMode_Source); + const QVector<QRect> rects = region.rects(); + const QColor blank = Qt::transparent; + for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) { + p.fillRect(*it, blank); + } + } } void QXcbWindowSurface::endPaint(const QRegion &) |