Skip to content

Commit b4ab72d

Browse files
committed
fix: blur mask sometimes not updating due to very frequent events
1 parent 97259be commit b4ab72d

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

package/contents/ui/main.qml

+25-13
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ PlasmoidItem {
450450
return getColor(widgetSettings.foregroundColor, targetIndex, rect.color, itemType, fgColorHolder)
451451
}
452452
}
453+
property bool throttleMaskUpdate: false
453454
Rectangle {
454455
id: fgColorHolder
455456
height: 6
@@ -581,7 +582,7 @@ PlasmoidItem {
581582
Component.onCompleted: {
582583
main.recolorCountChanged.connect(rect.recolor)
583584
main.updateUnified.connect(updateUnifyType)
584-
main.updateMasks.connect(updateMask)
585+
main.updateMasks.connect(updateMaskDebounced)
585586
recolorTimer.start()
586587
}
587588

@@ -1036,12 +1037,12 @@ PlasmoidItem {
10361037

10371038
onXChanged: {
10381039
// console.error("onXChanged()")
1039-
updateMask()
1040+
updateMaskDebounced()
10401041
}
10411042

10421043
onYChanged: {
10431044
// console.error("onYChanged()")
1044-
updateMask()
1045+
updateMaskDebounced()
10451046
}
10461047

10471048
onWidthChanged: {
@@ -1056,18 +1057,18 @@ PlasmoidItem {
10561057

10571058
onBlurMaskXChanged: {
10581059
// console.error("onBlurMaskXChanged()")
1059-
updateMask()
1060+
updateMaskDebounced()
10601061
}
10611062

10621063
onBlurMaskYChanged: {
10631064
// console.error("onBlurMaskYChanged()")
1064-
updateMask()
1065+
updateMaskDebounced()
10651066
}
10661067

1067-
onTopLeftRadiusChanged: updateMask()
1068-
onTopRightRadiusChanged: updateMask()
1069-
onBottomLeftRadiusChanged: updateMask()
1070-
onBottomRightRadiusChanged: updateMask()
1068+
onTopLeftRadiusChanged: updateMaskDebounced()
1069+
onTopRightRadiusChanged: updateMaskDebounced()
1070+
onBottomLeftRadiusChanged: updateMaskDebounced()
1071+
onBottomRightRadiusChanged: updateMaskDebounced()
10711072

10721073
// TODO find where does 16 and 8 come from instead of blindly hardcoding them
10731074
property real moveX: {
@@ -1084,7 +1085,7 @@ PlasmoidItem {
10841085

10851086
onVisibleChanged: {
10861087
main.updateUnified()
1087-
updateMask()
1088+
updateMaskDebounced()
10881089
}
10891090

10901091
onBlurBehindChanged: {
@@ -1095,7 +1096,18 @@ PlasmoidItem {
10951096
trayItemsDoingBlur[maskIndex] = blurBehind
10961097
anyTrayItemDoingBlur = Object.values(trayItemsDoingBlur).some(state => state)
10971098
}
1098-
updateMask()
1099+
updateMaskDebounced()
1100+
}
1101+
1102+
function updateMaskDebounced() {
1103+
if (rect.throttleMaskUpdate) {
1104+
return
1105+
}
1106+
rect.throttleMaskUpdate = true
1107+
Qt.callLater(function () {
1108+
updateMask()
1109+
rect.throttleMaskUpdate = false
1110+
})
10991111
}
11001112

11011113
function updateMask() {
@@ -1372,7 +1384,7 @@ PlasmoidItem {
13721384
}
13731385

13741386
onPanelLayoutCountChanged: {
1375-
console.log("onPanelLayoutCountChanged")
1387+
// console.log("onPanelLayoutCountChanged")
13761388
initAll()
13771389
// re-apply customizations after the widget stops being dagged around
13781390
for (var i = 0; i < panelLayout.children.length; i++) {
@@ -1574,7 +1586,7 @@ PlasmoidItem {
15741586

15751587
function showWidgets(panelLayout) {
15761588
if (!panelLayout) return
1577-
console.log("showWidgets()")
1589+
// console.log("showWidgets()")
15781590
for (var i in panelLayout.children) {
15791591
const child = panelLayout.children[i];
15801592
// name may not be available while gragging into the panel and

0 commit comments

Comments
 (0)