summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsmousehandler.cpp
diff options
context:
space:
mode:
authorAlexandra Cherdantseva <neluhus.vagus@gmail.com>2017-12-13 17:29:49 +0300
committerAlexandra Cherdantseva <neluhus.vagus@gmail.com>2018-05-16 09:02:40 +0000
commit9c707f140e96937f2ea256a6a93dc827328f22ad (patch)
tree793a8cd8ba5e8b37dbfdeff392d28265548d00a2 /src/plugins/platforms/windows/qwindowsmousehandler.cpp
parentb1452011282bfd0213b9f35b446e4970cb60d112 (diff)
Windows Platform: Redirect wheel event to a window under mouse cursor
Revert a part of af5c8d04fb0c9ddda58925e4862e857c78a5e563 which affected mouse wheel event redirection. Task-number: QTBUG-63979 Change-Id: Ice88675aadbb8a7477b3758a607db5979d62562c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alexandra Cherdantseva <neluhus.vagus@gmail.com> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsmousehandler.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 814291c54a..17851618b4 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -395,10 +395,24 @@ static bool isValidWheelReceiver(QWindow *candidate)
static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int delta,
Qt::Orientation orientation, Qt::KeyboardModifiers mods)
{
+ // Redirect wheel event to one of the following, in order of preference:
+ // 1) The window under mouse
+ // 2) The window receiving the event
// If a window is blocked by modality, it can't get the event.
- if (isValidWheelReceiver(window)) {
- QWindowSystemInterface::handleWheelEvent(window,
- QWindowsGeometryHint::mapFromGlobal(window, globalPos),
+
+ QWindow *receiver = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE);
+ while (receiver && receiver->flags().testFlag(Qt::WindowTransparentForInput))
+ receiver = receiver->parent();
+ bool handleEvent = true;
+ if (!isValidWheelReceiver(receiver)) {
+ receiver = window;
+ if (!isValidWheelReceiver(receiver))
+ handleEvent = false;
+ }
+
+ if (handleEvent) {
+ QWindowSystemInterface::handleWheelEvent(receiver,
+ QWindowsGeometryHint::mapFromGlobal(receiver, globalPos),
globalPos, delta, orientation, mods);
}
}