From 91a9e7c0c5a04a037be937e1df753afda3056cb2 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 15 Jun 2019 16:11:41 +0300 Subject: [PATCH] improvements for effects area and painting --- app/view/effects.cpp | 141 +++++++++---------- app/wm/xwindowinterface.cpp | 13 +- containment/package/contents/ui/PanelBox.qml | 3 + 3 files changed, 71 insertions(+), 86 deletions(-) diff --git a/app/view/effects.cpp b/app/view/effects.cpp index c0843265e..5b4f56fe9 100644 --- a/app/view/effects.cpp +++ b/app/view/effects.cpp @@ -222,28 +222,28 @@ QRegion Effects::subtrackedMaskFromWindow(QRegion initialRegion, QQuickView *win QRect windowMask; //! we need to subtrack the mask areas that overlap with underlying window switch (m_view->location()) { - case Plasma::Types::TopEdge: - windowMask.setTopLeft(QPoint(start - m_view->x(), m_mask.y() + m_mask.height() - m_editShadow)); - windowMask.setSize(QSize(length, m_editShadow)); - break; - - case Plasma::Types::LeftEdge: - windowMask.setTopLeft(QPoint(m_mask.right() + 1 - m_editShadow, start - m_view->y())); - windowMask.setSize(QSize(m_editShadow, length)); - break; - - case Plasma::Types::RightEdge: - windowMask.setTopLeft(QPoint(m_mask.x(), start - m_view->y())); - windowMask.setSize(QSize(m_editShadow, length)); - break; - - case Plasma::Types::BottomEdge: - windowMask.setTopLeft(QPoint(start - m_view->x(), m_mask.y())); - windowMask.setSize(QSize(length, m_editShadow)); - break; - - default: - break; + case Plasma::Types::TopEdge: + windowMask.setTopLeft(QPoint(start - m_view->x(), m_mask.y() + m_mask.height() - m_editShadow)); + windowMask.setSize(QSize(length, m_editShadow)); + break; + + case Plasma::Types::LeftEdge: + windowMask.setTopLeft(QPoint(m_mask.right() + 1 - m_editShadow, start - m_view->y())); + windowMask.setSize(QSize(m_editShadow, length)); + break; + + case Plasma::Types::RightEdge: + windowMask.setTopLeft(QPoint(m_mask.x(), start - m_view->y())); + windowMask.setSize(QSize(m_editShadow, length)); + break; + + case Plasma::Types::BottomEdge: + windowMask.setTopLeft(QPoint(start - m_view->x(), m_mask.y())); + windowMask.setSize(QSize(length, m_editShadow)); + break; + + default: + break; } subtractedMask = subtractedMask.subtracted(windowMask); @@ -387,53 +387,40 @@ void Effects::updateEffects() return; } - if (!m_view->behaveAsPlasmaPanel()) { - if (m_drawEffects && !m_rect.isNull() && !m_rect.isEmpty()) { - //! this is used when compositing is disabled and provides - //! the correct way for the mask to be painted in order for - //! rounded corners to be shown correctly - if (!m_background) { - m_background = new Plasma::FrameSvg(this); - } - - if (m_background->imagePath() != "widgets/panel-background") { - m_background->setImagePath(QStringLiteral("widgets/panel-background")); - } + if (m_drawEffects && !m_rect.isNull() && !m_rect.isEmpty()) { + //! this is used when compositing is disabled and provides + //! the correct way for the mask to be painted in order for + //! rounded corners to be shown correctly + if (!m_background) { + m_background = new Plasma::FrameSvg(this); + } - m_background->setEnabledBorders(m_enabledBorders); - m_background->resizeFrame(m_rect.size()); - QRegion fixedMask = m_background->mask(); - fixedMask.translate(m_rect.x(), m_rect.y()); + if (m_background->imagePath() != "widgets/panel-background") { + m_background->setImagePath(QStringLiteral("widgets/panel-background")); + } - //! fix1, for KF5.32 that return empty QRegion's for the mask - if (fixedMask.isEmpty()) { - fixedMask = QRegion(m_rect); - } + m_background->setEnabledBorders(m_enabledBorders); + m_background->resizeFrame(m_rect.size()); + QRegion fixedMask = m_background->mask(); + fixedMask.translate(m_rect.x(), m_rect.y()); - KWindowEffects::enableBlurBehind(m_view->winId(), true, fixedMask); - - bool drawBackgroundEffect = m_theme.backgroundContrastEnabled() && (m_backgroundOpacity == 100); - //based on Breeze Dark theme behavior the enableBackgroundContrast even though it does accept - //a QRegion it uses only the first rect. The bug was that for Breeze Dark there was a line - //at the dock bottom that was distinguishing it from other themes - KWindowEffects::enableBackgroundContrast(m_view->winId(), drawBackgroundEffect, - m_theme.backgroundContrast(), - m_theme.backgroundIntensity(), - m_theme.backgroundSaturation(), - fixedMask.boundingRect()); - } else { - KWindowEffects::enableBlurBehind(m_view->winId(), false); - KWindowEffects::enableBackgroundContrast(m_view->winId(), false); + //! fix1, for KF5.32 that return empty QRegion's for the mask + if (fixedMask.isEmpty()) { + fixedMask = QRegion(m_rect); } - } else if (m_view->behaveAsPlasmaPanel() && m_drawEffects) { - KWindowEffects::enableBlurBehind(m_view->winId(), true); - bool drawBackgroundEffect = m_theme.backgroundContrastEnabled() && (m_backgroundOpacity == 100); + KWindowEffects::enableBlurBehind(m_view->winId(), true, fixedMask); - KWindowEffects::enableBackgroundContrast(m_view->winId(), drawBackgroundEffect, - m_theme.backgroundContrast(), - m_theme.backgroundIntensity(), - m_theme.backgroundSaturation()); + bool drawBackgroundEffect = m_theme.backgroundContrastEnabled() && (m_backgroundOpacity == 100); + //based on Breeze Dark theme behavior the enableBackgroundContrast even though it does accept + //a QRegion it uses only the first rect. The bug was that for Breeze Dark there was a line + //at the dock bottom that was distinguishing it from other themes + KWindowEffects::enableBackgroundContrast(m_view->winId(), + drawBackgroundEffect, + m_theme.backgroundContrast(), + m_theme.backgroundIntensity(), + m_theme.backgroundSaturation(), + fixedMask); } else { KWindowEffects::enableBlurBehind(m_view->winId(), false); KWindowEffects::enableBackgroundContrast(m_view->winId(), false); @@ -455,24 +442,24 @@ void Effects::updateEnabledBorders() Plasma::FrameSvg::EnabledBorders borders = Plasma::FrameSvg::AllBorders; switch (m_view->location()) { - case Plasma::Types::TopEdge: - borders &= ~Plasma::FrameSvg::TopBorder; - break; + case Plasma::Types::TopEdge: + borders &= ~Plasma::FrameSvg::TopBorder; + break; - case Plasma::Types::LeftEdge: - borders &= ~Plasma::FrameSvg::LeftBorder; - break; + case Plasma::Types::LeftEdge: + borders &= ~Plasma::FrameSvg::LeftBorder; + break; - case Plasma::Types::RightEdge: - borders &= ~Plasma::FrameSvg::RightBorder; - break; + case Plasma::Types::RightEdge: + borders &= ~Plasma::FrameSvg::RightBorder; + break; - case Plasma::Types::BottomEdge: - borders &= ~Plasma::FrameSvg::BottomBorder; - break; + case Plasma::Types::BottomEdge: + borders &= ~Plasma::FrameSvg::BottomBorder; + break; - default: - break; + default: + break; } if ((m_view->location() == Plasma::Types::LeftEdge || m_view->location() == Plasma::Types::RightEdge)) { diff --git a/app/wm/xwindowinterface.cpp b/app/wm/xwindowinterface.cpp index d68fc9b87..40351bd42 100644 --- a/app/wm/xwindowinterface.cpp +++ b/app/wm/xwindowinterface.cpp @@ -91,17 +91,12 @@ void XWindowInterface::setViewStruts(QWindow &view, const QRect &rect const QRect currentScreen {screen->geometry()}; const QRect wholeScreen {{0, 0}, screen->virtualSize()}; - //! WORKAROUND in order to fix KWin faulty behavior concerning struts - //! under !compositing mode. Under !compositing mode, kwin removes 1px. - //! from the struts - const int strutsGap = KWindowSystem::compositingActive ? 1 : 2; - switch (location) { case Plasma::Types::TopEdge: { const int topOffset {screen->geometry().top()}; strut.top_width = rect.height() + topOffset; strut.top_start = rect.x(); - strut.top_end = rect.x() + rect.width() - strutsGap; + strut.top_end = rect.x() + rect.width() - 1; break; } @@ -109,7 +104,7 @@ void XWindowInterface::setViewStruts(QWindow &view, const QRect &rect const int bottomOffset {wholeScreen.bottom() - currentScreen.bottom()}; strut.bottom_width = rect.height() + bottomOffset; strut.bottom_start = rect.x(); - strut.bottom_end = rect.x() + rect.width() - strutsGap; + strut.bottom_end = rect.x() + rect.width() - 1; break; } @@ -117,7 +112,7 @@ void XWindowInterface::setViewStruts(QWindow &view, const QRect &rect const int leftOffset = {screen->geometry().left()}; strut.left_width = rect.width() + leftOffset; strut.left_start = rect.y(); - strut.left_end = rect.y() + rect.height() - strutsGap; + strut.left_end = rect.y() + rect.height() - 1; break; } @@ -125,7 +120,7 @@ void XWindowInterface::setViewStruts(QWindow &view, const QRect &rect const int rightOffset = {wholeScreen.right() - currentScreen.right()}; strut.right_width = rect.width() + rightOffset; strut.right_start = rect.y(); - strut.right_end = rect.y() + rect.height() - strutsGap; + strut.right_end = rect.y() + rect.height() - 1; break; } diff --git a/containment/package/contents/ui/PanelBox.qml b/containment/package/contents/ui/PanelBox.qml index b75926fcd..d0ffc3a68 100644 --- a/containment/package/contents/ui/PanelBox.qml +++ b/containment/package/contents/ui/PanelBox.qml @@ -515,6 +515,9 @@ Item{ return "transparent"; } + borderWidth: 1 + borderColor: backgroundColor + roundness: { if (themeExtended) { switch(plasmoid.location) {