Go to file
Volker Hilsheimer 5afb04d79b Mac: close popups opened on inactive application on relevant user action
On macOS, users can right-click into an inactive application to open a
context menu without activating the application. Qt handles a number of
events to close open popups (window deactivating or a mouse press
outside the popup), but none of those will get called when the
application is already inactive. So the popup might stay open (and on
top of the window stack) when the user clicks into other applications,
or activates another window.

To fix this we need to watch for events outside of the Qt application on
which we need to close the popup: when the user presses a mouse button,
or activates another application using Cmd-Tab. But we don't want to
monitor for key events, as that requires user permission. Use a global
event monitor to watch for mouse presses, and an notification observer
to watch for application activations, and respond by closing all popups
(and removing the monitor and observer again).

Use the monitor as well to watch for mouse moves, and pass only those
events through the Qt event system so that mouse tracking in the menu
works even if the application is inactive. This change brings back a
version of the global event monitor we had in Qt 5.15.

However, a press into our own menu will trigger the activation observer
after the application became active, which would now close the menu. We
don't want that, so we also need to remove the observer when the
application becomes active (which makes sense anyway, as we will get
regular events from then on).

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-105474
Change-Id: I18573fcda09a46c27730bd670a795f4d467aab01
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-08-22 20:10:13 +02:00
.github/workflows Repair github action workflow 2021-11-10 18:57:33 +01:00
bin Minor fixes for qt-configure-module 2022-06-27 17:55:19 +02:00
cmake Add possibility to store source files for interface targets 2022-08-19 23:53:11 +02:00
coin CMake: Allow building and running tests targeting iOS in other repos 2022-08-17 17:02:27 +02:00
config.tests Add license headers to cmake files 2022-08-03 17:14:55 +02:00
dist Add Qt 6.0.0 changes file 2020-11-16 10:02:08 +02:00
doc Add license headers to cmake files 2022-08-03 17:14:55 +02:00
examples QDomDocument: deprecate old setContent() overloads in favor of new ones 2022-08-17 17:02:27 +02:00
lib Purge all fonts 2015-08-18 19:59:14 +00:00
libexec Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
LICENSES Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
mkspecs wasm: include asyncify support unconditionally 2022-08-17 04:52:46 +02:00
qmake Rename QT_DISABLE_DEPRECATED_BEFORE -> QT_DISABLE_DEPRECATED_UP_TO 2022-08-19 23:52:05 +02:00
src Mac: close popups opened on inactive application on relevant user action 2022-08-22 20:10:13 +02:00
tests tst_qgraphicswidget: Avoid redeclaration of Size from MacTypes.h 2022-08-21 14:40:38 +02:00
util CMake: Rewrite double-conversion find module 2022-07-02 00:11:12 +02:00
.cmake.conf Bump version to 6.5.0 2022-06-06 13:23:59 +03:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore Assume qhelpgenerator in libexec instead of bin 2021-11-08 19:27:32 +01:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.tag Update the git-archive export options 2012-09-07 15:39:31 +02:00
CMakeLists.txt Add license headers to cmake files 2022-08-03 17:14:55 +02:00
conanfile.py Conan: Do not force 'qt_host_path' usage in cross-build context 2022-06-22 18:18:42 +03:00
config_help.txt Add -disable-deprecated-up-to parameter to configure script 2022-08-19 23:52:05 +02:00
configure Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
configure.bat Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
configure.cmake Add license headers to cmake files 2022-08-03 17:14:55 +02:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
qt_cmdline.cmake Add license headers to cmake files 2022-08-03 17:14:55 +02:00
sync.profile Remove deprecated qgl.h from sync.profile 2022-06-11 00:42:13 +02:00