summaryrefslogtreecommitdiff
path: root/src/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/windows')
-rw-r--r--src/windows/voice/voicewindow.cpp15
-rw-r--r--src/windows/voice/voicewindow.hpp1
2 files changed, 16 insertions, 0 deletions
diff --git a/src/windows/voice/voicewindow.cpp b/src/windows/voice/voicewindow.cpp
index 1ada8ee..079d0f7 100644
--- a/src/windows/voice/voicewindow.cpp
+++ b/src/windows/voice/voicewindow.cpp
@@ -36,6 +36,7 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
discord.signal_voice_user_disconnect().connect(sigc::mem_fun(*this, &VoiceWindow::OnUserDisconnect));
discord.signal_voice_user_connect().connect(sigc::mem_fun(*this, &VoiceWindow::OnUserConnect));
+ discord.signal_voice_speaker_state_changed().connect(sigc::mem_fun(*this, &VoiceWindow::OnSpeakerStateChanged));
if (const auto self_state = discord.GetVoiceState(discord.GetUserData().ID); self_state.has_value()) {
m_mute.set_active(util::FlagSet(self_state->second.Flags, VoiceStateFlags::SelfMute));
@@ -305,6 +306,20 @@ void VoiceWindow::OnUserDisconnect(Snowflake user_id, Snowflake from_channel_id)
}
}
+void VoiceWindow::OnSpeakerStateChanged(Snowflake channel_id, Snowflake user_id, bool is_speaker) {
+ if (m_channel_id != channel_id) return;
+ if (is_speaker) {
+ if (auto it = m_rows.find(user_id); it == m_rows.end()) {
+ m_user_list.add(*CreateRow(user_id));
+ }
+ } else {
+ if (auto it = m_rows.find(user_id); it != m_rows.end()) {
+ delete it->second;
+ m_rows.erase(it);
+ }
+ }
+}
+
VoiceWindow::type_signal_mute VoiceWindow::signal_mute() {
return m_signal_mute;
}
diff --git a/src/windows/voice/voicewindow.hpp b/src/windows/voice/voicewindow.hpp
index 5d73e97..fea998c 100644
--- a/src/windows/voice/voicewindow.hpp
+++ b/src/windows/voice/voicewindow.hpp
@@ -29,6 +29,7 @@ private:
void OnUserConnect(Snowflake user_id, Snowflake to_channel_id);
void OnUserDisconnect(Snowflake user_id, Snowflake from_channel_id);
+ void OnSpeakerStateChanged(Snowflake channel_id, Snowflake user_id, bool is_speaker);
void OnMuteChanged();
void OnDeafenChanged();