Skip to content

Commit

Permalink
refactor: improve blur mask updating speed
Browse files Browse the repository at this point in the history
Uses a signal instead of a timer so this should also use less system resources

refs: #74
  • Loading branch information
luisbocanegra committed Oct 7, 2024
1 parent c25c6c4 commit b9ddc3d
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,27 @@ PlasmoidItem {
property var panelColorizer: null
property var blurMask: panelColorizer?.mask ?? null
property var floatigness: panelElement?.floatingness ?? 0
property var panelWidth: panelElement?.width ?? 0
property var panelHeight: panelElement?.height ?? 0
property bool debug: false
signal recolorCountChanged()
signal refreshNeeded()
signal updateUnified()
signal updateMasks()

onForceRecolorCountChanged: {
// console.error("onForceRecolorCountChanged ->", forceRecolorCount)
recolorCountChanged()
}

onPanelWidthChanged: {
updateMasks()
}

onPanelHeightChanged: {
updateMasks()
}

Rectangle {
id: colorHolder
height: 0
Expand Down Expand Up @@ -427,6 +438,7 @@ PlasmoidItem {
Component.onCompleted: {
main.recolorCountChanged.connect(rect.recolor)
main.updateUnified.connect(updateUnifyType)
main.updateMasks.connect(updateMask)
recolorTimer.start()
}

Expand Down Expand Up @@ -813,16 +825,7 @@ PlasmoidItem {
}
}

Timer {
interval: 1000
running: true
repeat: true
onTriggered: {
position = Utils.getGlobalPosition(borderRec, panelElement)
}
}

property var position: Utils.getGlobalPosition(borderRec, panelElement)
property var position: Qt.point(0,0)
property var positionX: position.x
property var positionY: position.y
property var fl: floatigness
Expand Down Expand Up @@ -867,42 +870,37 @@ PlasmoidItem {
}

onXChanged: {
position = Utils.getGlobalPosition(borderRec, panelElement)
// console.error("onXChanged()")
updateMask()
}

onYChanged: {
position = Utils.getGlobalPosition(borderRec, panelElement)
// console.error("onYChanged()")
updateMask()
}

onWidthChanged: {
position = Utils.getGlobalPosition(borderRec, panelElement)
updateMask()
// console.error("onWidthChanged()")
main.updateMasks()
}

onHeightChanged: {
position = Utils.getGlobalPosition(borderRec, panelElement)
updateMask()
// console.error("onHeightChanged()")
main.updateMasks()
}

onBlurMaskXChanged: {
// console.error("onBlurMaskXChanged()")
updateMask()
}

onBlurMaskYChanged: {
// console.error("onBlurMaskYChanged()")
updateMask()
}

onFlChanged: {
position = Utils.getGlobalPosition(borderRec, panelElement)
}

onPositionXChanged: {
updateMask()
}

onPositionYChanged: {
// console.error("onFlChanged()")
updateMask()
}

Expand Down Expand Up @@ -933,7 +931,9 @@ PlasmoidItem {
}

function updateMask() {
if (panelColorizer === null) return
if (panelColorizer === null || !borderRec) return
// console.error("updateMask()", widgetName)
position = Utils.getGlobalPosition(borderRec, panelElement)
panelColorizer.updatePanelMask(
maskIndex,
borderRec,
Expand Down

0 comments on commit b9ddc3d

Please sign in to comment.