Skip to content

Commit

Permalink
Completed workaround for artifacts of Qt 6.8 with translucency
Browse files Browse the repository at this point in the history
  • Loading branch information
tsujan committed Oct 23, 2024
1 parent 9e89530 commit 7fe724a
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions Kvantum/style/Kvantum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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())
Expand All @@ -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
Expand Down

0 comments on commit 7fe724a

Please sign in to comment.