diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 62b2e5806..3eb66ef25 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; } }