From 8298bf0e2c86681bbbe0688ea7ff05abffe5f5da Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 22 Aug 2020 20:59:52 +0300 Subject: [PATCH] fix dock view geometry calculations --when background custom radius and shadow are applied the dock window geometry shouldnot change if these values are not altered. This is especially true when a dock is hiding its screen edge margin when there is a maximized window and the same time is hiding also its background shadows. In such case in the past because shadows were temporarily disabled the dock was constantly changing its geometry --- .../package/contents/ui/VisibilityManager.qml | 4 +++- .../contents/ui/background/MultiLayered.qml | 16 +++++++++------- .../contents/ui/background/types/Shadows.qml | 18 +++++++++++------- containment/package/contents/ui/main.qml | 4 ++++ 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index 01cb8f834..db55c2e69 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -82,6 +82,8 @@ Item{ return plasmoid.configuration.screenEdgeMargin; } + property int maxScreenEdgeMargin: root.behaveAsDockWithMask ? Math.max(0, plasmoid.configuration.screenEdgeMargin) : 0 + property int thicknessAutoHidden: LatteCore.WindowSystem.compositingActive ? 2 : 1 property int thicknessMid: finalScreenEdgeMargin + (1 + (0.65 * (parabolic.factor.maxZoom-1)))*(metrics.totals.thickness+extraZoomThickMask) //needed in some animations property int thicknessNormal: finalScreenEdgeMargin + Math.max(metrics.totals.thickness + extraNormalThickMask, background.thickness + background.shadows.headThickness) @@ -94,7 +96,7 @@ Item{ thicknessNormalOriginalValue : background.thickness + background.shadows.headThickness*/ property int thicknessNormalOriginalValue: finalScreenEdgeMargin + metrics.maxIconSize + (metrics.margin.maxThickness * 2) + extraNormalThickMask - property int thicknessZoomOriginal: finalScreenEdgeMargin + Math.max( ((metrics.maxIconSize+(metrics.margin.maxThickness * 2)) * parabolic.factor.maxZoom) + extraZoomThickMask, + property int thicknessZoomOriginal: maxScreenEdgeMargin + Math.max( ((metrics.maxIconSize+(metrics.margin.maxThickness * 2)) * parabolic.factor.maxZoom) + extraZoomThickMask, background.thickness + background.shadows.headThickness) //! when Latte behaves as Plasma panel diff --git a/containment/package/contents/ui/background/MultiLayered.qml b/containment/package/contents/ui/background/MultiLayered.qml index 83563a345..a1b2fe2e9 100644 --- a/containment/package/contents/ui/background/MultiLayered.qml +++ b/containment/package/contents/ui/background/MultiLayered.qml @@ -57,10 +57,10 @@ BackgroundProperties{ shadows.top: hasTopBorder ? (customShadowIsEnabled ? customShadow : shadowsSvgItem.margins.top) : 0 shadows.bottom: hasBottomBorder ? (customShadowIsEnabled ? customShadow : shadowsSvgItem.margins.bottom) : 0 - shadows.fixedLeft: customShadowIsEnabled ? customShadow : shadowsSvgItem.fixedMargins.left - shadows.fixedRight: customShadowIsEnabled ? customShadow : shadowsSvgItem.fixedMargins.right - shadows.fixedTop: customShadowIsEnabled ? customShadow : shadowsSvgItem.fixedMargins.top - shadows.fixedBottom: customShadowIsEnabled ? customShadow : shadowsSvgItem.fixedMargins.bottom + shadows.fixedLeft: (customDefShadowIsEnabled || customUserShadowIsEnabled) ? customShadow : shadowsSvgItem.fixedMargins.left + shadows.fixedRight: (customDefShadowIsEnabled || customUserShadowIsEnabled) ? customShadow : shadowsSvgItem.fixedMargins.right + shadows.fixedTop: (customDefShadowIsEnabled || customUserShadowIsEnabled) ? customShadow : shadowsSvgItem.fixedMargins.top + shadows.fixedBottom: (customDefShadowIsEnabled || customUserShadowIsEnabled) ? customShadow : shadowsSvgItem.fixedMargins.bottom //! it can accept negative values in DockMode screenEdgeMargin: root.screenEdgeMarginEnabled ? metrics.margin.screenEdge - shadows.tailThickness : -shadows.tailThickness @@ -165,12 +165,14 @@ BackgroundProperties{ property int animationTime: 6*animations.speedFactor.current*animations.duration.small //! CustomShadowedRectangle properties - readonly property bool customShadowedRectangleIsEnabled: customRadiusIsEnabled || customShadowIsEnabled + readonly property bool customShadowedRectangleIsEnabled: customRadiusIsEnabled || (customDefShadowIsEnabled || customUserShadowIsEnabled) readonly property bool customShadowIsSupported: LatteCore.WindowSystem.compositingActive && kirigamiLibraryIsFound - && panelShadowsActive - readonly property bool customShadowIsEnabled: customDefShadowIsEnabled || customUserShadowIsEnabled + + //!current shadow state but do not change other values of normal mode, for example if a Dock hides its screen edge thickness + //!shouldnt change the fact that customShadowedRectangle is still used + readonly property bool customShadowIsEnabled: (customDefShadowIsEnabled || customUserShadowIsEnabled) && panelShadowsActive readonly property bool customDefShadowIsEnabled: customShadowIsSupported && !customUserShadowIsEnabled && customRadiusIsEnabled readonly property bool customUserShadowIsEnabled: customShadowIsSupported && plasmoid.configuration.backgroundShadowSize >= 0 diff --git a/containment/package/contents/ui/background/types/Shadows.qml b/containment/package/contents/ui/background/types/Shadows.qml index ad28d5525..160e7b7a9 100644 --- a/containment/package/contents/ui/background/types/Shadows.qml +++ b/containment/package/contents/ui/background/types/Shadows.qml @@ -46,14 +46,18 @@ QtObject{ } readonly property int headThickness: { - if (plasmoid.location === PlasmaCore.Types.LeftEdge) { - return right; - } else if (plasmoid.location === PlasmaCore.Types.RightEdge) { - return left; - } else if (plasmoid.location === PlasmaCore.Types.TopEdge) { - return bottom; + if (!backgroundShadowsInRegularStateEnabled) { + return 0; } - return top; + if (plasmoid.location === PlasmaCore.Types.LeftEdge) { + return fixedRight; + } else if (plasmoid.location === PlasmaCore.Types.RightEdge) { + return fixedLeft; + } else if (plasmoid.location === PlasmaCore.Types.TopEdge) { + return fixedBottom; + } + + return fixedTop; } } diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index aa3087413..53b3696f8 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -303,6 +303,10 @@ Item { property int panelEdgeSpacing: Math.max(background.lengthMargins, 1.5*appShadowSize) property int panelTransparency: plasmoid.configuration.panelTransparency //user set + property bool backgroundShadowsInRegularStateEnabled: LatteCore.WindowSystem.compositingActive + && userShowPanelBackground + && plasmoid.configuration.panelShadows + property bool panelShadowsActive: { if (!userShowPanelBackground) { return false;