From 7e6439e4f8ac1965fc5436059908b9917c651e37 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 30 Jun 2021 01:25:43 +0400 Subject: [PATCH] Fix counting screen bottom point when restoring geometry --- Telegram/SourceFiles/window/main_window.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 62b2e58066..3eb66ef25c 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -532,28 +532,30 @@ void MainWindow::initSize() { if (position.w > w) position.w = w; if (position.h > h) position.h = h; const auto rightPoint = position.x + position.w; - if (rightPoint > w) { - const auto distance = rightPoint - w; + const auto screenRightPoint = x + w; + if (rightPoint > screenRightPoint) { + const auto distance = rightPoint - screenRightPoint; const auto newXPos = position.x - distance; if (newXPos >= x) { position.x = newXPos; } else { position.x = x; const auto newRightPoint = position.x + position.w; - const auto newDistance = newRightPoint - w; + const auto newDistance = newRightPoint - screenRightPoint; position.w -= newDistance; } } const auto bottomPoint = position.y + position.h; - if (bottomPoint > h) { - const auto distance = bottomPoint - h; + const auto screenBottomPoint = y + h; + if (bottomPoint > screenBottomPoint) { + const auto distance = bottomPoint - screenBottomPoint; const auto newYPos = position.y - distance; if (newYPos >= y) { position.y = newYPos; } else { position.y = y; const auto newBottomPoint = position.y + position.h; - const auto newDistance = newBottomPoint - h; + const auto newDistance = newBottomPoint - screenBottomPoint; position.h -= newDistance; } }