Skip to content

Commit db4de55

Browse files
committed
popout: decouple shadow from content layer
1 parent 37ecbbb commit db4de55

1 file changed

Lines changed: 29 additions & 13 deletions

File tree

quickshell/Widgets/DankPopout.qml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ Item {
214214
onTriggered: root._resizeActive = false
215215
}
216216

217-
218217
readonly property real alignedX: Theme.snap((() => {
219218
const useAutoGaps = storedBarConfig?.popupGapsAuto !== undefined ? storedBarConfig.popupGapsAuto : true;
220219
const manualGapValue = storedBarConfig?.popupGapsManual !== undefined ? storedBarConfig.popupGapsManual : 4;
@@ -470,16 +469,18 @@ Item {
470469
}
471470
}
472471

473-
Item {
474-
id: contentWrapper
472+
Rectangle {
473+
id: shadowSource
475474
anchors.centerIn: parent
476475
width: parent.width
477476
height: parent.height
478-
opacity: shouldBeVisible ? 1 : 0
479-
visible: opacity > 0
480-
scale: contentContainer.scaleValue
481-
x: Theme.snap(contentContainer.animX + (parent.width - width) * (1 - contentContainer.scaleValue) * 0.5, root.dpr)
482-
y: Theme.snap(contentContainer.animY + (parent.height - height) * (1 - contentContainer.scaleValue) * 0.5, root.dpr)
477+
radius: Theme.cornerRadius
478+
color: "black"
479+
visible: false
480+
opacity: contentWrapper.opacity
481+
scale: contentWrapper.scale
482+
x: contentWrapper.x
483+
y: contentWrapper.y
483484

484485
property real shadowBlurPx: 10
485486
property real shadowSpreadPx: 0
@@ -488,23 +489,38 @@ Item {
488489
readonly property real effectiveShadowAlpha: Math.max(0, Math.min(1, shadowBaseAlpha * popupSurfaceAlpha))
489490
readonly property int blurMax: 64
490491

491-
layer.enabled: contentWrapper.opacity < 1 && Quickshell.env("DMS_DISABLE_LAYER") !== "true" && Quickshell.env("DMS_DISABLE_LAYER") !== "1" && !(root.suspendShadowWhileResizing && root._resizeActive)
492+
layer.enabled: Quickshell.env("DMS_DISABLE_LAYER") !== "true" && Quickshell.env("DMS_DISABLE_LAYER") !== "1" && !(root.suspendShadowWhileResizing && root._resizeActive)
492493
layer.smooth: false
493-
layer.textureSize: root.dpr > 1 ? Qt.size(Math.ceil(width * root.dpr), Math.ceil(height * root.dpr)) : Qt.size(0, 0)
494494

495495
layer.effect: MultiEffect {
496496
id: shadowFx
497497
autoPaddingEnabled: true
498498
shadowEnabled: true
499499
blurEnabled: false
500500
maskEnabled: false
501-
shadowBlur: Math.max(0, Math.min(1, contentWrapper.shadowBlurPx / contentWrapper.blurMax))
502-
shadowScale: 1 + (2 * contentWrapper.shadowSpreadPx) / Math.max(1, Math.min(contentWrapper.width, contentWrapper.height))
501+
shadowBlur: Math.max(0, Math.min(1, shadowSource.shadowBlurPx / shadowSource.blurMax))
502+
shadowScale: 1 + (2 * shadowSource.shadowSpreadPx) / Math.max(1, Math.min(shadowSource.width, shadowSource.height))
503503
shadowColor: {
504504
const baseColor = Theme.isLightMode ? Qt.rgba(0, 0, 0, 1) : Theme.surfaceContainerHighest;
505-
return Theme.withAlpha(baseColor, contentWrapper.effectiveShadowAlpha);
505+
return Theme.withAlpha(baseColor, shadowSource.effectiveShadowAlpha);
506506
}
507507
}
508+
}
509+
510+
Item {
511+
id: contentWrapper
512+
anchors.centerIn: parent
513+
width: parent.width
514+
height: parent.height
515+
opacity: shouldBeVisible ? 1 : 0
516+
visible: opacity > 0
517+
scale: contentContainer.scaleValue
518+
x: Theme.snap(contentContainer.animX + (parent.width - width) * (1 - contentContainer.scaleValue) * 0.5, root.dpr)
519+
y: Theme.snap(contentContainer.animY + (parent.height - height) * (1 - contentContainer.scaleValue) * 0.5, root.dpr)
520+
521+
layer.enabled: contentWrapper.opacity < 1
522+
layer.smooth: false
523+
layer.textureSize: root.dpr > 1 ? Qt.size(Math.ceil(width * root.dpr), Math.ceil(height * root.dpr)) : Qt.size(0, 0)
508524

509525
Behavior on opacity {
510526
NumberAnimation {

0 commit comments

Comments
 (0)