From 8ed56bb4e4d9783154d05b8110082ee9272ddc18 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 23 Jan 2021 21:07:32 +0400 Subject: [PATCH] Don't mess GTK scale factor with other scaling settings Have this order for scaling settings: 1. devicePixelRatio 2. GTK 3. DPI --- .../platform/linux/linux_gtk_integration.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp index 8367a07f5..964dff0f1 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp @@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/linux/linux_gtk_integration_p.h" #include "base/platform/base_platform_info.h" -#include "platform/linux/linux_desktop_environment.h" #include "platform/linux/linux_xlib_helper.h" #include "platform/linux/linux_gdk_helper.h" #include "platform/linux/linux_gtk_file_dialog.h" @@ -211,22 +210,18 @@ bool CursorSizeShouldBeSet() { void SetScaleFactor() { Core::Sandbox::Instance().customEnterFromEventLoop([] { const auto integration = GtkIntegration::Instance(); - if (!integration || !DesktopEnvironment::IsGtkBased()) { + const auto ratio = Core::Sandbox::Instance().devicePixelRatio(); + if (!integration || ratio > 1.) { return; } - const auto scaleFactor = integration->scaleFactor(); - if (!scaleFactor.has_value()) { + const auto scaleFactor = integration->scaleFactor().value_or(1); + if (scaleFactor == 1) { return; } - LOG(("GTK scale factor: %1").arg(*scaleFactor)); - - const int scale = *scaleFactor - * 100 - / Core::Sandbox::Instance().devicePixelRatio(); - - cSetScreenScale(std::clamp(scale, 100, 300)); + LOG(("GTK scale factor: %1").arg(scaleFactor)); + cSetScreenScale(std::clamp(scaleFactor * 100, 100, 300)); }); }