From f3a4bc17ab4a68941b3c5bf48a9d5288cff2a8b7 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 6 Sep 2013 11:02:46 +0200 Subject: [PATCH] Keep the dockwidget with the mouse when moving to another screen When you move a dockwidget from one screen to another then it needs to be kept at the same position on the new screen, i.e. with the mouse pointer. This fix ensures that this is happening including when the screens may not 100% align up with each other. Task-number: QTBUG-33369 Change-Id: If414effdd0e0415629ca31a86f8bbe382dd29f80 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qcocoahelpers.mm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 197a2058afe..4a5696b35e9 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -599,7 +599,17 @@ NSRect qt_mac_flipRect(const QRect &rect, QWindow *window) { QPlatformScreen *onScreen = QPlatformScreen::platformScreenForWindow(window); int flippedY = onScreen->geometry().height() - (rect.y() + rect.height()); - + QList screens = QGuiApplication::screens(); + if (screens.size() > 1) { + int height = 0; + foreach (QScreen *scr, screens) + height = qMax(height, scr->size().height()); + int difference = height - onScreen->geometry().height(); + if (difference > 0) + flippedY += difference; + else + flippedY -= difference; + } // In case of automatic positioning, try to put as much of the window onscreen as possible. if (window->isTopLevel() && qt_window_private(const_cast(window))->positionAutomatic && flippedY < 0) flippedY = onScreen->geometry().height() - onScreen->availableGeometry().height() - onScreen->availableGeometry().y();