diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-03-01 01:01:44 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-03-01 01:01:44 -0500 |
commit | a09ad5cec016575ef3041367826a1bd1b261a9fc (patch) | |
tree | 8d8a988331f35d80e0b649a82d97d2bbf7abbd67 /src | |
parent | e37901bbbbc88ad62ee9f74e3217f656945f1afb (diff) | |
download | abaddon-portaudio-a09ad5cec016575ef3041367826a1bd1b261a9fc.tar.gz abaddon-portaudio-a09ad5cec016575ef3041367826a1bd1b261a9fc.zip |
dont notify if message channel is focused
Diffstat (limited to 'src')
-rw-r--r-- | src/abaddon.cpp | 8 | ||||
-rw-r--r-- | src/abaddon.hpp | 2 | ||||
-rw-r--r-- | src/notifications/notifications.cpp | 2 |
3 files changed, 12 insertions, 0 deletions
diff --git a/src/abaddon.cpp b/src/abaddon.cpp index 4daa53c..200183b 100644 --- a/src/abaddon.cpp +++ b/src/abaddon.cpp @@ -696,6 +696,14 @@ Glib::RefPtr<Gtk::Application> Abaddon::GetApp() { return m_gtk_app; } +bool Abaddon::IsMainWindowActive() { + return m_main_window->has_toplevel_focus(); +} + +Snowflake Abaddon::GetActiveChannelID() const noexcept { + return m_main_window->GetChatActiveChannel(); +} + void Abaddon::ActionConnect() { if (!m_discord.IsStarted()) StartDiscord(); diff --git a/src/abaddon.hpp b/src/abaddon.hpp index 56f5e04..2fbbcc0 100644 --- a/src/abaddon.hpp +++ b/src/abaddon.hpp @@ -97,6 +97,8 @@ public: static std::string GetStateCachePath(const std::string &path); [[nodiscard]] Glib::RefPtr<Gtk::Application> GetApp(); + [[nodiscard]] bool IsMainWindowActive(); + [[nodiscard]] Snowflake GetActiveChannelID() const noexcept; protected: void RunFirstTimeDiscordStartup(); diff --git a/src/notifications/notifications.cpp b/src/notifications/notifications.cpp index ed4a879..351cf32 100644 --- a/src/notifications/notifications.cpp +++ b/src/notifications/notifications.cpp @@ -10,6 +10,8 @@ void Notifications::CheckMessage(const Message &message) { auto &discord = Abaddon::Get().GetDiscordClient(); // ignore if the channel is muted if (discord.IsChannelMuted(message.ChannelID)) return; + // ignore if focused and message's channel is active + if (Abaddon::Get().IsMainWindowActive() && Abaddon::Get().GetActiveChannelID() == message.ChannelID) return; // notify messages in DMs const auto channel = discord.GetChannel(message.ChannelID); if (channel->IsDM()) { |