From c3fa7b2e1d32980218bcc5c11fe69050ec7d1913 Mon Sep 17 00:00:00 2001 From: bbedward Date: Tue, 14 Jul 2026 14:29:18 -0400 Subject: [PATCH] cava: more optimizations for visualizer related #2863 --- .../Modules/DankBar/Widgets/AudioVisualization.qml | 11 ++++++++--- quickshell/Modules/DankBar/Widgets/Media.qml | 7 ++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/quickshell/Modules/DankBar/Widgets/AudioVisualization.qml b/quickshell/Modules/DankBar/Widgets/AudioVisualization.qml index 86d02dfe4..4b2cdc7e2 100644 --- a/quickshell/Modules/DankBar/Widgets/AudioVisualization.qml +++ b/quickshell/Modules/DankBar/Widgets/AudioVisualization.qml @@ -50,10 +50,15 @@ Item { return; const n = i => { const x = v[i]; - return x <= 0 ? 0 : x >= 100 ? 1 : Math.sqrt(x * 0.01); + const level = x <= 0 ? 0 : x >= 100 ? 1 : Math.sqrt(x * 0.01); + return Math.round(level * 32) / 32; }; - bars.bandsA = Qt.vector4d(n(0), n(1), n(2), n(3)); - bars.bandsB = Qt.vector2d(n(4), n(5)); + const a = Qt.vector4d(n(0), n(1), n(2), n(3)); + const b = Qt.vector2d(n(4), n(5)); + if (a == bars.bandsA && b == bars.bandsB) + return; + bars.bandsA = a; + bars.bandsB = b; } } diff --git a/quickshell/Modules/DankBar/Widgets/Media.qml b/quickshell/Modules/DankBar/Widgets/Media.qml index 3dc23f75f..8171ee741 100644 --- a/quickshell/Modules/DankBar/Widgets/Media.qml +++ b/quickshell/Modules/DankBar/Widgets/Media.qml @@ -342,6 +342,7 @@ BasePill { StyledText { id: mediaText + readonly property bool onScreen: Window.window?.visible ?? false property bool needsScrolling: implicitWidth > textContainer.width && SettingsData.scrollTitleEnabled property real scrollOffset: 0 property real textShift: 0 @@ -351,20 +352,20 @@ BasePill { font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale, root.barConfig?.maximizeWidgetText) color: Theme.widgetTextColor wrapMode: Text.NoWrap - x: (needsScrolling ? -scrollOffset : 0) + textShift + x: Math.round((needsScrolling ? -scrollOffset : 0) + textShift) opacity: 1 onTextChanged: { scrollOffset = 0; textShift = 0; - scrollAnimation.restart(); textChangeAnimation.restart(); } SequentialAnimation { id: scrollAnimation - running: mediaText.needsScrolling && textContainer.visible + running: mediaText.needsScrolling && textContainer.visible && mediaText.onScreen && root._isPlaying loops: Animation.Infinite + onStopped: mediaText.scrollOffset = 0 PauseAnimation { duration: 2000