diff --git a/Versions/build.txt b/Versions/build.txt index 2bd017808..651dd1bb9 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -2631 +2632 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index fa5a1ad66..5a338a463 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 BETA diff --git a/src/Dialogs.c b/src/Dialogs.c index 10adba2b4..1fdcb9c6a 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -3240,14 +3240,14 @@ WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO* hMonitorInfo) //============================================================================= // -// FitIntoMonitorWorkArea() +// FitIntoMonitorGeometry() // -void FitIntoMonitorWorkArea(RECT* pRect, WININFO* pWinInfo, bool bFullWorkArea) +void FitIntoMonitorGeometry(RECT* pRect, WININFO* pWinInfo, SCREEN_MODE mode) { MONITORINFO mi; GetMonitorInfoFromRect(pRect, &mi); - if (bFullWorkArea) { + if (mode == SCR_FULL_WORKAREA) { SetRect(pRect, mi.rcWork.left, mi.rcWork.top, mi.rcWork.right, mi.rcWork.bottom); // monitor coord -> work area coord pWinInfo->x = mi.rcWork.left - (mi.rcWork.left - mi.rcMonitor.left); @@ -3255,6 +3255,14 @@ void FitIntoMonitorWorkArea(RECT* pRect, WININFO* pWinInfo, bool bFullWorkArea) pWinInfo->cx = (mi.rcWork.right - mi.rcWork.left); pWinInfo->cy = (mi.rcWork.bottom - mi.rcWork.top); } + else if (mode == SCR_FULL_SCREEN) { + SetRect(pRect, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom); + // monitor coord -> screen coord + pWinInfo->x = mi.rcMonitor.left - (mi.rcWork.left - mi.rcMonitor.left); + pWinInfo->y = mi.rcMonitor.top - (mi.rcWork.top - mi.rcMonitor.top); + pWinInfo->cx = (mi.rcMonitor.right - mi.rcMonitor.left); + pWinInfo->cy = (mi.rcMonitor.bottom - mi.rcMonitor.top); + } else { WININFO wi = *pWinInfo; WinInfoToScreen(&wi); @@ -3287,7 +3295,7 @@ void FitIntoMonitorWorkArea(RECT* pRect, WININFO* pWinInfo, bool bFullWorkArea) // WindowPlacementFromInfo() // // -WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo) +WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo, SCREEN_MODE mode) { WINDOWPLACEMENT wndpl; ZeroMemory(&wndpl, sizeof(WINDOWPLACEMENT)); @@ -3298,7 +3306,7 @@ WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo) if (pWinInfo) { RECT rc = RectFromWinInfo(pWinInfo); winfo = *pWinInfo; - FitIntoMonitorWorkArea(&rc, &winfo, false); + FitIntoMonitorGeometry(&rc, &winfo, SCR_NORMAL); if (pWinInfo->max) { wndpl.flags &= WPF_RESTORETOMAXIMIZED; } } else { @@ -3308,7 +3316,7 @@ WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo) else GetWindowRect(GetDesktopWindow(), &rc); - FitIntoMonitorWorkArea(&rc, &winfo, true); + FitIntoMonitorGeometry(&rc, &winfo, mode); // TODO: maximize ? } wndpl.rcNormalPosition = RectFromWinInfo(&winfo); diff --git a/src/Dialogs.h b/src/Dialogs.h index 1177981a2..46518a95c 100644 --- a/src/Dialogs.h +++ b/src/Dialogs.h @@ -41,8 +41,8 @@ bool WarnIndentationDlg(HWND hwnd, EditFileIOStatus* fioStatus); bool GetMonitorInfoFromRect(const RECT* rc, MONITORINFO* hMonitorInfo); void WinInfoToScreen(WININFO* pWinInfo); WININFO GetMyWindowPlacement(HWND hwnd,MONITORINFO * hMonitorInfo); -void FitIntoMonitorWorkArea(RECT* pRect, WININFO* pWinInfo, bool); -WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo); +void FitIntoMonitorGeometry(RECT* pRect, WININFO* pWinInfo, SCREEN_MODE mode); +WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo, SCREEN_MODE mode); void DialogNewWindow(HWND hwnd,bool,bool); void DialogFileBrowse(HWND hwnd); diff --git a/src/Notepad3.c b/src/Notepad3.c index db37a450d..023e3f920 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -148,6 +148,7 @@ static int s_cyReBarFrame; static int s_cxEditFrame; static int s_cyEditFrame; static bool s_bUndoRedoScroll = false; +static bool s_bPrevFullScreenFlag = false; // for tiny expression calculation static double s_dExpression = 0.0; @@ -1100,7 +1101,7 @@ void InitWindowPosition(WININFO* pWinInfo, const int flagsPos) RECT const rc = RectFromWinInfo(&winfo); GetMonitorInfoFromRect(&rc, &mi); WININFO wi = winfo; wi.cx = wi.cy = 16; // really small - FitIntoMonitorWorkArea(&(mi.rcWork), &wi, false); + FitIntoMonitorGeometry(&(mi.rcWork), &wi, SCR_NORMAL); winfo.x = wi.x; winfo.y = wi.y; } @@ -2427,6 +2428,10 @@ LRESULT MsgEndSession(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (!bShutdownOK) { + if (s_bPrevFullScreenFlag) { + SendWMCommand(hwnd, CMD_FULLSCRWINPOS); + } + // Terminate file watching InstallFileWatching(NULL); @@ -6052,18 +6057,18 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_INITIALWINPOS: - SnapToWinInfoPos(hwnd, &s_WinInfo, false); + SnapToWinInfoPos(hwnd, &s_WinInfo, SCR_NORMAL); break; case CMD_FULLSCRWINPOS: { WININFO const wi = GetMyWindowPlacement(Globals.hwndMain, NULL); - SnapToWinInfoPos(hwnd, &wi, true); + SnapToWinInfoPos(hwnd, &wi, SCR_FULL_SCREEN); } break; case CMD_DEFAULTWINPOS: - SnapToWinInfoPos(hwnd, &s_DefWinInfo, false); + SnapToWinInfoPos(hwnd, &s_DefWinInfo, SCR_NORMAL); break; case CMD_SAVEASDEFWINPOS: @@ -10360,21 +10365,26 @@ bool RelaunchElevated(LPWSTR lpNewCmdLnArgs) // SnapToWinInfoPos() // Aligns Notepad3 to the default window position on the current screen // -void SnapToWinInfoPos(HWND hwnd, const WININFO* pWinInfo, bool bFullWorkArea) +void SnapToWinInfoPos(HWND hwnd, const WININFO* pWinInfo, SCREEN_MODE mode) { static WINDOWPLACEMENT s_wndplPrev; - static bool s_bPrevFullWAFlag = false; - static bool s_bPrevShowToolbar = true; - static bool s_bPrevShowStatusbar = true; + static bool s_bPrevShowToolbar = false; + static bool s_bPrevShowStatusbar = false; WINDOWPLACEMENT wndpl; RECT rcCurrent; GetWindowRect(hwnd, &rcCurrent); - if (bFullWorkArea) { - if (s_bPrevFullWAFlag) { // snap to previous rect + if ((mode == SCR_FULL_WORKAREA) || (mode == SCR_FULL_SCREEN)) { + if (s_bPrevFullScreenFlag) { // snap to previous rect Settings.ShowToolbar = s_bPrevShowToolbar; Settings.ShowStatusbar = s_bPrevShowStatusbar; //SetMenu(Globals.hwndMain, Globals.hMainMenu); + if (Settings.AlwaysOnTop) { + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } + else { + SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } wndpl = s_wndplPrev; } else { @@ -10383,17 +10393,26 @@ void SnapToWinInfoPos(HWND hwnd, const WININFO* pWinInfo, bool bFullWorkArea) s_bPrevShowStatusbar = Settings.ShowStatusbar; Settings.ShowToolbar = Settings.ShowStatusbar = false; //SetMenu(Globals.hwndMain, NULL); - wndpl = WindowPlacementFromInfo(hwnd, NULL); + wndpl = WindowPlacementFromInfo(hwnd, NULL, mode); + if (mode == SCR_FULL_SCREEN) { + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } } - s_bPrevFullWAFlag = !s_bPrevFullWAFlag; + s_bPrevFullScreenFlag = !s_bPrevFullScreenFlag; } else { - wndpl = WindowPlacementFromInfo(hwnd, pWinInfo); - if (s_bPrevFullWAFlag) { + if (Settings.AlwaysOnTop) { + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } + else { + SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } + wndpl = WindowPlacementFromInfo(hwnd, pWinInfo, SCR_NORMAL); + if (s_bPrevFullScreenFlag) { Settings.ShowToolbar = s_bPrevShowToolbar; Settings.ShowStatusbar = s_bPrevShowStatusbar; } - s_bPrevFullWAFlag = false; + s_bPrevFullScreenFlag = false; } if (GetDoAnimateMinimize()) { diff --git a/src/Notepad3.h b/src/Notepad3.h index 8f56db1c2..9a2c0fb0a 100644 --- a/src/Notepad3.h +++ b/src/Notepad3.h @@ -125,7 +125,7 @@ bool ActivatePrevInst(); bool RelaunchMultiInst(); bool RelaunchElevated(LPWSTR lpNewCmdLnArgs); bool DoElevatedRelaunch(EditFileIOStatus* pFioStatus); -void SnapToWinInfoPos(HWND hwnd, const WININFO* pWinInfo, bool bFullWorkArea); +void SnapToWinInfoPos(HWND hwnd, const WININFO* pWinInfo, SCREEN_MODE mode); void ShowNotifyIcon(HWND hwnd, bool bAdd); void SetNotifyIconTitle(HWND hwnd); void InstallFileWatching(LPCWSTR lpszFile); diff --git a/src/TypeDefs.h b/src/TypeDefs.h index eaa3f51fb..5a5db56c5 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -86,6 +86,8 @@ typedef struct _wi #define INIT_WININFO { CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, false, 100 } +typedef enum { SCR_NORMAL = 0, SCR_FULL_WORKAREA = 1, SCR_FULL_SCREEN = 2 } SCREEN_MODE; + inline RECT RectFromWinInfo(const WININFO* const pWinInfo) { RECT rc; SetRect(&rc, pWinInfo->x, pWinInfo->y, pWinInfo->x + pWinInfo->cx, pWinInfo->y + pWinInfo->cy); return rc; } diff --git a/src/VersionEx.h b/src/VersionEx.h index 4a96f1c12..6271c41ab 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -7,8 +7,8 @@ #define SAPPNAME "Notepad3" #define VERSION_MAJOR 5 #define VERSION_MINOR 19 -#define VERSION_REV 912 -#define VERSION_BUILD 2631 +#define VERSION_REV 913 +#define VERSION_BUILD 2632 #define SCINTILLA_VER 420 #define ONIGURUMA_REGEX_VER 6.9.3 #define UCHARDET_VER 2018.09.27