diff --git lib/utils/qtprops.h lib/utils/qtprops.h index 6589c779..2c52fdef 100644 --- lib/utils/qtprops.h +++ lib/utils/qtprops.h @@ -34,6 +34,7 @@ struct _QtcQWidgetProps { opacity(100), #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) prePolishing(false), + ensuringPolish(false), #else prePolished(false), prePolishStarted(false), @@ -45,6 +46,7 @@ struct _QtcQWidgetProps { int opacity; #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) bool prePolishing: 1; + bool ensuringPolish: 1; #else bool prePolished: 1; bool prePolishStarted: 1; diff --git qt5/style/argbhelper.cpp qt5/style/argbhelper.cpp index ccf17777..42838e54 100644 --- qt5/style/argbhelper.cpp +++ qt5/style/argbhelper.cpp @@ -21,33 +21,45 @@ #include "argbhelper.h" #include +#include #include +#include #include "private/qwidget_p.h" namespace QtCurve { __attribute__((hot)) void addAlphaChannel(QWidget *widget) { - QTC_RET_IF_FAIL(!qtcGetWid(widget)); - // Set this for better efficiency for now - widget->setAutoFillBackground(false); - QWindow *window = widget->windowHandle(); - QWidgetPrivate *widgetPrivate = - static_cast(QObjectPrivate::get(widget)); - widgetPrivate->updateIsOpaque(); - if (!window) { - widgetPrivate->createTLExtra(); - widgetPrivate->createTLSysExtra(); - window = widget->windowHandle(); - } - if (window) { - // Maybe we can register event filters and/or listen for signals - // like parent change or screen change on the QWidgetWindow - // so that we have a better change to update the alpha info - QSurfaceFormat format = window->format(); - format.setAlphaBufferSize(8); - window->setFormat(format); + if (qobject_cast(widget)) { + QtcQWidgetProps props(widget); + widget->setAttribute(Qt::WA_TranslucentBackground); + if (!props->ensuringPolish) { + props->ensuringPolish = true; + widget->ensurePolished(); + props->ensuringPolish = false; + } + } else { + QTC_RET_IF_FAIL(!qtcGetWid(widget)); + // Set this for better efficiency for now + widget->setAutoFillBackground(false); + QWindow *window = widget->windowHandle(); + QWidgetPrivate *widgetPrivate = + static_cast(QObjectPrivate::get(widget)); + widgetPrivate->updateIsOpaque(); + if (!window) { + widgetPrivate->createTLExtra(); + widgetPrivate->createTLSysExtra(); + window = widget->windowHandle(); + } + if (window) { + // Maybe we can register event filters and/or listen for signals + // like parent change or screen change on the QWidgetWindow + // so that we have a better change to update the alpha info + QSurfaceFormat format = window->format(); + format.setAlphaBufferSize(8); + window->setFormat(format); + } } }