Win: fix wrong mouse leave event generation

When Qt runs in process with low integrity level,
and place child QWindow to HWND from less restricted process,
ChildWindowFromPointEx could fail with ERROR_ACCESS_DENIED
and QWindowsScreen::windowAt will return 0 despite mouse is on window.

Task-number: QTBUG-44332
Change-Id: I07e1594b90cbde8a9496f8d53ef247a7c69d8715
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
Sergey Radionov 2015-02-06 15:48:02 +06:00
parent 68293395ed
commit 34ea269b3b

View File

@ -271,6 +271,16 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
QWindow *currentWindowUnderMouse = platformWindow->hasMouseCapture() ?
QWindowsScreen::windowAt(globalPosition, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT) : window;
// QTBUG-44332: When Qt is running at low integrity level and
// a Qt Window is parented on a Window of a higher integrity process
// using QWindow::fromWinId() (for example, Qt running in a browser plugin)
// ChildWindowFromPointEx() may not find the Qt window (failing with ERROR_ACCESS_DENIED)
if (!currentWindowUnderMouse) {
const QRect clientRect(QPoint(0, 0), window->size());
if (clientRect.contains(winEventPosition / QWindowsScaling::factor()))
currentWindowUnderMouse = window;
}
compressMouseMove(&msg);
// Qt expects the platform plugin to capture the mouse on
// any button press until release.