summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-02-26 13:00:42 +0100
committerAndy Shaw <andy.shaw@qt.io>2020-02-27 22:56:26 +0100
commit09c5dfb73271614eb55c6d6c610c873fc9146a2f (patch)
tree13238e385027f4d4c07ccb3f4e65345b944c419b /src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
parentde1d51a3fd69a4961816ecfc3982424d5379a00f (diff)
Windows: Enable closing the system tray menu when clicking outside of it
In order for the system to close a menu when clicking outside of it or outside of the controlling window for the system tray then it needs to be at the foreground right before the menu is tracked. This makes it act like other system tray menus then. Change-Id: I663670c506cfd1e2ba59cd3e75b12e1f8ba17c33 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowssystemtrayicon.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowssystemtrayicon.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
index ab830e1461..9409d2db4d 100644
--- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
+++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
@@ -424,8 +424,12 @@ bool QWindowsSystemTrayIcon::winEvent(const MSG &message, long *result)
if (screen) {
emit contextMenuRequested(globalPos, screen);
emit activated(Context);
- if (m_menu)
+ if (m_menu) {
+ // Set the foreground window to the controlling window so that clicking outside
+ // of the menu or window will cause the menu to close
+ SetForegroundWindow(m_hwnd);
m_menu->trackPopupMenu(message.hwnd, globalPos.x(), globalPos.y());
+ }
}
}
break;