mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
+ chg/add: configurable position offset on launching new instance
+ fix: Sticky Window Flag on launching new instance
This commit is contained in:
parent
27468544c6
commit
31d8914521
@ -37,6 +37,8 @@ SettingsVersion=4
|
||||
;ShellAppUserModelID=Rizonesoft.Notepad3
|
||||
;ShellUseSystemMRU=1
|
||||
;StickyWindowPosition=0
|
||||
;LaunchInstanceWndPosOffset=0
|
||||
;LaunchInstanceFullVisible=0
|
||||
;UseOldStyleBraceMatching=0
|
||||
;WebTemplate1=https://google.com/search?q=%s
|
||||
;WebTmpl1MenuName=Open Web Action 1
|
||||
|
||||
@ -47,10 +47,6 @@ extern "C" {
|
||||
|
||||
#include "DarkMode/DarkMode.h"
|
||||
|
||||
|
||||
extern "C" WININFO g_IniWinInfo;
|
||||
extern "C" WININFO g_DefWinInfo;
|
||||
|
||||
extern "C" const WCHAR* const TBBUTTON_DEFAULT_IDS_V1;
|
||||
extern "C" const WCHAR* const TBBUTTON_DEFAULT_IDS_V2;
|
||||
|
||||
@ -1130,8 +1126,7 @@ void LoadSettings()
|
||||
Defaults2.UndoTransactionTimeout),
|
||||
0UL, 86400000UL);
|
||||
|
||||
// deprecated
|
||||
|
||||
// Settings2 SciDirectWriteTech deprecated
|
||||
Defaults.RenderingTechnology = IniSectionGetInt(IniSecSettings2, L"SciDirectWriteTech", -111);
|
||||
if (Defaults.RenderingTechnology != -111) {
|
||||
if (Settings.SaveSettings) {
|
||||
@ -1144,7 +1139,7 @@ void LoadSettings()
|
||||
Defaults.RenderingTechnology = SC_TECHNOLOGY_DIRECTWRITE; // new default DirectWrite (D2D)
|
||||
}
|
||||
|
||||
// Settings2 deprecated
|
||||
// Settings2 EnableBidirectionalSupport deprecated
|
||||
Defaults.Bidirectional = IniSectionGetInt(IniSecSettings2, L"EnableBidirectionalSupport", -111);
|
||||
if ((Defaults.Bidirectional != -111) && Settings.SaveSettings) {
|
||||
// cleanup
|
||||
@ -1162,6 +1157,12 @@ void LoadSettings()
|
||||
Settings2.IMEInteraction = ((codePage == 949 || codePage == 1361) ? SC_IME_INLINE : SC_IME_WINDOWED);
|
||||
}
|
||||
|
||||
Defaults2.LaunchInstanceWndPosOffset = 0;
|
||||
Settings2.LaunchInstanceWndPosOffset = clampi(IniSectionGetInt(IniSecSettings2, L"LaunchInstanceWndPosOffset", Defaults2.LaunchInstanceWndPosOffset), -10000, 10000);
|
||||
|
||||
Defaults2.LaunchInstanceFullVisible = false;
|
||||
Settings2.LaunchInstanceFullVisible = IniSectionGetBool(IniSecSettings2, L"LaunchInstanceFullVisible", Defaults2.LaunchInstanceFullVisible);
|
||||
|
||||
Defaults2.SciFontQuality = SC_EFF_QUALITY_LCD_OPTIMIZED;
|
||||
Settings2.SciFontQuality = clampi(IniSectionGetInt(IniSecSettings2, L"SciFontQuality", Defaults2.SciFontQuality), SC_EFF_QUALITY_DEFAULT, SC_EFF_QUALITY_LCD_OPTIMIZED);
|
||||
|
||||
|
||||
108
src/Dialogs.c
108
src/Dialogs.c
@ -4362,59 +4362,6 @@ bool GetWindowRectEx(HWND hwnd, LPRECT pRect) {
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// GetMyWindowPlacement()
|
||||
//
|
||||
WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO* hMonitorInfo, const int offset)
|
||||
{
|
||||
RECT rc;
|
||||
GetWindowRect(hwnd, &rc);
|
||||
|
||||
MONITORINFO mi = { sizeof(MONITORINFO) };
|
||||
GetMonitorInfoFromRect(&rc, &mi);
|
||||
|
||||
// set monitor info
|
||||
if (hMonitorInfo) {
|
||||
if (hMonitorInfo->cbSize == mi.cbSize) {
|
||||
*hMonitorInfo = mi;
|
||||
} else {
|
||||
GetMonitorInfoFromRect(&rc, hMonitorInfo);
|
||||
}
|
||||
}
|
||||
|
||||
WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
|
||||
GetWindowPlacement(hwnd, &wndpl);
|
||||
|
||||
// corrections in case of aero snapped position
|
||||
if (SW_SHOWNORMAL == wndpl.showCmd) {
|
||||
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 = { 0 };
|
||||
wi.x = wndpl.rcNormalPosition.left + offset;
|
||||
wi.y = wndpl.rcNormalPosition.top + offset;
|
||||
wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
|
||||
wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
|
||||
wi.max = IsZoomed(hwnd) || (wndpl.flags & WPF_RESTORETOMAXIMIZED);
|
||||
wi.zoom = SciCall_GetZoom();
|
||||
|
||||
// check if window fits monitor
|
||||
if ((wi.x + wi.cx) > mi.rcWork.right || (wi.y + wi.cy) > mi.rcWork.bottom) {
|
||||
wi.x = mi.rcMonitor.left;
|
||||
wi.y = mi.rcMonitor.top;
|
||||
}
|
||||
|
||||
return wi;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// FitIntoMonitorGeometry()
|
||||
@ -4472,6 +4419,57 @@ void FitIntoMonitorGeometry(LPRECT pRect, WININFO *pWinInfo, SCREEN_MODE mode) {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// GetMyWindowPlacement()
|
||||
//
|
||||
WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO *hMonitorInfo, const int offset) {
|
||||
RECT rc;
|
||||
GetWindowRect(hwnd, &rc);
|
||||
|
||||
MONITORINFO mi = { sizeof(MONITORINFO) };
|
||||
GetMonitorInfoFromRect(&rc, &mi);
|
||||
|
||||
// set monitor info
|
||||
if (hMonitorInfo) {
|
||||
if (hMonitorInfo->cbSize == mi.cbSize) {
|
||||
*hMonitorInfo = mi;
|
||||
} else {
|
||||
GetMonitorInfoFromRect(&rc, hMonitorInfo);
|
||||
}
|
||||
}
|
||||
|
||||
WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
|
||||
GetWindowPlacement(hwnd, &wndpl);
|
||||
|
||||
// corrections in case of aero snapped position
|
||||
if (SW_SHOWNORMAL == wndpl.showCmd) {
|
||||
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 = { 0 };
|
||||
wi.x = wndpl.rcNormalPosition.left + offset;
|
||||
wi.y = wndpl.rcNormalPosition.top + offset;
|
||||
wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left;
|
||||
wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top;
|
||||
wi.max = IsZoomed(hwnd) || (wndpl.flags & WPF_RESTORETOMAXIMIZED);
|
||||
wi.zoom = SciCall_GetZoom();
|
||||
|
||||
if (Settings2.LaunchInstanceFullVisible) {
|
||||
RECT rcWi;
|
||||
RectFromWinInfo(&wi, &rcWi);
|
||||
FitIntoMonitorGeometry(&rcWi, &wi, SCR_NORMAL);
|
||||
}
|
||||
return wi;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// WindowPlacementFromInfo()
|
||||
@ -4542,7 +4540,9 @@ void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, LPCWSTR lpcwFilePath, WINI
|
||||
}
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), Flags.bSingleFileInstance ? L" -ns" : L" -n");
|
||||
|
||||
WININFO const _wi = wi ? *wi : GetMyWindowPlacement(hwnd, NULL, 0);
|
||||
WININFO const _wi = (Flags.bStickyWindowPosition ? g_IniWinInfo :
|
||||
(wi ? *wi : GetMyWindowPlacement(hwnd, NULL, Settings2.LaunchInstanceWndPosOffset)));
|
||||
|
||||
StringCchPrintf(tch, COUNTOF(tch), L" -pos %i,%i,%i,%i,%i", _wi.x, _wi.y, _wi.cx, _wi.cy, _wi.max);
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), tch);
|
||||
|
||||
|
||||
@ -3019,25 +3019,17 @@ LRESULT MsgDropFiles(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
HDROP const hDrop = (HDROP)wParam;
|
||||
bool const vkCtrlDown = IsKeyDown(VK_CONTROL);
|
||||
|
||||
WCHAR szDropFilePath[MAX_PATH + 40];
|
||||
UINT const cnt = DragQueryFile(hDrop, UINT_MAX, NULL, 0);
|
||||
|
||||
int const offset = 20;
|
||||
MONITORINFO mi = { sizeof(MONITORINFO) };
|
||||
WININFO wi = GetMyWindowPlacement(hwnd, &mi, (IsKeyDown(VK_CONTROL) ? offset : 0));
|
||||
int const offset = Settings2.LaunchInstanceWndPosOffset;
|
||||
|
||||
for (UINT i = 0; i < cnt; ++i) {
|
||||
WININFO wi = GetMyWindowPlacement(hwnd, NULL, (vkCtrlDown ? (offset * (i + 1)) : 0));
|
||||
DragQueryFile(hDrop, i, szDropFilePath, COUNTOF(szDropFilePath));
|
||||
_OnDropOneFile(hwnd, szDropFilePath, (((0 == i) && !IsKeyDown(VK_CONTROL)) ? NULL : &wi));
|
||||
// offset next window position
|
||||
wi.x += offset;
|
||||
wi.y += offset;
|
||||
// check if window fits monitor
|
||||
if ((wi.x + wi.cx) > mi.rcWork.right || (wi.y + wi.cy) > mi.rcWork.bottom) {
|
||||
wi.x = mi.rcMonitor.left;
|
||||
wi.y = mi.rcMonitor.top;
|
||||
}
|
||||
}
|
||||
|
||||
DragFinish(hDrop);
|
||||
@ -7710,9 +7702,9 @@ static LRESULT _MsgNotifyFromEdit(HWND hwnd, const SCNotification* const scn)
|
||||
|
||||
|
||||
case SCN_URIDROPPED: {
|
||||
WCHAR szBuf[MAX_PATH + 40] = { L'\0' };
|
||||
if (MultiByteToWideChar(CP_UTF8, 0, scn->text, -1, szBuf, (int)COUNTOF(szBuf)) > 0) {
|
||||
return _OnDropOneFile(hwnd, szBuf, false);
|
||||
WCHAR szFilePath[MAX_PATH + 40] = { L'\0' };
|
||||
if (MultiByteToWideChar(CP_UTF8, 0, scn->text, -1, szFilePath, (int)COUNTOF(szFilePath)) > 0) {
|
||||
return _OnDropOneFile(hwnd, szFilePath, NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -93,6 +93,9 @@ inline void RectFromWinInfo(const WININFO* const pWinInfo, LPRECT pRect)
|
||||
SetRect(pRect, pWinInfo->x, pWinInfo->y, pWinInfo->x + pWinInfo->cx, pWinInfo->y + pWinInfo->cy);
|
||||
}
|
||||
|
||||
extern WININFO g_IniWinInfo;
|
||||
extern WININFO g_DefWinInfo;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
typedef int COLORALPHAREF;
|
||||
@ -595,7 +598,8 @@ typedef struct _settings2_t
|
||||
DWORD UndoTransactionTimeout;
|
||||
int IMEInteraction;
|
||||
int SciFontQuality;
|
||||
|
||||
int LaunchInstanceWndPosOffset;
|
||||
bool LaunchInstanceFullVisible;
|
||||
int UpdateDelayMarkAllOccurrences;
|
||||
bool DenyVirtualSpaceAccess;
|
||||
bool UseOldStyleBraceMatching;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user