WindowServer: Listen for muted state changes from AudioServer

Now the menu audio icon updates between muted/unmuted when anything in
the system changes the muted state. :^)
This commit is contained in:
Andreas Kling 2019-11-23 17:21:28 +01:00
parent 84cb91de38
commit f61ed8eab5
Notes: sideshowbarker 2024-07-19 11:06:28 +09:00

View File

@ -10,6 +10,15 @@
WSMenuManager::WSMenuManager()
{
m_audio_client = make<AClientConnection>();
m_audio_client->on_muted_state_change = [this](bool muted) {
if (m_audio_muted == muted)
return;
m_audio_muted = muted;
if (m_window) {
draw();
m_window->invalidate();
}
};
m_unmuted_bitmap = GraphicsBitmap::load_from_file("/res/icons/audio-unmuted.png");
m_muted_bitmap = GraphicsBitmap::load_from_file("/res/icons/audio-muted.png");
@ -153,11 +162,7 @@ void WSMenuManager::event(CEvent& event)
if (mouse_event.type() == WSEvent::MouseDown
&& mouse_event.button() == MouseButton::Left
&& m_audio_rect.contains(mouse_event.position())) {
// FIXME: This should listen for notifications from the AudioServer, once those actually exist.
// Right now, we won't notice if another program changes the AudioServer muted state.
m_audio_muted = !m_audio_muted;
m_audio_client->set_muted(m_audio_muted);
m_audio_client->set_muted(!m_audio_muted);
draw();
m_window->invalidate();
}