From 631db2019419cb6c6853fae87fd75869cc52de6e Mon Sep 17 00:00:00 2001 From: Eric Teutsch Date: Sun, 31 Mar 2024 14:11:47 -0400 Subject: [PATCH] If previous screen position is now out of bounds (due to unplugging of secondary monitor), then assume default screen position --- code/meos.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/code/meos.cpp b/code/meos.cpp index 63f5f2b..7c056d3 100644 --- a/code/meos.cpp +++ b/code/meos.cpp @@ -788,6 +788,17 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) int xs = gEvent->getPropertyInt("xsize", max(850, min(int(rc.right)-yp, (rc.right*9)/10))); int ys = gEvent->getPropertyInt("ysize", max(650, min(int(rc.bottom)-yp-40, (rc.bottom*8)/10))); + if ((xp + xs > rc.right) + || xp < rc.left + || yp + ys > rc.bottom + || yp < rc.top) + { + // out of bounds, just use default position and size + xp = 50; + yp = 20; + xs = max(850, min(int(rc.right) - yp, (rc.right * 9) / 10)); + ys = max(650, min(int(rc.bottom) - yp - 40, (rc.bottom * 8) / 10)); + } gEvent->setProperty("ypos", yp + 16); gEvent->setProperty("xpos", xp + 32); gEvent->saveProperties(settings); // For other instance starting while running