From 9fbc9547bae84c61dbf5d859bce721d7375ed9d1 Mon Sep 17 00:00:00 2001 From: imluketheduke Date: Mon, 19 Oct 2026 19:28:00 -0600 Subject: [PATCH] Fix dead device clicks in the default-device selector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setDefaultDevice() silently returned false whenever the *current* default could not be resolved to a backend identity — a routine state after device churn (dock replug, USB audio flap, BT reconnect, suspend/resume) — leaving every row visually enabled but dead until something else changed the default. The backend recomputes the previous default from routing state on its own, so pass previous:null instead of aborting. Also: - Surface every early-return as the direction's error text so a dead click reports *why* instead of no-opping. - Narrow row disabling to an actual in-flight default.set or scene apply; the backend 'busy' flag flaps during unrelated PipeWire churn and left rows unclickable for long stretches. --- qml/panels/Panel.qml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/qml/panels/Panel.qml b/qml/panels/Panel.qml index 96cce81..78590fc 100644 --- a/qml/panels/Panel.qml +++ b/qml/panels/Panel.qml @@ -1,4 +1,4 @@ -import QtQuick +import QtQuick 6.11 import QtQuick.Controls import Quickshell import Quickshell.Io @@ -860,10 +860,26 @@ Panel { function setDefaultDevice(node, previous, direction) { - if (!mutableAudioNode(node) || sceneController.busy || routeMutationBusy) return false + var fail = direction === "output" + ? function(message) { defaultOutputError = message } + : function(message) { defaultInputError = message } + if (!mutableAudioNode(node)) { + fail("That device just changed; wait a moment and retry") + return false + } + if (sceneController.busy || routeMutationBusy) { + fail("Audio is applying another change; retry in a moment") + return false + } var identity = audioService.identityForNode(node) - var previousIdentity = audioService.identityForNode(previous) - if (!identity || (previous && !previousIdentity)) return false + if (!identity) { + fail("Device snapshot is stale; wait a moment and retry") + return false + } + // A previous default that already left the graph cannot be resolved here. + // The backend recomputes it from routing state, so a stale previous must + // never block the whole switch. + var previousIdentity = previous ? audioService.identityForNode(previous) : null if (direction === "output") defaultOutputError = "" else defaultInputError = "" defaultSetPending = true @@ -1427,7 +1443,7 @@ Panel { preferredName: root.preferredOutputName label: root.nodeLabel(sinkDelegate.node) outputGroup: Model.isOutputGroupSink(sinkDelegate.node) - defaultSetBusy: root.sceneMutationBusy + defaultSetBusy: root.sceneController.busy || root.defaultSetPending hasCursor: root.cursorActive && root.focusSection === "output" && root.selectedIndex === sinkDelegate.rowIndex onHasCursorChanged: if (hasCursor) root.ensureCursorVisible(sinkDelegate) @@ -1564,7 +1580,7 @@ Panel { bar: root.bar preferredName: root.preferredInputName label: root.nodeLabel(sourceDelegate.node) - defaultSetBusy: root.sceneMutationBusy + defaultSetBusy: root.sceneController.busy || root.defaultSetPending hasCursor: root.cursorActive && root.focusSection === "input" && root.selectedIndex === sourceDelegate.rowIndex onHasCursorChanged: if (hasCursor) root.ensureCursorVisible(sourceDelegate)