high-dpi: Set screen on QWindow::setGeometry()
Keep (requested) geometry and screen in sync, which is required for correct high-dpi scaling. The platform plugin can still override with new geometry (and screen), as usual. This has previously been fixed/worked around for QDialog, see QTBUG-52735. That fix can now be removed in favor of this change in QWindow. Change-Id: Ieadb1bfee5fb966c5c2052e9daa5ba124a87f3cd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>bb10
parent
95bce5b185
commit
e8fabb2946
|
|
@ -529,6 +529,13 @@ void QWindowPrivate::create(bool recursive, WId nativeHandle)
|
|||
if (q->parent())
|
||||
q->parent()->create();
|
||||
|
||||
// QPlatformWindow will poll geometry() during construction below. Set the
|
||||
// screen here so that high-dpi scaling will use the correct scale factor.
|
||||
if (q->isTopLevel()) {
|
||||
if (QScreen *screen = screenForGeometry(geometry))
|
||||
setTopLevelScreen(screen, false);
|
||||
}
|
||||
|
||||
QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();
|
||||
platformWindow = nativeHandle ? platformIntegration->createForeignWindow(q, nativeHandle)
|
||||
: platformIntegration->createPlatformWindow(q);
|
||||
|
|
@ -1726,8 +1733,11 @@ void QWindow::setGeometry(const QRect &rect)
|
|||
|
||||
d->positionPolicy = QWindowPrivate::WindowFrameExclusive;
|
||||
if (d->platformWindow) {
|
||||
QRect nativeRect;
|
||||
QScreen *newScreen = d->screenForGeometry(rect);
|
||||
if (newScreen && isTopLevel())
|
||||
d->setTopLevelScreen(newScreen, true);
|
||||
|
||||
QRect nativeRect;
|
||||
if (newScreen && isTopLevel())
|
||||
nativeRect = QHighDpi::toNativePixels(rect, newScreen);
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue