diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index 415144e21..b0a71ee0e 100644 --- a/Build/Notepad3.ini +++ b/Build/Notepad3.ini @@ -38,8 +38,8 @@ SettingsVersion=5 ;ShellAppUserModelID=Rizonesoft.Notepad3 ;ShellUseSystemMRU=1 ;StickyWindowPosition=0 -;LaunchInstanceWndPosOffset=0 -;LaunchInstanceFullVisible=0 +;LaunchInstanceWndPosOffset=28 +;LaunchInstanceFullVisible=true ;UseOldStyleBraceMatching=0 ;WebTemplate1=https://google.com/search?q=%s ;WebTmpl1MenuName=Open Web Action 1 diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 1c15d3333..a6b6f6398 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -1220,9 +1220,8 @@ void LoadSettings() Settings2.IMEInteraction = ((codePage == 949 || codePage == 1361) ? SC_IME_INLINE : SC_IME_WINDOWED); } - Settings2.LaunchInstanceWndPosOffset = clampi(IniSectionGetInt(IniSecSettings2, L"LaunchInstanceWndPosOffset", 0), -10000, 10000); - - Settings2.LaunchInstanceFullVisible = IniSectionGetBool(IniSecSettings2, L"LaunchInstanceFullVisible", false); + Settings2.LaunchInstanceWndPosOffset = clampi(IniSectionGetInt(IniSecSettings2, L"LaunchInstanceWndPosOffset", 28), -10000, 10000); + Settings2.LaunchInstanceFullVisible = IniSectionGetBool(IniSecSettings2, L"LaunchInstanceFullVisible", true); Settings2.SciFontQuality = clampi(IniSectionGetInt(IniSecSettings2, L"SciFontQuality", SC_EFF_QUALITY_LCD_OPTIMIZED), SC_EFF_QUALITY_DEFAULT, SC_EFF_QUALITY_LCD_OPTIMIZED); diff --git a/src/Dialogs.c b/src/Dialogs.c index 439ededc6..7b7f6ca3c 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -4449,24 +4449,29 @@ WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo, SCRE WININFO winfo = INIT_WININFO; if (pWinInfo) { - RECT rc = { 0 }; - RectFromWinInfo(pWinInfo, &rc); - - winfo = *pWinInfo; - FitIntoMonitorGeometry(&rc, &winfo, mode, false); + winfo = *pWinInfo; + if (Settings2.LaunchInstanceFullVisible) { + RECT rc = { 0 }; + RectFromWinInfo(pWinInfo, &rc); + FitIntoMonitorGeometry(&rc, &winfo, mode, false); + } if (pWinInfo->max) { wndpl.flags &= WPF_RESTORETOMAXIMIZED; } wndpl.showCmd = SW_RESTORE; } else { - RECT rc = {0}; - if (hwnd) { - GetWindowRect(hwnd, &rc); - } else { - GetWindowRect(GetDesktopWindow(), &rc); - } - FitIntoMonitorGeometry(&rc, &winfo, mode, false); - + RECT rc = { 0 }; + if (hwnd) { + GetWindowRect(hwnd, &rc); + } + else { + GetWindowRect(GetDesktopWindow(), &rc); + } + if (Settings2.LaunchInstanceFullVisible) { + FitIntoMonitorGeometry(&rc, &winfo, mode, false); + } else { + WinInfoFromRect(&rc, &winfo); + } wndpl.showCmd = SW_SHOW; } RectFromWinInfo(&winfo, &(wndpl.rcNormalPosition)); diff --git a/src/Notepad3.c b/src/Notepad3.c index f51bbb02c..dd3e65014 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -11528,9 +11528,7 @@ bool LaunchNewInstance(HWND hwnd, LPCWSTR lpszParameter, LPCWSTR lpszFilePath) else { int const offset = Settings2.LaunchInstanceWndPosOffset; int const instCnt = CountRunningInstances(); - WININFO wi = g_IniWinInfo; - wi.x += (instCnt * offset); - wi.y += (instCnt * offset); + WININFO wi = GetMyWindowPlacement(hwnd, NULL, offset * instCnt); WCHAR wchPos[80] = { L'\0' }; StringCchPrintf(wchPos, COUNTOF(wchPos), L"-pos %i,%i,%i,%i,%i", wi.x, wi.y, wi.cx, wi.cy, (int)wi.max); diff --git a/src/TypeDefs.h b/src/TypeDefs.h index ad63038a8..4fcf0e30c 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -112,6 +112,16 @@ __forceinline void RectFromWinInfo(const WININFO* const pWinInfo, LPRECT pRect) { SetRect(pRect, pWinInfo->x, pWinInfo->y, pWinInfo->x + pWinInfo->cx, pWinInfo->y + pWinInfo->cy); } +__forceinline void WinInfoFromRect(LPCRECT pRect, WININFO* pWinInfo) +{ + pWinInfo->x = pRect->left; + pWinInfo->y = pRect->top; + pWinInfo->cx = pRect->right - pRect->left; + pWinInfo->cy = pRect->bottom - pRect->top; + pWinInfo->max = false; + pWinInfo->zoom = 100; + pWinInfo->dpi = USER_DEFAULT_SCREEN_DPI; +} extern WININFO g_IniWinInfo; extern WININFO g_DefWinInfo;