mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
AudioPanel: suppress OSD when toggle mute/unmute to prevent overlapping
This commit is contained in:
+6
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user