[PATCH 4/7] win32u: Move NtUserDragDetect implementation from user32.
Jacek Caban
wine at gitlab.winehq.org
Wed Jun 8 19:14:33 CDT 2022
From: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
---
dlls/user32/win.c | 42 ++-------------------------------
dlls/win32u/gdiobj.c | 1 +
dlls/win32u/input.c | 45 ++++++++++++++++++++++++++++++++++++
dlls/win32u/win32u.spec | 2 +-
dlls/win32u/win32u_private.h | 1 +
dlls/win32u/wrappers.c | 6 +++++
include/ntuser.h | 1 +
7 files changed, 57 insertions(+), 41 deletions(-)
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 4adffc37d6b..7b0fc884402 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -1482,47 +1482,9 @@ BOOL WINAPI SetWindowContextHelpId( HWND hwnd, DWORD id )
/*******************************************************************
* DragDetect (USER32.@)
*/
-BOOL WINAPI DragDetect( HWND hWnd, POINT pt )
+BOOL WINAPI DragDetect( HWND hwnd, POINT pt )
{
- MSG msg;
- RECT rect;
- WORD wDragWidth, wDragHeight;
-
- TRACE( "%p,%s\n", hWnd, wine_dbgstr_point( &pt ) );
-
- if (!(NtUserGetKeyState( VK_LBUTTON ) & 0x8000))
- return FALSE;
-
- wDragWidth = GetSystemMetrics(SM_CXDRAG);
- wDragHeight= GetSystemMetrics(SM_CYDRAG);
- SetRect(&rect, pt.x - wDragWidth, pt.y - wDragHeight, pt.x + wDragWidth, pt.y + wDragHeight);
-
- NtUserSetCapture( hWnd );
-
- while(1)
- {
- while (PeekMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ))
- {
- if( msg.message == WM_LBUTTONUP )
- {
- ReleaseCapture();
- return FALSE;
- }
- if( msg.message == WM_MOUSEMOVE )
- {
- POINT tmp;
- tmp.x = (short)LOWORD(msg.lParam);
- tmp.y = (short)HIWORD(msg.lParam);
- if( !PtInRect( &rect, tmp ))
- {
- ReleaseCapture();
- return TRUE;
- }
- }
- }
- WaitMessage();
- }
- return FALSE;
+ return NtUserDragDetect( hwnd, pt.x, pt.y );
}
/******************************************************************************
diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c
index 222b74b45d6..7d9adcdec6a 100644
--- a/dlls/win32u/gdiobj.c
+++ b/dlls/win32u/gdiobj.c
@@ -1158,6 +1158,7 @@ static struct unix_funcs unix_funcs =
NtUserDestroyMenu,
NtUserDestroyWindow,
NtUserDispatchMessage,
+ NtUserDragDetect,
NtUserDrawIconEx,
NtUserEmptyClipboard,
NtUserEnableMenuItem,
diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c
index 2b196fb5b1d..6f0e4f45501 100644
--- a/dlls/win32u/input.c
+++ b/dlls/win32u/input.c
@@ -1394,6 +1394,51 @@ BOOL WINAPI NtUserTrackMouseEvent( TRACKMOUSEEVENT *info )
return TRUE;
}
+/*******************************************************************
+ * NtUserDragDetect (win32u.@)
+ */
+BOOL WINAPI NtUserDragDetect( HWND hwnd, int x, int y )
+{
+ WORD width, height;
+ RECT rect;
+ MSG msg;
+
+ TRACE( "%p (%d,%d)\n", hwnd, x, y );
+
+ if (!(NtUserGetKeyState( VK_LBUTTON ) & 0x8000)) return FALSE;
+
+ width = get_system_metrics( SM_CXDRAG );
+ height = get_system_metrics( SM_CYDRAG );
+ SetRect( &rect, x - width, y - height, x + width, y + height );
+
+ NtUserSetCapture( hwnd );
+
+ for (;;)
+ {
+ while (NtUserPeekMessage( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ))
+ {
+ if (msg.message == WM_LBUTTONUP)
+ {
+ release_capture();
+ return FALSE;
+ }
+ if (msg.message == WM_MOUSEMOVE)
+ {
+ POINT tmp;
+ tmp.x = (short)LOWORD( msg.lParam );
+ tmp.y = (short)HIWORD( msg.lParam );
+ if (!PtInRect( &rect, tmp ))
+ {
+ release_capture();
+ return TRUE;
+ }
+ }
+ }
+ NtUserMsgWaitForMultipleObjectsEx( 0, NULL, INFINITE, QS_ALLINPUT, 0 );
+ }
+ return FALSE;
+}
+
/**********************************************************************
* set_capture_window
*/
diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec
index 86d359b8386..28c839f5901 100644
--- a/dlls/win32u/win32u.spec
+++ b/dlls/win32u/win32u.spec
@@ -845,7 +845,7 @@
@ stub NtUserDoSoundConnect
@ stub NtUserDoSoundDisconnect
@ stub NtUserDownlevelTouchpad
-@ stub NtUserDragDetect
+@ stdcall NtUserDragDetect(long long long)
@ stub NtUserDragObject
@ stub NtUserDrawAnimatedRects
@ stub NtUserDrawCaption
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index 2394a8850a5..e72ab8ff1d7 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -214,6 +214,7 @@ struct unix_funcs
BOOL (WINAPI *pNtUserDestroyMenu)( HMENU handle );
BOOL (WINAPI *pNtUserDestroyWindow)( HWND hwnd );
LRESULT (WINAPI *pNtUserDispatchMessage)( const MSG *msg );
+ BOOL (WINAPI *pNtUserDragDetect)( HWND hwnd, int x, int y );
BOOL (WINAPI *pNtUserDrawIconEx)( HDC hdc, INT x0, INT y0, HICON icon, INT width,
INT height, UINT istep, HBRUSH hbr, UINT flags );
BOOL (WINAPI *pNtUserEmptyClipboard)(void);
diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c
index 679cce95b9a..e4219ed5648 100644
--- a/dlls/win32u/wrappers.c
+++ b/dlls/win32u/wrappers.c
@@ -855,6 +855,12 @@ LRESULT WINAPI NtUserDispatchMessage( const MSG *msg )
return unix_funcs->pNtUserDispatchMessage( msg );
}
+BOOL WINAPI NtUserDragDetect( HWND hwnd, int x, int y )
+{
+ if (!unix_funcs) return FALSE;
+ return unix_funcs->pNtUserDragDetect( hwnd, x, y );
+}
+
BOOL WINAPI NtUserDrawIconEx( HDC hdc, INT x0, INT y0, HICON icon, INT width,
INT height, UINT istep, HBRUSH hbr, UINT flags )
{
diff --git a/include/ntuser.h b/include/ntuser.h
index 482bdbcbddd..7451d649702 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -513,6 +513,7 @@ BOOL WINAPI NtUserDestroyCursor( HCURSOR cursor, ULONG arg );
BOOL WINAPI NtUserDestroyMenu( HMENU menu );
BOOL WINAPI NtUserDestroyWindow( HWND hwnd );
LRESULT WINAPI NtUserDispatchMessage( const MSG *msg );
+BOOL WINAPI NtUserDragDetect( HWND hwnd, int x, int y );
BOOL WINAPI NtUserDrawIconEx( HDC hdc, INT x0, INT y0, HICON icon, INT width,
INT height, UINT istep, HBRUSH hbr, UINT flags );
BOOL WINAPI NtUserEmptyClipboard(void);
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/211
More information about the wine-devel
mailing list