Fix counting screen bottom point when restoring geometry

This commit is contained in:
Ilya Fedin 2021-06-30 01:25:43 +04:00 committed by John Preston
parent f07ee7f590
commit 7e6439e4f8

View File

@ -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;
}
}