Skip to content

Commit f9c3be5

Browse files
davtur19john-preston
authored andcommitted
Fixed window position restoring outside the work area on a screen with a different scale
1 parent a82a47f commit f9c3be5

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

‎Telegram/SourceFiles/window/main_window.cpp‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,14 +831,32 @@ void MainWindow::firstShow() {
831831
show();
832832
return;
833833
}
834-
const auto geometry = countInitialGeometry(initialPosition());
834+
const auto position = initialPosition();
835+
const auto geometry = countInitialGeometry(position);
835836
DEBUG_LOG(("Window Pos: Setting first %1, %2, %3, %4"
836837
).arg(geometry.x()
837838
).arg(geometry.y()
838839
).arg(geometry.width()
839840
).arg(geometry.height()));
840841
setGeometry(geometry);
841842
show();
843+
844+
InvokeQueued(this, [=] {
845+
const auto counted = countInitialGeometry(position);
846+
if (counted != geometry) {
847+
DEBUG_LOG(("Window Pos: Correcting first %1, %2, %3, %4 "
848+
"to %5, %6, %7, %8"
849+
).arg(geometry.x()
850+
).arg(geometry.y()
851+
).arg(geometry.width()
852+
).arg(geometry.height()
853+
).arg(counted.x()
854+
).arg(counted.y()
855+
).arg(counted.width()
856+
).arg(counted.height()));
857+
setGeometry(counted);
858+
}
859+
});
842860
}
843861

844862
void MainWindow::positionUpdated() {

0 commit comments

Comments
 (0)