From 703ea9aacdc98b68e45d92f74ad3256e12ffe364 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 16 Sep 2021 13:16:13 +0300 Subject: [PATCH] Apply scale keeping window center in place. --- Telegram/SourceFiles/window/main_window.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 7c9cf878a2..66f5e31300 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -445,10 +445,15 @@ Core::WindowPosition MainWindow::positionFromSettings() const { return position; } const auto scaleFactor = cScale() / float64(position.scale); - position.x *= scaleFactor; - position.y *= scaleFactor; - position.w *= scaleFactor; - position.h *= scaleFactor; + if (scaleFactor != 1.) { + // Change scale while keeping the position center in place. + position.x += position.w / 2; + position.y += position.h / 2; + position.w *= scaleFactor; + position.h *= scaleFactor; + position.x -= position.w / 2; + position.y -= position.h / 2; + } return position; }