Skip to content

Commit

Permalink
+fix: show ColorDef Dlg always full visible
Browse files Browse the repository at this point in the history
  • Loading branch information
RaiKoHoff committed Oct 16, 2023
1 parent 789273b commit 5b72f48
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/Config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2264,8 +2264,8 @@ bool SaveWindowPositionSettings(bool bClearSettings)
return false;
}

// set current window position as ne initial window
WININFO const winInfo = GetMyWindowPlacement(Globals.hwndMain, NULL, 0);
// set current window position as new initial window
WININFO const winInfo = GetMyWindowPlacement(Globals.hwndMain, NULL, 0, false);

int const ResX = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int const ResY = GetSystemMetrics(SM_CYVIRTUALSCREEN);
Expand Down
10 changes: 6 additions & 4 deletions src/Dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4623,7 +4623,7 @@ void FitIntoMonitorGeometry(LPRECT pRect, WININFO *pWinInfo, SCREEN_MODE mode, b
//
// GetMyWindowPlacement()
//
WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO *hMonitorInfo, const int offset) {
WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO *hMonitorInfo, const int offset, const bool bFullVisible) {
RECT rc;
GetWindowRect(hwnd, &rc);

Expand Down Expand Up @@ -4662,7 +4662,7 @@ WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO *hMonitorInfo, const int off
wi.zoom = hwnd ? SciCall_GetZoom() : 100;
wi.dpi = Scintilla_GetWindowDPI(hwnd);

if (Settings2.LaunchInstanceFullVisible) {
if (bFullVisible) {
RECT rci;
RectFromWinInfo(&wi, &rci);
FitIntoMonitorGeometry(&rci, &wi, SCR_NORMAL, false);
Expand Down Expand Up @@ -4834,7 +4834,7 @@ void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, const HPATHL hFilePath, WI
StrgCat(hparam_str, Flags.bSingleFileInstance ? L" -ns" : L" -n");

WININFO const _wi = (Flags.bStickyWindowPosition ? g_IniWinInfo :
(wi ? *wi : GetMyWindowPlacement(hwnd, NULL, Settings2.LaunchInstanceWndPosOffset)));
(wi ? *wi : GetMyWindowPlacement(hwnd, NULL, Settings2.LaunchInstanceWndPosOffset, Settings2.LaunchInstanceFullVisible)));

StringCchPrintf(wch, COUNTOF(wch), L" -pos " WINDOWPOS_STRGFORMAT, _wi.x, _wi.y, _wi.cx, _wi.cy, _wi.dpi, (int)_wi.max);
StrgCat(hparam_str, wch);
Expand Down Expand Up @@ -6700,7 +6700,9 @@ INT_PTR CALLBACK ColorDialogHookProc(
const CHOOSECOLOR *const pChooseColor = ((CHOOSECOLOR *)lParam);
if (pChooseColor && pChooseColor->lCustData) {
POINT const pt = *(POINT*)pChooseColor->lCustData;
SetWindowPos(hdlg, NULL, pt.x, pt.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
SetWindowPos(hdlg, NULL, pt.x, pt.y, 0, 0, (SWP_NOZORDER | SWP_NOSIZE | SWP_HIDEWINDOW) & ~SWP_SHOWWINDOW);
WININFO wi = GetMyWindowPlacement(hdlg, NULL, 0, true);
SetWindowPos(hdlg, NULL, wi.x, wi.y, wi.cx, wi.cy, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW);
SetForegroundWindow(hdlg);
} else {
CenterDlgInParent(hdlg, NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/Dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void RelAdjustRectForDPI(LPRECT rc, const UINT oldDPI, const UINT new
void MapRectClientToWndCoords(HWND hwnd, LPRECT rc);
bool GetMonitorInfoFromRect(const LPRECT rc, MONITORINFO* hMonitorInfo);
void WinInfoToScreenCoord(WININFO* pWinInfo);
WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO* hMonitorInfo, const int offset);
WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO* hMonitorInfo, const int offset, const bool bFullVisible);
bool GetWindowRectEx(HWND hwnd, LPRECT pRect);
void FitIntoMonitorGeometry(LPRECT pRect, WININFO* pWinInfo, SCREEN_MODE mode, bool bTopLeft);
WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo, SCREEN_MODE mode, UINT nCmdShow);
Expand Down
19 changes: 10 additions & 9 deletions src/Notepad3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ WININFO GetWinInfoByFlag(HWND hwnd, const int flagsPos)

WININFO winfo = INIT_WININFO;
if (flagsPos < 0) {
winfo = GetMyWindowPlacement(hwnd, NULL, 0); // current window position
winfo = GetMyWindowPlacement(hwnd, NULL, 0, false); // current window position
} else if (flagsPos == 0) {
winfo = g_IniWinInfo; // initial window position
} else if (flagsPos == 1) {
Expand Down Expand Up @@ -3732,9 +3732,9 @@ LRESULT MsgDropFiles(HWND hwnd, WPARAM wParam, LPARAM lParam)
UINT const cnt = DragQueryFileW(hDrop, UINT_MAX, NULL, 0);

int const offset = Settings2.LaunchInstanceWndPosOffset;

bool const bFullVisible = Settings2.LaunchInstanceFullVisible;
for (UINT i = 0; i < cnt; ++i) {
WININFO wi = GetMyWindowPlacement(hwnd, NULL, (vkCtrlDown ? (offset * (i + 1)) : 0));
WININFO wi = GetMyWindowPlacement(hwnd, NULL, (vkCtrlDown ? (offset * (i + 1)) : 0), bFullVisible);
DragQueryFileW(hDrop, i, drop_buf, (UINT)Path_GetBufCount(hdrop_pth));
_OnDropOneFile(hwnd, hdrop_pth, (((0 == i) && !IsKeyDown(VK_CONTROL)) ? NULL : &wi));
}
Expand Down Expand Up @@ -7248,7 +7248,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)


case CMD_COPYWINPOS: {
WININFO wi = GetMyWindowPlacement(Globals.hwndMain, NULL, 0);
WININFO wi = GetMyWindowPlacement(Globals.hwndMain, NULL, 0, false);
WCHAR wchBuf[128] = { L'\0' };
StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"/pos " WINDOWPOS_STRGFORMAT, wi.x, wi.y, wi.cx, wi.cy, wi.dpi, (int)wi.max);
SetClipboardText(hwnd, wchBuf, StringCchLen(wchBuf, 0));
Expand All @@ -7261,7 +7261,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
break;

case CMD_FULLSCRWINPOS: {
WININFO wi = GetMyWindowPlacement(hwnd, NULL, 0);
WININFO wi = GetMyWindowPlacement(hwnd, NULL, 0, false);
SnapToWinInfoPos(hwnd, wi, SCR_FULL_SCREEN, SW_SHOWDEFAULT);
}
break;
Expand All @@ -7271,7 +7271,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
break;

case CMD_SAVEASDEFWINPOS: {
WININFO const wi = GetMyWindowPlacement(hwnd, NULL, 0);
WININFO const wi = GetMyWindowPlacement(hwnd, NULL, 0, false);
StringCchPrintf(Settings2.DefaultWindowPosition, COUNTOF(Settings2.DefaultWindowPosition),
WINDOWPOS_STRGFORMAT, wi.x, wi.y, wi.cx, wi.cy, wi.dpi, (int)wi.max);
if (Globals.bCanSaveIniFile) {
Expand Down Expand Up @@ -8311,7 +8311,7 @@ void HandleColorDefClicked(HWND hwnd, const DocPos position)
// custom hook
cc.Flags |= CC_ENABLEHOOK;
cc.lpfnHook = (LPCCHOOKPROC)ColorDialogHookProc;
WININFO const wi = GetMyWindowPlacement(Globals.hwndEdit, NULL, 0);
WININFO const wi = GetMyWindowPlacement(Globals.hwndEdit, NULL, 0, false);
int const offset = f2int(Style_GetCurrentLexerFontSize()) << 1;
POINT pt = { 0L, 0L };
pt.x = wi.x + SciCall_PointXFromPosition(SciCall_GetCurrentPos()) + offset;
Expand Down Expand Up @@ -11834,7 +11834,7 @@ bool DoElevatedRelaunch(EditFileIOStatus* pFioStatus, bool bAutoSaveOnRelaunch)
DocPos const iCurPos = SciCall_GetCurrentPos();
int const iCurLn = (int)SciCall_LineFromPosition(iCurPos) + 1;
int const iCurCol = (int)SciCall_GetColumn(iCurPos) + 1;
WININFO const wi = GetMyWindowPlacement(Globals.hwndMain, NULL, 0);
WININFO const wi = GetMyWindowPlacement(Globals.hwndMain, NULL, 0, false);

HSTRINGW hstr_args = StrgCreate(NULL);
StrgFormat(hstr_args, L"%s/pos " WINDOWPOS_STRGFORMAT L" /g %i,%i %s",
Expand Down Expand Up @@ -12345,8 +12345,9 @@ bool LaunchNewInstance(HWND hwnd, LPCWSTR lpszParameter, LPCWSTR lpszFilePath)
}
else {
int const offset = Settings2.LaunchInstanceWndPosOffset;
int const bFullVisible = Settings2.LaunchInstanceFullVisible;
int const instCnt = CountRunningInstances();
WININFO wi = GetMyWindowPlacement(hwnd, NULL, offset * instCnt);
WININFO wi = GetMyWindowPlacement(hwnd, NULL, offset * instCnt, bFullVisible);
WCHAR wchPos[80] = { L'\0' };
StringCchPrintf(wchPos, COUNTOF(wchPos), L"-pos " WINDOWPOS_STRGFORMAT, wi.x, wi.y, wi.cx, wi.cy, wi.dpi, (int)wi.max);

Expand Down

0 comments on commit 5b72f48

Please sign in to comment.