Windows QPA: Fix mouse event position for QWindows with Qt::WindowTransparentForInput
The local position needs to be corrected when the Qt receiver window does not correspond to the native event receiver window. Fixes: QTBUG-97095 Pick-to: 6.2 5.15 Change-Id: Ic9fa3d84b6ee84ae5f8fa2408b0d60e35dbfa328 Reviewed-by: André de la Rocha <andre.rocha@qt.io>
This commit is contained in:
parent
58d64b770a
commit
36a6d17af0
@ -258,8 +258,13 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
|
||||
globalPosition = winEventPosition;
|
||||
clientPosition = QWindowsGeometryHint::mapFromGlobal(hwnd, globalPosition);
|
||||
} else {
|
||||
clientPosition = winEventPosition;
|
||||
globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, winEventPosition);
|
||||
auto targetHwnd = hwnd;
|
||||
if (auto *pw = window->handle())
|
||||
targetHwnd = HWND(pw->winId());
|
||||
clientPosition = targetHwnd == hwnd
|
||||
? winEventPosition
|
||||
: QWindowsGeometryHint::mapFromGlobal(targetHwnd, globalPosition);
|
||||
}
|
||||
|
||||
// Windows sends a mouse move with no buttons pressed to signal "Enter"
|
||||
@ -476,7 +481,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
|
||||
}
|
||||
|
||||
if (!discardEvent && mouseEvent.type != QEvent::None) {
|
||||
QWindowSystemInterface::handleMouseEvent(window, device, winEventPosition, globalPosition, buttons,
|
||||
QWindowSystemInterface::handleMouseEvent(window, device, clientPosition, globalPosition, buttons,
|
||||
mouseEvent.button, mouseEvent.type,
|
||||
keyModifiers, source);
|
||||
}
|
||||
|
@ -768,8 +768,13 @@ bool QWindowsPointerHandler::translateMouseEvent(QWindow *window,
|
||||
globalPos = eventPos;
|
||||
localPos = QWindowsGeometryHint::mapFromGlobal(hwnd, eventPos);
|
||||
} else {
|
||||
localPos = eventPos;
|
||||
globalPos = QWindowsGeometryHint::mapToGlobal(hwnd, eventPos);
|
||||
auto targetHwnd = hwnd;
|
||||
if (auto *pw = window->handle())
|
||||
targetHwnd = HWND(pw->winId());
|
||||
localPos = targetHwnd == hwnd
|
||||
? eventPos
|
||||
: QWindowsGeometryHint::mapFromGlobal(targetHwnd, globalPos);
|
||||
}
|
||||
|
||||
const Qt::KeyboardModifiers keyModifiers = QWindowsKeyMapper::queryKeyboardModifiers();
|
||||
|
Loading…
Reference in New Issue
Block a user