aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-22 12:51:46 +0200
committerdec05eba <dec05eba@protonmail.com>2018-05-22 12:51:49 +0200
commitb1e534009e564dee9517c0679230d380bd64f96c (patch)
treea07b503db739254898be6e8144d98b31711b0bd0 /src
parent0b2c312211823fc6c9947ec4036ab75cbe8383fb (diff)
Do not get notification from self
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp24
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)