From 6de7cfefc082ef1bdc207fb79600e8fa3f72d43e Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Mon, 10 May 2021 16:01:45 -0700 Subject: [PATCH] Properly restore negative window positions It's okay to have the window off the top/left edge of the primary display, but CiderPress was rejecting the values and reverting to default placement. (for issue #41) --- app/Main.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Main.cpp b/app/Main.cpp index 9e7d2e5..b821208 100644 --- a/app/Main.cpp +++ b/app/Main.cpp @@ -1936,15 +1936,17 @@ void MainWindow::SaveWinPlacement() void MainWindow::RestoreWinPlacement() { - RECT normPos; - normPos.left = gMyApp.GetProfileInt(kMainWinSection, kMainWin_Left, -1); - normPos.top = gMyApp.GetProfileInt(kMainWinSection, kMainWin_Top, -1); - normPos.right = gMyApp.GetProfileInt(kMainWinSection, kMainWin_Right, -1); - normPos.bottom = gMyApp.GetProfileInt(kMainWinSection, kMainWin_Bottom, -1); - int cmd = gMyApp.GetProfileInt(kMainWinSection, kMainWin_Cmd, -1); + const int kNoVal = -32000; - if (normPos.left < 0 || normPos.top < 0 || normPos.right < 0 || - normPos.bottom < 0 || cmd < 0) { + RECT normPos; + normPos.left = gMyApp.GetProfileInt(kMainWinSection, kMainWin_Left, kNoVal); + normPos.top = gMyApp.GetProfileInt(kMainWinSection, kMainWin_Top, kNoVal); + normPos.right = gMyApp.GetProfileInt(kMainWinSection, kMainWin_Right, kNoVal); + normPos.bottom = gMyApp.GetProfileInt(kMainWinSection, kMainWin_Bottom, kNoVal); + int cmd = gMyApp.GetProfileInt(kMainWinSection, kMainWin_Cmd, kNoVal); + + if (normPos.left == kNoVal || normPos.top == kNoVal || + normPos.right == kNoVal || normPos.bottom == kNoVal || cmd == kNoVal) { LOGI("Previous window placement not found."); return; }