From 5c440880ba9846a137a436c864d958c4a8225c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 8 Feb 2017 14:47:37 +0100 Subject: Respect QWindow::screen() when computing QPlatformWindow::initialGeometry() Calling setScreen() on a QWindow doesn't move the window to that screen unless the new screen is a separate virtual desktop, as the window geometry is what determines the position of the window within each virtual desktop. But when mapping a QWindow that doesn't have a position explicitly set by the user, we try to resolve a reasonable position for it. In that case we should take the QWindow screen into account, as setting it to a non-primary screen is a good indication that the user wants the window to end up on that screen. If that's the case, it should override the logic of using the transient parent or the cursor position to choose which screen to place the window on. Change-Id: I591d872a93913173b20eb3da19aa63118fcf6b12 Reviewed-by: Friedemann Kleint Reviewed-by: Laszlo Agocs --- src/gui/kernel/qplatformwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gui/kernel/qplatformwindow.cpp') diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index bfb2deff50..5062bd1e77 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -561,7 +561,8 @@ bool QPlatformWindow::isAlertState() const // Return the effective screen for the initial geometry of a window. In a // multimonitor-setup, try to find the right screen by checking the transient // parent or the mouse cursor for parentless windows (cf QTBUG-34204, -// QDialog::adjustPosition()). +// QDialog::adjustPosition()), unless a non-primary screen has been set, +// in which case we try to respect that. static inline const QScreen *effectiveScreen(const QWindow *window) { if (!window) @@ -569,6 +570,8 @@ static inline const QScreen *effectiveScreen(const QWindow *window) const QScreen *screen = window->screen(); if (!screen) return QGuiApplication::primaryScreen(); + if (screen != QGuiApplication::primaryScreen()) + return screen; #ifndef QT_NO_CURSOR const QList siblings = screen->virtualSiblings(); if (siblings.size() > 1) { -- cgit v1.2.3