From 4c414f8fb60a3a84e09f43ae0161677f88d318ca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gy=C3=B6rgy=20Ball=C3=B3?= Date: Thu, 16 Feb 2017 08:41:08 +0100 Subject: [PATCH] Fix handling systray notifications Only toggle/activate the main window if the notification message comes from quassel. This fixes the problem that Quassel's main window is opened when the user clicks on any notification bubbles from other applications. Resolves GH-272. --- src/qtui/systraynotificationbackend.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/qtui/systraynotificationbackend.cpp b/src/qtui/systraynotificationbackend.cpp index b0b7be62..d96000e1 100644 --- a/src/qtui/systraynotificationbackend.cpp +++ b/src/qtui/systraynotificationbackend.cpp @@ -92,15 +92,16 @@ void SystrayNotificationBackend::close(uint notificationId) void SystrayNotificationBackend::notificationActivated(uint notificationId) { if (!_blockActivation) { - if (_notifications.count()) { - if (QtUi::mainWindow()->systemTray()->mode() == SystemTray::Legacy) - _blockActivation = true; // prevent double activation because both tray icon and bubble might send a signal - if (!notificationId) - notificationId = _notifications.count() ? _notifications.last().notificationId : 0; - emit activated(notificationId); + QList::iterator i = _notifications.begin(); + while (i != _notifications.end()) { + if (i->notificationId == notificationId) { + if (QtUi::mainWindow()->systemTray()->mode() == SystemTray::Legacy) + _blockActivation = true; // prevent double activation because both tray icon and bubble might send a signal + emit activated(notificationId); + break; + } + ++i; } - else - GraphicalUi::toggleMainWidget(); } } @@ -108,7 +109,10 @@ void SystrayNotificationBackend::notificationActivated(uint notificationId) void SystrayNotificationBackend::notificationActivated(SystemTray::ActivationReason reason) { if (reason == SystemTray::Trigger) { - notificationActivated(0); + if (_notifications.count()) + notificationActivated(_notifications.last().notificationId); + else + GraphicalUi::toggleMainWidget(); } } -- 2.20.1