From 9a4b8cdd822104066cb10356fa1ac1e0f69f6b0c Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 3 Nov 2021 17:26:22 +0400 Subject: [PATCH] Use QPlatformScreen::logicalDpi instead of QScreen::logicalDotsPerInch QScreen::logicalDotsPerInch can be overriden by QT_FONT_DPI what is not good --- Telegram/SourceFiles/core/sandbox.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/core/sandbox.cpp b/Telegram/SourceFiles/core/sandbox.cpp index 1a4316cd6..440ff3547 100644 --- a/Telegram/SourceFiles/core/sandbox.cpp +++ b/Telegram/SourceFiles/core/sandbox.cpp @@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +#include namespace Core { namespace { @@ -183,7 +184,11 @@ void Sandbox::launchApplication() { } void Sandbox::setupScreenScale() { - const auto dpi = Sandbox::primaryScreen()->logicalDotsPerInch(); + const auto processDpi = [](const QDpi &dpi) { + return (dpi.first + dpi.second) * qreal(0.5); + }; + const auto dpi = processDpi( + Sandbox::primaryScreen()->handle()->logicalDpi()); LOG(("Primary screen DPI: %1").arg(dpi)); if (dpi <= 108) { cSetScreenScale(100); // 100%: 96 DPI (0-108)