From 2f0ffdd27e8750f1554d0d10174ce3e831e2ac9a Mon Sep 17 00:00:00 2001 From: sudden6 Date: Mon, 1 Aug 2016 20:58:14 +0200 Subject: [PATCH] fix(systemtray): don't activate qTox widget on tray icon click in Unity backend based on #3423 by @abbat --- src/widget/systemtrayicon.cpp | 5 +++++ src/widget/systemtrayicon.h | 1 + src/widget/systemtrayicon_private.h | 8 +------- src/widget/widget.cpp | 4 +++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/widget/systemtrayicon.cpp b/src/widget/systemtrayicon.cpp index 190a41dfe..2195cf807 100644 --- a/src/widget/systemtrayicon.cpp +++ b/src/widget/systemtrayicon.cpp @@ -356,3 +356,8 @@ void SystemTrayIcon::setIcon(QIcon &icon) qtIcon->setIcon(icon); } } + +SystrayBackendType SystemTrayIcon::backend() const +{ + return backendType; +} diff --git a/src/widget/systemtrayicon.h b/src/widget/systemtrayicon.h index 1ec26ea00..a63cb50b7 100644 --- a/src/widget/systemtrayicon.h +++ b/src/widget/systemtrayicon.h @@ -38,6 +38,7 @@ public: void hide(); void setVisible(bool); void setIcon(QIcon &icon); + SystrayBackendType backend() const; signals: void activated(QSystemTrayIcon::ActivationReason); diff --git a/src/widget/systemtrayicon_private.h b/src/widget/systemtrayicon_private.h index 4b973d400..bbe8c74d8 100644 --- a/src/widget/systemtrayicon_private.h +++ b/src/widget/systemtrayicon_private.h @@ -63,15 +63,9 @@ extern "C" { enum class SystrayBackendType { Qt, -#ifdef ENABLE_SYSTRAY_UNITY_BACKEND Unity, -#endif -#ifdef ENABLE_SYSTRAY_STATUSNOTIFIER_BACKEND StatusNotifier, -#endif -#ifdef ENABLE_SYSTRAY_GTK_BACKEND - GTK, -#endif + GTK }; #endif // SYSTEMTRAYICON_PRIVATE_H diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index dfe8a328f..c809be071 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -1815,7 +1815,9 @@ void Widget::onTryCreateTrayIcon() trayMenu->addAction(actionQuit); icon->setContextMenu(trayMenu); - connect(icon, &SystemTrayIcon::activated, this, &Widget::onIconClick); + // don't activate qTox widget on tray icon click in Unity backend (see #3419) + if (icon->backend() != SystrayBackendType::Unity) + connect(icon, &SystemTrayIcon::activated, this, &Widget::onIconClick); if (Settings::getInstance().getShowSystemTray()) {