https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d0d909245fdadcc93463d…
commit d0d909245fdadcc93463d501c5667bc21738c3b1
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sat Jan 19 23:56:33 2019 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sat Jan 19 23:56:33 2019 +0900
[WIN32SS][NTUSER] Refactor PR #1226 (#1266)
Refactoring of #1226. CORE-12845
---
win32ss/user/ntuser/defwnd.c | 83 ++++++++++++++++++++++----------------------
1 file changed, 41 insertions(+), 42 deletions(-)
diff --git a/win32ss/user/ntuser/defwnd.c b/win32ss/user/ntuser/defwnd.c
index d00d9aa853..67215d1f26 100644
--- a/win32ss/user/ntuser/defwnd.c
+++ b/win32ss/user/ntuser/defwnd.c
@@ -783,85 +783,84 @@ IntDefWindowProc(
}
if (IS_KEY_DOWN(gafAsyncKeyState, VK_LWIN) || IS_KEY_DOWN(gafAsyncKeyState,
VK_RWIN))
{
- PWND topWnd = UserGetWindowObject(UserGetForegroundWindow());
-
+ HWND hwndTop = UserGetForegroundWindow();
+ PWND topWnd = UserGetWindowObject(hwndTop);
if (topWnd)
{
if (wParam == VK_DOWN)
{
- co_IntSendMessage(UserHMGetHandle(topWnd), WM_SYSCOMMAND,
(topWnd->style & WS_MAXIMIZE) ? SC_RESTORE : SC_MINIMIZE, lParam);
- }
- else
- if (wParam == VK_UP)
+ if (topWnd->style & WS_MAXIMIZE)
+ co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_RESTORE, lParam);
+ else
+ co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_MINIMIZE, lParam);
+ }
+ else if (wParam == VK_UP)
{
- RECT currentRect = (topWnd->InternalPos.NormalRect.right ==
topWnd->InternalPos.NormalRect.left) ||
- (topWnd->InternalPos.NormalRect.top ==
topWnd->InternalPos.NormalRect.bottom)
- ? topWnd->rcWindow
- : topWnd->InternalPos.NormalRect;
- co_IntSendMessage(UserHMGetHandle(topWnd), WM_SYSCOMMAND, SC_MAXIMIZE,
0);
-
+ RECT currentRect;
+ if ((topWnd->InternalPos.NormalRect.right ==
topWnd->InternalPos.NormalRect.left) ||
+ (topWnd->InternalPos.NormalRect.top ==
topWnd->InternalPos.NormalRect.bottom))
+ {
+ currentRect = topWnd->rcWindow;
+ }
+ else
+ {
+ currentRect = topWnd->InternalPos.NormalRect;
+ }
+ co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
+
// save normal rect if maximazing snapped window
topWnd->InternalPos.NormalRect = currentRect;
}
- else
- if (wParam == VK_LEFT || wParam == VK_RIGHT)
+ else if (wParam == VK_LEFT || wParam == VK_RIGHT)
{
- RECT snapRect;
- RECT normalRect;
- RECT windowRect;
- BOOL snapped = FALSE;
+ RECT snapRect, normalRect, windowRect;
+ BOOL snapped;
normalRect = topWnd->InternalPos.NormalRect;
- snapped = (normalRect.left != 0
- && normalRect.right != 0
- && normalRect.top != 0
- && normalRect.bottom != 0);
+ snapped = (normalRect.left != 0 && normalRect.right != 0
&&
+ normalRect.top != 0 && normalRect.bottom != 0);
if (topWnd->style & WS_MAXIMIZE)
{
- co_IntSendMessage(UserHMGetHandle(topWnd), WM_SYSCOMMAND,
SC_RESTORE, lParam);
+ co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_RESTORE, lParam);
snapped = FALSE;
}
-
windowRect = topWnd->rcWindow;
UserSystemParametersInfo(SPI_GETWORKAREA, 0, &snapRect, 0);
if (wParam == VK_LEFT)
{
- snapRect.right = (snapRect.right - snapRect.left) / 2 +
snapRect.left;
+ snapRect.right = (snapRect.left + snapRect.right) / 2;
}
else // VK_RIGHT
{
- snapRect.left = (snapRect.right - snapRect.left) / 2 +
snapRect.left;
+ snapRect.left = (snapRect.left + snapRect.right) / 2;
}
if (snapped)
{
// if window was snapped but moved to other location - restore
normal size
- if (snapRect.left != windowRect.left ||
- snapRect.right != windowRect.right ||
- snapRect.top != windowRect.top ||
- snapRect.bottom != windowRect.bottom)
+ if (!IntEqualRect(&snapRect, &windowRect))
{
RECT empty = {0, 0, 0, 0};
co_WinPosSetWindowPos(topWnd,
- 0,
- normalRect.left,
- normalRect.top,
- normalRect.right - normalRect.left,
- normalRect.bottom - normalRect.top,
- 0);
+ 0,
+ normalRect.left,
+ normalRect.top,
+ normalRect.right - normalRect.left,
+ normalRect.bottom - normalRect.top,
+ 0);
topWnd->InternalPos.NormalRect = empty;
}
}
else
{
co_WinPosSetWindowPos(topWnd,
- 0,
- snapRect.left,
- snapRect.top,
- snapRect.right - snapRect.left,
- snapRect.bottom - snapRect.top,
- 0);
+ 0,
+ snapRect.left,
+ snapRect.top,
+ snapRect.right - snapRect.left,
+ snapRect.bottom - snapRect.top,
+ 0);
topWnd->InternalPos.NormalRect = windowRect;
}
}