Don't mess GTK scale factor with other scaling settings

Have this order for scaling settings:
1. devicePixelRatio
2. GTK
3. DPI
This commit is contained in:
Ilya Fedin 2021-01-23 21:07:32 +04:00 committed by John Preston
parent 3793f7c3c9
commit 8ed56bb4e4

View file

@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/linux/linux_gtk_integration_p.h" #include "platform/linux/linux_gtk_integration_p.h"
#include "base/platform/base_platform_info.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_xlib_helper.h"
#include "platform/linux/linux_gdk_helper.h" #include "platform/linux/linux_gdk_helper.h"
#include "platform/linux/linux_gtk_file_dialog.h" #include "platform/linux/linux_gtk_file_dialog.h"
@ -211,22 +210,18 @@ bool CursorSizeShouldBeSet() {
void SetScaleFactor() { void SetScaleFactor() {
Core::Sandbox::Instance().customEnterFromEventLoop([] { Core::Sandbox::Instance().customEnterFromEventLoop([] {
const auto integration = GtkIntegration::Instance(); const auto integration = GtkIntegration::Instance();
if (!integration || !DesktopEnvironment::IsGtkBased()) { const auto ratio = Core::Sandbox::Instance().devicePixelRatio();
if (!integration || ratio > 1.) {
return; return;
} }
const auto scaleFactor = integration->scaleFactor(); const auto scaleFactor = integration->scaleFactor().value_or(1);
if (!scaleFactor.has_value()) { if (scaleFactor == 1) {
return; return;
} }
LOG(("GTK scale factor: %1").arg(*scaleFactor)); LOG(("GTK scale factor: %1").arg(scaleFactor));
cSetScreenScale(std::clamp(scaleFactor * 100, 100, 300));
const int scale = *scaleFactor
* 100
/ Core::Sandbox::Instance().devicePixelRatio();
cSetScreenScale(std::clamp(scale, 100, 300));
}); });
} }