QWidget: use window device pixel ratio for metrics

Most code uses the window/backing store DPR, except for this path that
uses the screen.
On wayland it's possible to get a different ratio for the screen and
window which causes some subtle rendering issues. For other platforms
behavior shouldn't change.

Change-Id: Ie390ba3bdfc183815df9e7e79e508d3e15d61f25
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
David Edmundson 2022-11-30 11:31:10 +00:00
parent cbd5bc0b58
commit 687a206b2e

View File

@ -12752,9 +12752,8 @@ int QWidget::metric(PaintDeviceMetric m) const
// Note: keep in sync with QBackingStorePrivate::backingStoreDevicePixelRatio()!
static bool downscale = qEnvironmentVariableIntValue("QT_WIDGETS_HIGHDPI_DOWNSCALE") > 0;
QWindow *window = this->window()->windowHandle();
if (downscale && window)
return std::ceil(window->devicePixelRatio());
if (window)
return downscale ? std::ceil(window->devicePixelRatio()) : window->devicePixelRatio();
return screen->devicePixelRatio();
};