AudioPanel: suppress OSD when toggle mute/unmute to prevent overlapping

This commit is contained in:
Ly-sec
2025-11-27 09:34:00 +01:00
parent f70e49ad9e
commit 778dce21c1
3 changed files with 38 additions and 2 deletions
+6 -1
View File
@@ -206,6 +206,8 @@ Variants {
}
function onMutedChanged() {
if (AudioService.consumeOutputOSDSuppression())
return;
showOSD(OSD.Type.Volume);
}
@@ -215,7 +217,10 @@ Variants {
}
function onInputMutedChanged() {
if (AudioService.hasInput)
if (!AudioService.hasInput)
return;
if (AudioService.consumeInputOSDSuppression())
return;
showOSD(OSD.Type.InputVolume);
}
+2
View File
@@ -157,6 +157,7 @@ SmartPanel {
tooltipText: I18n.tr("tooltips.output-muted")
baseSize: Style.baseWidgetSize * 0.8
onClicked: {
AudioService.suppressOutputOSD();
AudioService.setOutputMuted(!AudioService.muted);
}
}
@@ -166,6 +167,7 @@ SmartPanel {
tooltipText: I18n.tr("tooltips.input-muted")
baseSize: Style.baseWidgetSize * 0.8
onClicked: {
AudioService.suppressInputOSD();
AudioService.setInputMuted(!AudioService.inputMuted);
}
}
+29
View File
@@ -41,6 +41,35 @@ Singleton {
}
readonly property bool inputMuted: source?.audio?.muted ?? true
// Allow callers to skip the next OSD notification when they are already
// presenting volume state (e.g. the Audio Panel UI).
property int pendingOutputOSDSuppressions: 0
property int pendingInputOSDSuppressions: 0
function suppressOutputOSD() {
pendingOutputOSDSuppressions++;
}
function suppressInputOSD() {
pendingInputOSDSuppressions++;
}
function consumeOutputOSDSuppression(): bool {
if (pendingOutputOSDSuppressions <= 0) {
return false;
}
pendingOutputOSDSuppressions--;
return true;
}
function consumeInputOSDSuppression(): bool {
if (pendingInputOSDSuppressions <= 0) {
return false;
}
pendingInputOSDSuppressions--;
return true;
}
readonly property real stepVolume: Settings.data.audio.volumeStep / 100.0
// Filtered device nodes (non-stream sinks and sources)