mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 03:58:12 +00:00
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:
parent
84cb91de38
commit
f61ed8eab5
1 changed files with 10 additions and 5 deletions
|
@ -10,6 +10,15 @@
|
||||||
WSMenuManager::WSMenuManager()
|
WSMenuManager::WSMenuManager()
|
||||||
{
|
{
|
||||||
m_audio_client = make<AClientConnection>();
|
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_unmuted_bitmap = GraphicsBitmap::load_from_file("/res/icons/audio-unmuted.png");
|
||||||
m_muted_bitmap = GraphicsBitmap::load_from_file("/res/icons/audio-muted.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
|
if (mouse_event.type() == WSEvent::MouseDown
|
||||||
&& mouse_event.button() == MouseButton::Left
|
&& mouse_event.button() == MouseButton::Left
|
||||||
&& m_audio_rect.contains(mouse_event.position())) {
|
&& m_audio_rect.contains(mouse_event.position())) {
|
||||||
|
m_audio_client->set_muted(!m_audio_muted);
|
||||||
// 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);
|
|
||||||
draw();
|
draw();
|
||||||
m_window->invalidate();
|
m_window->invalidate();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue