Author: jimtabor Date: Sat Mar 12 01:29:08 2011 New Revision: 51021
URL: http://svn.reactos.org/svn/reactos?rev=51021&view=rev Log: [Win32k] - Move the drag detection routine to kernel space, this will decrease the number of kernel calls that is noticeable with slower systems running an emulator.
Modified: trunk/reactos/dll/win32/user32/windows/input.c trunk/reactos/subsystems/win32/win32k/include/winpos.h trunk/reactos/subsystems/win32/win32k/ntuser/focus.c trunk/reactos/subsystems/win32/win32k/ntuser/message.c trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c
Modified: trunk/reactos/dll/win32/user32/windows/input.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/in... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/input.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/input.c [iso-8859-1] Sat Mar 12 01:29:08 2011 @@ -48,9 +48,8 @@ HWND hWnd, POINT pt) { + return NtUserDragDetect(hWnd, pt); #if 0 - return NtUserDragDetect(hWnd, pt); -#else MSG msg; RECT rect; POINT tmp;
Modified: trunk/reactos/subsystems/win32/win32k/include/winpos.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/winpos.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/winpos.h [iso-8859-1] Sat Mar 12 01:29:08 2011 @@ -8,6 +8,9 @@ (!(WndObject)->hrgnClip || ((WndObject)->style & WS_MINIMIZE) || \ 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);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/focus.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/focus.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/focus.c [iso-8859-1] Sat Mar 12 01:29:08 2011 @@ -534,55 +534,63 @@ END_CLEANUP; }
+ +HWND FASTCALL +co_UserSetCapture(HWND hWnd) +{ + PTHREADINFO pti; + PUSER_MESSAGE_QUEUE ThreadQueue; + PWND Window, pWnd; + HWND hWndPrev; + + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; + + if ((Window = UserGetWindowObject(hWnd))) + { + if (Window->head.pti->MessageQueue != ThreadQueue) + { + return NULL; + } + } + + hWndPrev = MsqSetStateWindow(ThreadQueue, MSQ_STATE_CAPTURE, hWnd); + + if (hWndPrev) + { + pWnd = UserGetWindowObject(hWndPrev); + if (pWnd) + IntNotifyWinEvent(EVENT_SYSTEM_CAPTUREEND, pWnd, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); + } + + /* also remove other windows if not capturing anymore */ + if (hWnd == NULL) + { + MsqSetStateWindow(ThreadQueue, MSQ_STATE_MENUOWNER, NULL); + MsqSetStateWindow(ThreadQueue, MSQ_STATE_MOVESIZE, NULL); + } + + if (Window) + IntNotifyWinEvent(EVENT_SYSTEM_CAPTURESTART, Window, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); + + co_IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd); + ThreadQueue->CaptureWindow = hWnd; + + return hWndPrev; +} + /* * @implemented */ HWND APIENTRY NtUserSetCapture(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->head.pti->MessageQueue != ThreadQueue) - { - RETURN(NULL); - } - } - - hWndPrev = MsqSetStateWindow(ThreadQueue, MSQ_STATE_CAPTURE, hWnd); - - if (hWndPrev) - { - pWnd = UserGetWindowObject(hWndPrev); - if (pWnd) - IntNotifyWinEvent(EVENT_SYSTEM_CAPTUREEND, pWnd, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); - } - - /* also remove other windows if not capturing anymore */ - if (hWnd == NULL) - { - MsqSetStateWindow(ThreadQueue, MSQ_STATE_MENUOWNER, NULL); - MsqSetStateWindow(ThreadQueue, MSQ_STATE_MOVESIZE, NULL); - } - - if (Window) - IntNotifyWinEvent(EVENT_SYSTEM_CAPTURESTART, Window, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); - - co_IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd); - ThreadQueue->CaptureWindow = hWnd; - - RETURN( hWndPrev); + RETURN( co_UserSetCapture(hWnd));
CLEANUP: DPRINT("Leave NtUserSetCapture, ret=%i\n",_ret_);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] Sat Mar 12 01:29:08 2011 @@ -16,6 +16,7 @@ #include <debug.h>
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 @@
/** 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,
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] Sat Mar 12 01:29:08 2011 @@ -1338,16 +1338,6 @@ return 0; }
-BOOL -APIENTRY -NtUserDragDetect( - HWND hWnd, - POINT pt) // Just like the User call. -{ - UNIMPLEMENTED - return 0; -} - /* * @unimplemented */