Henri Verbeet : wordpad: Fall back to the default position if the saved position is off-screen.

Alexandre Julliard julliard at winehq.org
Tue Jan 2 15:01:28 CST 2018


Module: wine
Branch: stable
Commit: 49d0150154218f875283aa963aaae512fb933946
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=49d0150154218f875283aa963aaae512fb933946

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Mar 21 22:59:13 2017 +0100

wordpad: Fall back to the default position if the saved position is off-screen.

This condition is particularly easy to trigger when switching from a
multi-head setup to a virtual desktop. Inspired by some fairly similar
code in notepad.

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit ff0a34e9c95b6c7fee8453ee30d36bda21c01713)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 programs/wordpad/wordpad.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c
index 89bcac1..f787191 100644
--- a/programs/wordpad/wordpad.c
+++ b/programs/wordpad/wordpad.c
@@ -2731,6 +2731,9 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar
     HWND hRulerWnd;
     POINTL EditPoint;
     DWORD bMaximized;
+    MONITORINFO info;
+    HMONITOR monitor;
+    int x, y;
     static const WCHAR wszAccelTable[] = {'M','A','I','N','A','C','C','E','L',
                                           'T','A','B','L','E','\0'};
 
@@ -2767,8 +2770,18 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar
     RegisterClassExW(&wc);
 
     registry_read_winrect(&rc);
+    monitor = MonitorFromRect(&rc, MONITOR_DEFAULTTOPRIMARY);
+    info.cbSize = sizeof(info);
+    GetMonitorInfoW(monitor, &info);
+
+    x = rc.left;
+    y = rc.top;
+    IntersectRect(&info.rcWork, &info.rcWork, &rc);
+    if (IsRectEmpty(&info.rcWork))
+        x = y = CW_USEDEFAULT;
+
     hMainWnd = CreateWindowExW(0, wszMainWndClass, wszAppTitle, WS_CLIPCHILDREN|WS_OVERLAPPEDWINDOW,
-      rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, NULL, NULL, hInstance, NULL);
+            x, y, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL);
     registry_read_maximized(&bMaximized);
     if ((nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOWDEFAULT)
 	     && bMaximized)




More information about the wine-cvs mailing list