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;
|
globalPosition = winEventPosition;
|
||||||
clientPosition = QWindowsGeometryHint::mapFromGlobal(hwnd, globalPosition);
|
clientPosition = QWindowsGeometryHint::mapFromGlobal(hwnd, globalPosition);
|
||||||
} else {
|
} else {
|
||||||
clientPosition = winEventPosition;
|
|
||||||
globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, 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"
|
// 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) {
|
if (!discardEvent && mouseEvent.type != QEvent::None) {
|
||||||
QWindowSystemInterface::handleMouseEvent(window, device, winEventPosition, globalPosition, buttons,
|
QWindowSystemInterface::handleMouseEvent(window, device, clientPosition, globalPosition, buttons,
|
||||||
mouseEvent.button, mouseEvent.type,
|
mouseEvent.button, mouseEvent.type,
|
||||||
keyModifiers, source);
|
keyModifiers, source);
|
||||||
}
|
}
|
||||||
|
@ -768,8 +768,13 @@ bool QWindowsPointerHandler::translateMouseEvent(QWindow *window,
|
|||||||
globalPos = eventPos;
|
globalPos = eventPos;
|
||||||
localPos = QWindowsGeometryHint::mapFromGlobal(hwnd, eventPos);
|
localPos = QWindowsGeometryHint::mapFromGlobal(hwnd, eventPos);
|
||||||
} else {
|
} else {
|
||||||
localPos = eventPos;
|
|
||||||
globalPos = QWindowsGeometryHint::mapToGlobal(hwnd, 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();
|
const Qt::KeyboardModifiers keyModifiers = QWindowsKeyMapper::queryKeyboardModifiers();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user