QPlatformWindow::screenForGeometry(): Use mapToGlobal().

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ø <tor.arne.vestbo@theqtcompany.com>
This commit is contained in:
Friedemann Kleint 2016-01-06 16:10:11 +01:00
parent 966e893151
commit 9915630d08

View File

@ -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()) {