diff --git a/src/widgets/dplatformwindowhandle.cpp b/src/widgets/dplatformwindowhandle.cpp index 3de8ec6db..9f0a9754a 100644 --- a/src/widgets/dplatformwindowhandle.cpp +++ b/src/widgets/dplatformwindowhandle.cpp @@ -6,9 +6,27 @@ #include #include +#include +#include DWIDGET_BEGIN_NAMESPACE +static inline void ensureAlpha(QWidget *w) +{ + QWindow *handle = w->windowHandle(); + if (!handle) + return; + + QSurfaceFormat format = handle->requestedFormat(); + if ((w->windowFlags() & Qt::Window) && + handle->surfaceType() != QSurface::OpenGLSurface + && w->testAttribute(Qt::WA_TranslucentBackground)) { + format.setAlphaBufferSize(8); + } + + handle->setFormat(format); +} + static QWindow *ensureWindowHandle(QWidget *widget) { QWidget *window = widget->window(); @@ -27,6 +45,9 @@ static QWindow *ensureWindowHandle(QWidget *widget) handle = window->windowHandle(); window->setAttribute(Qt::WA_NativeWindow, false); + // FIX developer-center#5187 updateIsTranslucent + ensureAlpha(window); + // dxcb version >= 1.1.6 if (!DPlatformWindowHandle::pluginVersion().isEmpty()) { /// TODO: Avoid call parentWidget()->enforceNativeChildren().