feat(widgets/volume): add "Hide When Inactive" toggle to volume widget - #3927
feat(widgets/volume): add "Hide When Inactive" toggle to volume widget#3927Aron-dxd wants to merge 3 commits into
Conversation
[P1] Required clang-tidy check failssrc/shell/bar/widgets/volume_widget.cpp:113 isActive = std::any_of(captures.begin(), captures.end(), ...);The repository’s required scoped lint reports: Use: isActive = std::ranges::any_of(captures, [](const auto& capture) {
return capture.kind == PrivacyCaptureKind::Microphone;
});[P2] Output stream existence does not mean active playbacksrc/shell/bar/widgets/volume_widget.cpp:117 isActive = !m_audio->state().programOutputs.empty();programOutputs is the application-volume inventory. PipeWireService::rebuildState() adds every PipeWire distinguishes RUNNING, IDLE, and SUSPENDED node states, but NodeData/AudioNode currently
Reference: PipeWire node states |
|
Fixed the warning and added PipeWire node state to |
|
The prior clang-tidy finding is fixed. The output check now tests AudioNodeState::Running, but the [P1] Rebuild AudioState when node state changessrc/pipewire/pipewire_service.cpp:1154-1164 onNodeInfo() writes the latest PipeWire state into nd.nodeState, but the rebuildState() condition For an already-classified Stream/Output/Audio, a state-only callback has:
Therefore rebuildState() is skipped. m_audio->state().programOutputs retains its old state, so the
Capture the previous state, detect a transition, and include that transition in the rebuild |
… for programs streams.
|
Can you check now? On a side note, when I was on google meet, the stream stayed in the Running state even after ending the call(without closing the meet tab). But that is probably something with browsers/google meet. |
Summary
This pull request adds an optional toggle to hide the volume widget when it is not in use. When enabled, the widget will hide itself unless the device(output or input) is currently in use. In the case of inputs, it's hidden unless some application is capturing audio from a microphone. For outputs, the widget is hidden unless any application is currently playing audio.
Motivation
An input volume widget that is always visible even when nothing is capturing audio adds clutter to a bar for those who want only relevant controls. This lets people configure the widget to be hidden when it isn't relevant.
Type of Change
Related Issue
Closes #3917
Testing
just formatandjust build. Both passed.just testpasses 79/80.process_testfails in the same manner on a cleanmainManual Coverage
Screenshots / Videos
Checklist
CONTRIBUTING.md.just formatwith clang-format v22+ installed, or this PR has no code changes.assets/translations/en.json, or this PR adds no new user-facing strings.Additional Notes
The original issue only asked for a toggle in the case of microphone. A single setting for when a device is not in use in both input and output cases seemed more consistent than adding a setting that silently does nothing for output widgets or conditionally rendering the toggle only when input is selected. I also didn't find any widgets that do conditional rendering of a setting based on the value of another.
This PR also only checks capture activity and not device presence. A mic that is connected but idle will be treated the same as no mic present. In both cases, the widget will be hidden when the toggle is enabled.