diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-02-08 14:47:37 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-02-13 18:30:09 +0000 |
commit | 5c440880ba9846a137a436c864d958c4a8225c7a (patch) | |
tree | b8c67d06307fdd754b13d9f7dcabcbbb8af82038 | |
parent | 09e7a994d14a0582912551ca1342e3b695cf3a86 (diff) |
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 <Friedemann.Kleint@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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<QScreen *> siblings = screen->virtualSiblings(); if (siblings.size() > 1) { |