Skip to content

Commit

Permalink
Remove "Sticky Window Position" option, which is default and buggy si…
Browse files Browse the repository at this point in the history
…nce v4.2.25 (2011). fix issue #107.
  • Loading branch information
zufuliu committed Mar 8, 2019
1 parent 5dc8e57 commit f510eaf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 30 deletions.
Binary file modified doc/Notepad2.ini
Binary file not shown.
6 changes: 2 additions & 4 deletions metapath/src/metapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -2614,11 +2614,9 @@ void SaveWindowPosition(BOOL bSaveSettingsNow, WCHAR *pIniSectionBuf) {
WCHAR sectionName[96];
GetWindowPositionSectionName(sectionName);

// SaveSettingsNow(): query Window Dimensions
if (bSaveSettingsNow) {
// query window dimensions when window is not minimized
if (bSaveSettingsNow && !IsIconic(hwndMain)) {
WINDOWPLACEMENT wndpl;

// GetWindowPlacement
wndpl.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hwndMain, &wndpl);

Expand Down
31 changes: 8 additions & 23 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ typedef struct _wi {
} WININFO;

static WININFO wi;
static BOOL bStickyWinPos;
//BOOL bIsAppThemed;

static int cyReBar;
Expand Down Expand Up @@ -2384,7 +2383,6 @@ void MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) {

CheckCmd(hmenu, IDM_VIEW_REUSEWINDOW, bReuseWindow);
CheckCmd(hmenu, IDM_VIEW_SINGLEFILEINSTANCE, bSingleFileInstance);
CheckCmd(hmenu, IDM_VIEW_STICKYWINPOS, bStickyWinPos);
CheckCmd(hmenu, IDM_VIEW_ALWAYSONTOP, IsTopMost());
CheckCmd(hmenu, IDM_VIEW_MINTOTRAY, bMinimizeToTray);
CheckCmd(hmenu, IDM_VIEW_TRANSPARENT, bTransparentMode);
Expand Down Expand Up @@ -2443,7 +2441,6 @@ void MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) {
EnableCmd(hmenu, CMD_OPENINIFILE, i);

EnableCmd(hmenu, IDM_VIEW_REUSEWINDOW, i);
EnableCmd(hmenu, IDM_VIEW_STICKYWINPOS, i);
EnableCmd(hmenu, IDM_VIEW_SINGLEFILEINSTANCE, i);
EnableCmd(hmenu, IDM_VIEW_NOSAVERECENT, i);
EnableCmd(hmenu, IDM_VIEW_NOSAVEFINDREPL, i);
Expand Down Expand Up @@ -4028,15 +4025,6 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
SendWMSize(hwnd);
break;

case IDM_VIEW_STICKYWINPOS:
bStickyWinPos = !bStickyWinPos;
IniSetBool(INI_SECTION_NAME_FLAGS, L"StickyWindowPosition", bStickyWinPos);
if (bStickyWinPos) {
SaveWindowPosition(FALSE, NULL);
InfoBox(0, L"MsgStickyWinPos", IDS_STICKYWINPOS);
}
break;

case IDM_VIEW_CLEARWINPOS:
ClearWindowPositionHistory();
break;
Expand Down Expand Up @@ -5399,7 +5387,7 @@ void LoadSettings(void) {
IniSectionParse(pIniSection, pIniSectionBuf);

// ignore window position if /p was specified
if (!flagPosParam /*|| bStickyWinPos*/) {
if (!flagPosParam) {
wi.x = IniSectionGetInt(pIniSection, L"WindowPosX", CW_USEDEFAULT);
wi.y = IniSectionGetInt(pIniSection, L"WindowPosY", CW_USEDEFAULT);
wi.cx = IniSectionGetInt(pIniSection, L"WindowSizeX", CW_USEDEFAULT);
Expand Down Expand Up @@ -5614,8 +5602,8 @@ void SaveWindowPosition(BOOL bSaveSettingsNow, WCHAR *pIniSectionBuf) {
WCHAR sectionName[96];
GetWindowPositionSectionName(sectionName);

// SaveSettingsNow(): query Window Dimensions
if (bSaveSettingsNow || bStickyWinPos) {
// query window dimensions when window is not minimized
if (bSaveSettingsNow && !IsIconic(hwndMain)) {
WINDOWPLACEMENT wndpl;
wndpl.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hwndMain, &wndpl);
Expand All @@ -5627,13 +5615,11 @@ void SaveWindowPosition(BOOL bSaveSettingsNow, WCHAR *pIniSectionBuf) {
wi.max = (IsZoomed(hwndMain) || (wndpl.flags & WPF_RESTORETOMAXIMIZED));
}

if (bStickyWinPos) {
IniSectionSetInt(pIniSection, L"WindowPosX", wi.x);
IniSectionSetInt(pIniSection, L"WindowPosY", wi.y);
IniSectionSetInt(pIniSection, L"WindowSizeX", wi.cx);
IniSectionSetInt(pIniSection, L"WindowSizeY", wi.cy);
IniSectionSetBoolEx(pIniSection, L"WindowMaximized", wi.max, 0);
}
IniSectionSetInt(pIniSection, L"WindowPosX", wi.x);
IniSectionSetInt(pIniSection, L"WindowPosY", wi.y);
IniSectionSetInt(pIniSection, L"WindowSizeX", wi.cx);
IniSectionSetInt(pIniSection, L"WindowSizeY", wi.cy);
IniSectionSetBoolEx(pIniSection, L"WindowMaximized", wi.max, 0);

IniSectionSetIntEx(pIniSection, L"RunDlgSizeX", cxRunDlg, 0);
IniSectionSetIntEx(pIniSection, L"EncodingDlgSizeX", cxEncodingDlg, 0);
Expand Down Expand Up @@ -6348,7 +6334,6 @@ void LoadFlags(void) {

bSingleFileInstance = IniSectionGetBool(pIniSection, L"SingleFileInstance", 1);
bReuseWindow = IniSectionGetBool(pIniSection, L"ReuseWindow", 0);
bStickyWinPos = IniSectionGetBool(pIniSection, L"StickyWindowPosition", 0);

if (!flagReuseWindow && !flagNoReuseWindow) {
flagNoReuseWindow = !bReuseWindow;
Expand Down
2 changes: 0 additions & 2 deletions src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@ BEGIN
MENUITEM "Minimi&ze to Tray", IDM_VIEW_MINTOTRAY
MENUITEM SEPARATOR
MENUITEM "&Reuse Window", IDM_VIEW_REUSEWINDOW
MENUITEM "Sticky Window &Position", IDM_VIEW_STICKYWINPOS
MENUITEM "Clear Position &History", IDM_VIEW_CLEARWINPOS
END
POPUP "Window Title Displa&y"
Expand Down Expand Up @@ -1842,7 +1841,6 @@ BEGIN
IDS_READONLY_SAVE """%s"" is read only. Save to a different file?"
IDS_FILECHANGENOTIFY "The current file has been modified by an external program. Reload?"
IDS_FILECHANGENOTIFY2 "The current file has been deleted. Save now?"
IDS_STICKYWINPOS "Sticky Window Position is enabled. Any new Notepad2 windows will use the current window placement settings."
IDS_SAVEDSETTINGS "The current program settings have been saved."
IDS_CREATEINI_FAIL "Error creating configuration file."
IDS_WRITEINI_FAIL "Error writing settings to configuration file."
Expand Down
2 changes: 1 addition & 1 deletion src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@
#define IDM_VIEW_DEFAULT_TEXT_FONT 40421
#define IDM_VIEW_MARKOCCURRENCES_CASE 40422
#define IDM_VIEW_REUSEWINDOW 40423
#define IDM_VIEW_STICKYWINPOS 40424
// 40424
#define IDM_VIEW_ALWAYSONTOP 40425 // Alt+T
#define IDM_VIEW_MINTOTRAY 40426
#define IDM_VIEW_TRANSPARENT 40427 // Ctrl+0
Expand Down

0 comments on commit f510eaf

Please sign in to comment.