From 9915630d0886434e8984904b1cadedc81dc78ca0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 Jan 2016 16:10:11 +0100 Subject: QPlatformWindow::screenForGeometry(): Use mapToGlobal(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QPlatformWindow::mapToGlobal() should be used to obtain global coordinates for foreign/embedded windows. They do not have a parent QWindow, but the geometry passed in might be local to their native parent window. For normal top-level windows, this is a no-op. Task-number: QTBUG-50206 Task-number: QTBUG-41186 Change-Id: I00889b28db69ae65057f48b9e74bd4d8cfffa136 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformwindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gui/kernel/qplatformwindow.cpp') diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index aea029b7f5..04532e82aa 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -484,8 +484,10 @@ QPlatformScreen *QPlatformWindow::screenForGeometry(const QRect &newGeometry) co { QPlatformScreen *currentScreen = screen(); QPlatformScreen *fallback = currentScreen; - //QRect::center can return a value outside the rectangle if it's empty - const QPoint center = newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center(); + // QRect::center can return a value outside the rectangle if it's empty. + // Apply mapToGlobal() in case it is a foreign/embedded window. + const QPoint center = + mapToGlobal(newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center()); if (!parent() && currentScreen && !currentScreen->geometry().contains(center)) { Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) { -- cgit v1.2.3