From 687a206b2e3404b30ba24130294a92ea55a83dde Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 30 Nov 2022 11:31:10 +0000 Subject: [PATCH] QWidget: use window device pixel ratio for metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/widgets/kernel/qwidget.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 55bed86080..6a47e31d91 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -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(); };