From 01120529aca16bd88d6bf142ba3cffce4959f034 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Fri, 19 Oct 2018 14:05:32 +0200 Subject: [PATCH] + fix: window restoration in case of aero snap position --- src/Dialogs.c | 16 ++++++++++++++++ src/Notepad3.c | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Dialogs.c b/src/Dialogs.c index f5a099cf2..3ee32ece5 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -2599,6 +2599,21 @@ WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO* hMonitorInfo) wndpl.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(hwnd, &wndpl); + // corrections in case of aero snapped position + if (SW_NORMAL == wndpl.showCmd) { + RECT rc; + GetWindowRect(hwnd, &rc); + MONITORINFO mi; + GetMonitorInfoFromRect(&rc, &mi); + LONG const width = rc.right - rc.left; + LONG const height = rc.bottom - rc.top; + rc.left -= (mi.rcWork.left - mi.rcMonitor.left); + rc.right = rc.left + width; + rc.top -= (mi.rcWork.top - mi.rcMonitor.top); + rc.bottom = rc.top + height; + wndpl.rcNormalPosition = rc; + } + WININFO wi; wi.x = wndpl.rcNormalPosition.left; wi.y = wndpl.rcNormalPosition.top; @@ -2607,6 +2622,7 @@ WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO* hMonitorInfo) wi.max = IsZoomed(hwnd) || (wndpl.flags & WPF_RESTORETOMAXIMIZED); wi.zoom = SciCall_GetZoom(); + // set monitor info too GetMonitorInfoFromRect(&(wndpl.rcNormalPosition), hMonitorInfo); return wi; diff --git a/src/Notepad3.c b/src/Notepad3.c index 6d08d9c2b..ae34ce51c 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -871,7 +871,7 @@ void EndWaitCursor() // _InitWindowPosition() // // -static WININFO _InitDefaultWndPos(const int flagsPos) +static WININFO _InitDefaultWndPos(const int flagsPos) { RECT rc; GetWindowRect(GetDesktopWindow(), &rc);