diff --git a/reactos/dll/win32/user32/windows/input.c b/reactos/dll/win32/user32/windows/input.c index 08e457bf5a1..63f266eb492 100644 --- a/reactos/dll/win32/user32/windows/input.c +++ b/reactos/dll/win32/user32/windows/input.c @@ -48,9 +48,8 @@ DragDetect( HWND hWnd, POINT pt) { -#if 0 return NtUserDragDetect(hWnd, pt); -#else +#if 0 MSG msg; RECT rect; POINT tmp; diff --git a/reactos/subsystems/win32/win32k/include/winpos.h b/reactos/subsystems/win32/win32k/include/winpos.h index b21b9107616..7f1c52a4124 100644 --- a/reactos/subsystems/win32/win32k/include/winpos.h +++ b/reactos/subsystems/win32/win32k/include/winpos.h @@ -9,6 +9,9 @@ NtGdiPtInRegion((WndObject)->hrgnClip, (INT)((x) - (WndObject)->rcWindow.left), \ (INT)((y) - (WndObject)->rcWindow.top)))) +#define IntPtInRect(lprc,pt) \ + ((pt.x >= (lprc)->left) && (pt.x < (lprc)->right) && (pt.y >= (lprc)->top) && (pt.y < (lprc)->bottom)) + UINT FASTCALL co_WinPosArrangeIconicWindows(PWND parent); BOOL FASTCALL diff --git a/reactos/subsystems/win32/win32k/ntuser/focus.c b/reactos/subsystems/win32/win32k/ntuser/focus.c index 39e11965462..9989e880956 100644 --- a/reactos/subsystems/win32/win32k/ntuser/focus.c +++ b/reactos/subsystems/win32/win32k/ntuser/focus.c @@ -534,29 +534,23 @@ CLEANUP: END_CLEANUP; } -/* - * @implemented - */ -HWND APIENTRY -NtUserSetCapture(HWND hWnd) + +HWND FASTCALL +co_UserSetCapture(HWND hWnd) { PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; PWND Window, pWnd; HWND hWndPrev; - DECLARE_RETURN(HWND); - - DPRINT("Enter NtUserSetCapture(%x)\n", hWnd); - UserEnterExclusive(); pti = PsGetCurrentThreadWin32Thread(); ThreadQueue = pti->MessageQueue; - if((Window = UserGetWindowObject(hWnd))) + if ((Window = UserGetWindowObject(hWnd))) { - if(Window->head.pti->MessageQueue != ThreadQueue) + if (Window->head.pti->MessageQueue != ThreadQueue) { - RETURN(NULL); + return NULL; } } @@ -582,7 +576,21 @@ NtUserSetCapture(HWND hWnd) co_IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd); ThreadQueue->CaptureWindow = hWnd; - RETURN( hWndPrev); + return hWndPrev; +} + +/* + * @implemented + */ +HWND APIENTRY +NtUserSetCapture(HWND hWnd) +{ + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserSetCapture(%x)\n", hWnd); + UserEnterExclusive(); + + RETURN( co_UserSetCapture(hWnd)); CLEANUP: DPRINT("Leave NtUserSetCapture, ret=%i\n",_ret_); diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 1a1ae9d6c71..9d5b72bb105 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -16,6 +16,7 @@ #include BOOLEAN NTAPI PsGetProcessExitProcessCalled(PEPROCESS Process); +HWND FASTCALL co_UserSetCapture(HWND hWnd); #define PM_BADMSGFLAGS ~((QS_RAWINPUT << 16)|PM_QS_SENDMESSAGE|PM_QS_PAINT|PM_QS_POSTMESSAGE|PM_QS_INPUT|PM_NOYIELD|PM_REMOVE) @@ -1698,6 +1699,76 @@ IntUninitMessagePumpHook() /** Functions ******************************************************************/ +BOOL +APIENTRY +NtUserDragDetect( + HWND hWnd, + POINT pt) // Just like the User call. +{ + MSG msg; + RECT rect; + WORD wDragWidth, wDragHeight; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserDragDetect(%x)\n", hWnd); + UserEnterExclusive(); + + wDragWidth = UserGetSystemMetrics(SM_CXDRAG); + wDragHeight= UserGetSystemMetrics(SM_CYDRAG); + + rect.left = pt.x - wDragWidth; + rect.right = pt.x + wDragWidth; + + rect.top = pt.y - wDragHeight; + rect.bottom = pt.y + wDragHeight; + + co_UserSetCapture(hWnd); + + for (;;) + { + while (co_IntGetPeekMessage( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE, FALSE ) || + co_IntGetPeekMessage( &msg, 0, WM_QUEUESYNC, WM_QUEUESYNC, PM_REMOVE, FALSE ) || + co_IntGetPeekMessage( &msg, 0, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE, FALSE ) ) + { + if ( msg.message == WM_LBUTTONUP ) + { + co_UserSetCapture(NULL); + RETURN( FALSE); + } + if ( msg.message == WM_MOUSEMOVE ) + { + POINT tmp; + tmp.x = (short)LOWORD(msg.lParam); + tmp.y = (short)HIWORD(msg.lParam); + if( !IntPtInRect( &rect, tmp ) ) + { + co_UserSetCapture(NULL); + RETURN( TRUE); + } + } + if ( msg.message == WM_KEYDOWN ) + { + if ( msg.wParam == VK_ESCAPE ) + { + co_UserSetCapture(NULL); + RETURN( TRUE); + } + } + if ( msg.message == WM_QUEUESYNC ) + { + co_HOOK_CallHooks( WH_CBT, HCBT_QS, 0, 0 ); + } + } + co_IntWaitMessage(NULL, 0, 0); + } + RETURN( FALSE); + +CLEANUP: + DPRINT("Leave NtUserDragDetect, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + BOOL APIENTRY NtUserPostMessage(HWND hWnd, UINT Msg, diff --git a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c index 821d4d6ddf4..7d405821102 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c @@ -1338,16 +1338,6 @@ NtUserResolveDesktopForWOW(DWORD Unknown0) return 0; } -BOOL -APIENTRY -NtUserDragDetect( - HWND hWnd, - POINT pt) // Just like the User call. -{ - UNIMPLEMENTED - return 0; -} - /* * @unimplemented */