Browse Source

Bug 1852: Window position is not restored, if its left or top edge was aligned to monitor edge

https://winscp.net/tracker/1852

Source commit: 31695b04bf755c098f08019e9ec8b6cb49747832
Martin Prikryl 5 years ago
parent
commit
f1b0cd52a9
1 changed files with 5 additions and 4 deletions
  1. 5 4
      source/windows/Tools.cpp

+ 5 - 4
source/windows/Tools.cpp

@@ -241,11 +241,12 @@ void __fastcall RestoreForm(UnicodeString Data, TForm * Form, bool PositionOnly)
       TRect Bounds = OriginalBounds;
       LoadFormDimensions(LeftStr, TopStr, RightStr, BottomStr, PixelsPerInch, Monitor, Form, Bounds, DefaultPos);
 
+      int Padding = ScaleByPixelsPerInch(20, Monitor);
       if (DefaultPos ||
-          ((Bounds.Left < Monitor->Left) ||
-           (Bounds.Left > Monitor->Left + Monitor->WorkareaRect.Width() - 20) ||
-           (Bounds.Top < Monitor->Top) ||
-           (Bounds.Top > Monitor->Top + Monitor->WorkareaRect.Height() - 20)))
+          ((Bounds.Left < Monitor->Left - Padding) ||
+           (Bounds.Left > Monitor->Left + Monitor->WorkareaRect.Width() - Padding) ||
+           (Bounds.Top < Monitor->Top - Padding) ||
+           (Bounds.Top > Monitor->Top + Monitor->WorkareaRect.Height() - Padding)))
       {
         bool ExplicitPlacing = !Monitor->Primary;
         if (!ExplicitPlacing)