From b1e534009e564dee9517c0679230d380bd64f96c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 22 May 2018 12:51:46 +0200 Subject: Do not get notification from self --- src/main.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 1ce032c..1c359ca 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,6 +27,7 @@ using namespace std; using namespace dchat; static bool focused = true; +static bool windowFocused = true; static void channelChangeUserNickname(Channel *channel, const StringView data, const odhtdb::Signature::PublicKey &userPublicKey) { @@ -125,14 +126,18 @@ static void channelAddStoredMessage(Channel *channel, const odhtdb::Hash &reques { string msg(decryptedData.data, decryptedData.size); channel->addLocalMessage(msg, user, ntp::NtpTimestamp::fromCombined(timestamp).seconds, requestHash); - if(!focused) + if(!windowFocused && channel->getLocalUser()->isOnlineUser()) { - stringReplaceChar(msg, "'", ""); - stringReplaceChar(msg, "\\", ""); - string cmd = "notify-send dchat '"; - cmd += msg; - cmd += "'"; - system(cmd.c_str()); + auto onlineLocalUser = static_cast(channel->getLocalUser()); + if(creatorPublicKey != onlineLocalUser->getPublicKey()) + { + stringReplaceChar(msg, "'", ""); + stringReplaceChar(msg, "\\", ""); + string cmd = "notify-send dchat '"; + cmd += msg; + cmd += "'"; + system(cmd.c_str()); + } } break; } @@ -878,6 +883,11 @@ int main(int argc, char **argv) //else if(event.type == sf::Event::MouseLeft) // window.setFramerateLimit(FRAMERATE_NOT_FOCUSED); + if(event.type == sf::Event::GainedFocus) + windowFocused = true; + else if(event.type == sf::Event::LostFocus) + windowFocused = false; + if(event.type == sf::Event::MouseEntered) focused = true; else if(event.type == sf::Event::MouseLeft) -- cgit v1.2.3