https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ea55101aadc66dbb2b0c1…
commit ea55101aadc66dbb2b0c1041b3248a05bcf79ac1
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Feb 1 18:13:32 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Feb 1 18:13:32 2023 +0900
[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
---
win32ss/user/ntuser/defwnd.c | 2 +-
win32ss/user/ntuser/nonclient.c | 2 +-
win32ss/user/ntuser/sysparams.c | 18 ++++++++++++++++--
win32ss/user/ntuser/window.h | 1 +
4 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/win32ss/user/ntuser/defwnd.c b/win32ss/user/ntuser/defwnd.c
index 0faadbce3f9..05a1db08877 100644
--- a/win32ss/user/ntuser/defwnd.c
+++ b/win32ss/user/ntuser/defwnd.c
@@ -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;
}
diff --git a/win32ss/user/ntuser/nonclient.c b/win32ss/user/ntuser/nonclient.c
index aad6fe72d77..ab7d00143b4 100644
--- a/win32ss/user/ntuser/nonclient.c
+++ b/win32ss/user/ntuser/nonclient.c
@@ -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;
}
diff --git a/win32ss/user/ntuser/sysparams.c b/win32ss/user/ntuser/sysparams.c
index 7b1f2bf895a..47349cedd37 100644
--- a/win32ss/user/ntuser/sysparams.c
+++ b/win32ss/user/ntuser/sysparams.c
@@ -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
diff --git a/win32ss/user/ntuser/window.h b/win32ss/user/ntuser/window.h
index 0a463b75c16..fa0387f30d3 100644
--- a/win32ss/user/ntuser/window.h
+++ b/win32ss/user/ntuser/window.h
@@ -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) || \