summaryrefslogtreecommitdiffstats
path: root/src/widgets/util/qsystemtrayicon_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/util/qsystemtrayicon_win.cpp')
-rw-r--r--src/widgets/util/qsystemtrayicon_win.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp
index 209fb206e1..d273060f7b 100644
--- a/src/widgets/util/qsystemtrayicon_win.cpp
+++ b/src/widgets/util/qsystemtrayicon_win.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -117,7 +117,7 @@ public:
bool trayMessage(DWORD msg);
void setIconContents(NOTIFYICONDATA &data);
bool showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs);
- QRect findIconGeometry(const int a_iButtonID);
+ QRect findIconGeometry(UINT iconId);
HICON createIcon();
bool winEvent(MSG *m, long *result);
@@ -345,12 +345,12 @@ bool QSystemTrayIconSys::winEvent( MSG *m, long *result )
case NIN_KEYSELECT:
if (ignoreNextMouseRelease)
ignoreNextMouseRelease = false;
- else
+ else
emit q->activated(QSystemTrayIcon::Trigger);
break;
case WM_LBUTTONDBLCLK:
- ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse
+ ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse
// release we must ignore it
emit q->activated(QSystemTrayIcon::DoubleClick);
break;
@@ -413,8 +413,15 @@ void QSystemTrayIconPrivate::install_sys()
*
* If it fails an invalid rect is returned.
*/
-QRect QSystemTrayIconSys::findIconGeometry(const int iconId)
+
+QRect QSystemTrayIconSys::findIconGeometry(UINT iconId)
{
+ struct AppData
+ {
+ HWND hwnd;
+ UINT uID;
+ };
+
static PtrShell_NotifyIconGetRect Shell_NotifyIconGetRect =
(PtrShell_NotifyIconGetRect)QSystemLibrary::resolve(QLatin1String("shell32"),
"Shell_NotifyIconGetRect");
@@ -474,21 +481,18 @@ QRect QSystemTrayIconSys::findIconGeometry(const int iconId)
//search for our icon among all toolbar buttons
for (int toolbarButton = 0; toolbarButton < buttonCount; ++toolbarButton ) {
SIZE_T numBytes = 0;
- DWORD appData[2] = { 0, 0 };
+ AppData appData = { 0, 0 };
SendMessage(trayHandle, TB_GETBUTTON, toolbarButton , (LPARAM)data);
if (!ReadProcessMemory(trayProcess, data, &buttonData, sizeof(TBBUTTON), &numBytes))
continue;
- if (!ReadProcessMemory(trayProcess, (LPVOID) buttonData.dwData, appData, sizeof(appData), &numBytes))
+ if (!ReadProcessMemory(trayProcess, (LPVOID) buttonData.dwData, &appData, sizeof(AppData), &numBytes))
continue;
- int currentIconId = appData[1];
- HWND currentIconHandle = (HWND) appData[0];
bool isHidden = buttonData.fsState & TBSTATE_HIDDEN;
- if (currentIconHandle == m_hwnd &&
- currentIconId == iconId && !isHidden) {
+ if (m_hwnd == appData.hwnd && appData.uID == iconId && !isHidden) {
SendMessage(trayHandle, TB_GETITEMRECT, toolbarButton , (LPARAM)data);
RECT iconRect = {0, 0, 0, 0};
if(ReadProcessMemory(trayProcess, data, &iconRect, sizeof(RECT), &numBytes)) {