From 960c0a8661e3df311a85075b0ff610c4031c6012 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 24 Jul 2009 17:41:56 +0200 Subject: Fix QSystemTrayIcon causing three activated signals on doubleclick The problem was that on Windows, we would activate on WM_LButtonUp, but a double click after activating will also generate a second WM_LButtonUp. Hence we get three activations. The fix was basically to filter out the second WM_LButtonUP, something we also do in qapplication_win.cpp. Task-number: 205499 Reviewed-by: denis --- src/gui/util/qsystemtrayicon_win.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index 85eae26..a0648a1 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -106,6 +106,7 @@ public: private: uint notifyIconSize; int maxTipLength; + bool ignoreNextMouseRelease; }; bool QSystemTrayIconSys::allowsMessages() @@ -128,7 +129,8 @@ bool QSystemTrayIconSys::supportsMessages() } QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object) - : hIcon(0), q(object) + : hIcon(0), q(object), ignoreNextMouseRelease(false) + { #ifndef Q_OS_WINCE notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, guidItem); // NOTIFYICONDATAW_V2_SIZE; @@ -311,10 +313,15 @@ bool QSystemTrayIconSys::winEvent( MSG *m, long *result ) switch (m->lParam) { case WM_LBUTTONUP: - emit q->activated(QSystemTrayIcon::Trigger); + if (ignoreNextMouseRelease) + ignoreNextMouseRelease = false; + else + emit q->activated(QSystemTrayIcon::Trigger); break; case WM_LBUTTONDBLCLK: + ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse + // release we must ignore it emit q->activated(QSystemTrayIcon::DoubleClick); break; -- cgit v0.12