diff --git a/Kvantum/style/Kvantum.cpp b/Kvantum/style/Kvantum.cpp index 94fcc72c..8f961543 100644 --- a/Kvantum/style/Kvantum.cpp +++ b/Kvantum/style/Kvantum.cpp @@ -3105,9 +3105,19 @@ void Style::drawPrimitive(QStyle::PrimitiveElement element, QRect r = option->rect; theme_spec tspec_now = settings_->getCompositeSpec(); - bool isTranslucent(!noComposite_ && widget && translucentWidgets_.contains(widget) - /* detached (Qt5) menus may come here because of setSurfaceFormat() */ - && !widget->testAttribute(Qt::WA_X11NetWmWindowTypeMenu)); + bool isTranslucent(!noComposite_ && widget && translucentWidgets_.contains(widget)); +#if (QT_VERSION >= QT_VERSION_CHECK(6,8,0)) + /* NOTE: This is a workaround for artifacts under Wayland. */ + if (isTranslucent && !tspec_.isX11) + { + auto origMode = painter->compositionMode(); + painter->setCompositionMode(QPainter::CompositionMode_Clear); + painter->fillRect(r, Qt::transparent); + painter->setCompositionMode(origMode); + } +#endif + /* detached (Qt5) menus may come here because of setSurfaceFormat() */ + isTranslucent = isTranslucent && !widget->testAttribute(Qt::WA_X11NetWmWindowTypeMenu); if (tspec_.spread_menuitems && (tspec_.shadowless_popup || noComposite_ || !tspec_now.composite)) @@ -3120,17 +3130,6 @@ void Style::drawPrimitive(QStyle::PrimitiveElement element, } fspec.top = fspec.bottom = pixelMetric(PM_MenuVMargin,option,widget); -#if (QT_VERSION >= QT_VERSION_CHECK(6,8,0)) - /* NOTE: This is a workaround for artifacts under Wayland. */ - if (isTranslucent && !tspec_.isX11) - { - auto origMode = painter->compositionMode(); - painter->setCompositionMode(QPainter::CompositionMode_Clear); - painter->fillRect(r, Qt::transparent); - painter->setCompositionMode(origMode); - } -#endif - if (!tspec_.shadowless_popup && isTranslucent && tspec_now.menu_shadow_depth > 0 && fspec.left >= tspec_now.menu_shadow_depth // otherwise shadow will have no meaning @@ -3273,9 +3272,20 @@ void Style::drawPrimitive(QStyle::PrimitiveElement element, fspec.top = fspec.bottom = pixelMetric(PM_MenuVMargin,option,widget); QRect r = option->rect; theme_spec tspec_now = settings_->getCompositeSpec(); - bool isTranslucent(!noComposite_ && widget && translucentWidgets_.contains(widget) - /* detached (Qt5) menus may come here because of setSurfaceFormat() */ - && !widget->testAttribute(Qt::WA_X11NetWmWindowTypeMenu)); + bool isTranslucent(!noComposite_ && widget && translucentWidgets_.contains(widget)); +#if (QT_VERSION >= QT_VERSION_CHECK(6,8,0)) + /* NOTE: This is a workaround for artifacts under Wayland. */ + if (isTranslucent && !tspec_.isX11) + { + auto origMode = painter->compositionMode(); + painter->setCompositionMode(QPainter::CompositionMode_Clear); + painter->fillRect(r, Qt::transparent); + painter->setCompositionMode(origMode); + } +#endif + /* detached (Qt5) menus may come here because of setSurfaceFormat() */ + isTranslucent = isTranslucent && !widget->testAttribute(Qt::WA_X11NetWmWindowTypeMenu); + if (tspec_.spread_menuitems && (tspec_.shadowless_popup || noComposite_ || !tspec_now.composite)) { // PM_MenuHMargin is zero but we draw the frame (this condition was used in getMenuMargin()) @@ -3286,17 +3296,6 @@ void Style::drawPrimitive(QStyle::PrimitiveElement element, fspec.left = fspec.right = pixelMetric(PM_MenuHMargin,option,widget); } -#if (QT_VERSION >= QT_VERSION_CHECK(6,8,0)) - /* NOTE: This is a workaround for artifacts under Wayland. */ - if (isTranslucent && !tspec_.isX11) - { - auto origMode = painter->compositionMode(); - painter->setCompositionMode(QPainter::CompositionMode_Clear); - painter->fillRect(r, Qt::transparent); - painter->setCompositionMode(origMode); - } -#endif - if (!tspec_.shadowless_popup && isTranslucent && tspec_now.menu_shadow_depth > 0 && fspec.left >= tspec_now.menu_shadow_depth // otherwise shadow will have no meaning