[NTUSER] Allow Window Snap to be disabled (#5014)

- Add IntIsWindowSnapEnabled helper function that reads registry value WindowArrangementActive.
- Check the registry and store the value to newly-added g_bWindowSnapEnabled global variable on startup.
- Check the global variable before Window Snap.

Win+Left, Win+Right, Win+Up, and Win+Down can be disabled by registry value WindowArrangementActive.
Snapping mouse can be also disabled. CORE-16379
This commit is contained in:
Katayama Hirofumi MZ 2023-02-01 18:13:32 +09:00 committed by GitHub
parent 0dde428d00
commit ea55101aad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 4 deletions

View file

@ -813,7 +813,7 @@ IntDefWindowProc(
if (topWnd && !IsTaskBar) /* Second test is so we are not touching the Taskbar */
{
if ((topWnd->style & WS_THICKFRAME) == 0)
if ((topWnd->style & WS_THICKFRAME) == 0 || !g_bWindowSnapEnabled)
{
return 0;
}

View file

@ -418,7 +418,7 @@ DefWndDoSizeMove(PWND pwnd, WORD wParam)
UserSystemParametersInfo(SPI_GETWORKAREA, 0, &snapRect, 0);
/* if this is the taskbar, then we want to just exit */
if (IsTaskBar)
if (IsTaskBar || !g_bWindowSnapEnabled)
{
break;
}

View file

@ -17,6 +17,7 @@ DBG_DEFAULT_CHANNEL(UserSysparams);
SPIVALUES gspv;
BOOL gbSpiInitialized = FALSE;
BOOL g_PaintDesktopVersion = FALSE;
BOOL g_bWindowSnapEnabled = TRUE;
// HACK! We initialize SPI before we have a proper surface to get this from.
#define dpi 96
@ -100,8 +101,6 @@ static const WCHAR* KEY_KDBPREF = L"Control Panel\\Accessibility\\Keyboard Prefe
static const WCHAR* KEY_SCRREAD = L"Control Panel\\Accessibility\\Blind Access";
static const WCHAR* VAL_ON = L"On";
/** Loading the settings ******************************************************/
static
@ -215,6 +214,19 @@ SpiFixupValues(VOID)
}
/* Is Window Snap enabled? */
static BOOL IntIsWindowSnapEnabled(VOID)
{
WCHAR szValue[2];
if (RegReadUserSetting(L"Control Panel\\Desktop", L"WindowArrangementActive",
REG_SZ, szValue, sizeof(szValue)))
{
szValue[RTL_NUMBER_OF(szValue) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
return (_wtoi(szValue) != 0);
}
return TRUE;
}
static
VOID
SpiUpdatePerUserSystemParameters(VOID)
@ -344,6 +356,8 @@ SpiUpdatePerUserSystemParameters(VOID)
if (SPITESTPREF(UPM_LISTBOXSMOOTHSCROLLING)) gpsi->PUSIFlags |= PUSIF_LISTBOXSMOOTHSCROLLING;
}
gdwLanguageToggleKey = UserGetLanguageToggle();
g_bWindowSnapEnabled = IntIsWindowSnapEnabled();
}
BOOL

View file

@ -4,6 +4,7 @@ extern ATOM AtomMessage;
extern ATOM AtomWndObj; /* WNDOBJ list */
extern ATOM AtomLayer;
extern ATOM AtomFlashWndState;
extern BOOL g_bWindowSnapEnabled;
#define HAS_DLGFRAME(Style, ExStyle) \
(((ExStyle) & WS_EX_DLGMODALFRAME) || \