diff options
-rw-r--r-- | src/main.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
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<OnlineLocalUser*>(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) |