From 82a45262bfe07a461a51d63eb4e3e7173a16ace8 Mon Sep 17 00:00:00 2001 From: Whindmar Saksit Date: Thu, 15 Aug 2024 12:33:17 +0200 Subject: [PATCH] [NTUSER] Correctly store original unsnap position (#7244) A small change before PR #5705 was merged caused a severe downgrade in the snap/unsnap handling. Win key handling should work correctly now. CORE-19165 CORE-19166 --- win32ss/user/ntuser/winpos.c | 6 +++--- win32ss/user/ntuser/winpos.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/win32ss/user/ntuser/winpos.c b/win32ss/user/ntuser/winpos.c index 9c55ef7c0d9..f69f39bd7ed 100644 --- a/win32ss/user/ntuser/winpos.c +++ b/win32ss/user/ntuser/winpos.c @@ -3937,7 +3937,7 @@ co_IntSnapWindow(PWND Wnd, UINT Edge) co_IntSendMessage(UserHMGetHandle(Wnd), WM_SYSCOMMAND, SC_MAXIMIZE, 0); return; } - else if (Edge) + else if (Edge != HTNOWHERE) { UserRefObjectCo(Wnd, &ref); hasRef = TRUE; @@ -3951,7 +3951,7 @@ co_IntSnapWindow(PWND Wnd, UINT Edge) IntSetSnapEdge(Wnd, HTNOWHERE); return; } - newPos = Wnd->InternalPos.NormalRect; + newPos = Wnd->InternalPos.NormalRect; /* Copy RECT now before it is lost */ IntSetSnapInfo(Wnd, HTNOWHERE, NULL); } else @@ -4000,7 +4000,7 @@ IntSetSnapInfo(PWND Wnd, UINT Edge, IN const RECT *Pos OPTIONAL) { RECT r; IntSetSnapEdge(Wnd, Edge); - if (Edge != HTNOWHERE) + if (Edge == HTNOWHERE) { RECTL_vSetEmptyRect(&r); Pos = (Wnd->style & WS_MINIMIZE) ? NULL : &r; diff --git a/win32ss/user/ntuser/winpos.h b/win32ss/user/ntuser/winpos.h index 17d1c49cf33..d57e985f272 100644 --- a/win32ss/user/ntuser/winpos.h +++ b/win32ss/user/ntuser/winpos.h @@ -81,7 +81,7 @@ VOID FASTCALL IntSetSnapInfo(PWND Wnd, UINT Edge, IN const RECT *Pos OPTIONAL); FORCEINLINE VOID co_IntUnsnapWindow(PWND Wnd) { - co_IntSnapWindow(Wnd, 0); + co_IntSnapWindow(Wnd, HTNOWHERE); } FORCEINLINE BOOLEAN