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>
This commit is contained in:
parent
09e7a994d1
commit
5c440880ba
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user