[PATCH 2/6] win32u: Move WM_SETCURSOR implementation from user32.
Jacek Caban
wine at gitlab.winehq.org
Thu Jun 16 18:56:42 CDT 2022
From: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
---
dlls/user32/controls.h | 1 -
dlls/user32/defwnd.c | 15 ----------
dlls/user32/nonclient.c | 52 ---------------------------------
dlls/win32u/defwnd.c | 64 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 64 insertions(+), 68 deletions(-)
diff --git a/dlls/user32/controls.h b/dlls/user32/controls.h
index 3fadcc113c0..a0047d6183d 100644
--- a/dlls/user32/controls.h
+++ b/dlls/user32/controls.h
@@ -123,7 +123,6 @@ extern LRESULT NC_HandleNCMouseMove( HWND hwnd, WPARAM wParam, LPARAM lParam ) D
extern LRESULT NC_HandleNCMouseLeave( HWND hwnd ) DECLSPEC_HIDDEN;
extern LRESULT NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam) DECLSPEC_HIDDEN;
extern LRESULT NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
-extern LRESULT NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
/* scrollbar */
diff --git a/dlls/user32/defwnd.c b/dlls/user32/defwnd.c
index 57e12d8e00b..fd6c44dd29b 100644
--- a/dlls/user32/defwnd.c
+++ b/dlls/user32/defwnd.c
@@ -225,21 +225,6 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
case WM_CTLCOLOR:
return (LRESULT)DEFWND_ControlColor( (HDC)wParam, HIWORD(lParam) );
- case WM_SETCURSOR:
- if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
- {
- /* with the exception of the border around a resizable wnd,
- * give the parent first chance to set the cursor */
- if ((LOWORD(lParam) < HTSIZEFIRST) || (LOWORD(lParam) > HTSIZELAST))
- {
- HWND parent = GetParent( hwnd );
- if (parent != GetDesktopWindow() &&
- SendMessageW( parent, WM_SETCURSOR, wParam, lParam )) return TRUE;
- }
- }
- NC_HandleSetCursor( hwnd, wParam, lParam );
- break;
-
case WM_SYSCOMMAND:
return NC_HandleSysCommand( hwnd, wParam, lParam );
diff --git a/dlls/user32/nonclient.c b/dlls/user32/nonclient.c
index 73d5b6449de..cc31e1b2f2f 100644
--- a/dlls/user32/nonclient.c
+++ b/dlls/user32/nonclient.c
@@ -236,58 +236,6 @@ LRESULT NC_HandleNCMouseLeave(HWND hwnd)
return 0;
}
-/***********************************************************************
- * NC_HandleSetCursor
- *
- * Handle a WM_SETCURSOR message. Called from DefWindowProc().
- */
-LRESULT NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam )
-{
- hwnd = WIN_GetFullHandle( (HWND)wParam );
-
- switch((short)LOWORD(lParam))
- {
- case HTERROR:
- {
- WORD msg = HIWORD( lParam );
- if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
- (msg == WM_RBUTTONDOWN) || (msg == WM_XBUTTONDOWN))
- MessageBeep(0);
- }
- break;
-
- case HTCLIENT:
- {
- HCURSOR hCursor = (HCURSOR)GetClassLongPtrW(hwnd, GCLP_HCURSOR);
- if(hCursor) {
- NtUserSetCursor(hCursor);
- return TRUE;
- }
- return FALSE;
- }
-
- case HTLEFT:
- case HTRIGHT:
- return (LRESULT)NtUserSetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZEWE ) );
-
- case HTTOP:
- case HTBOTTOM:
- return (LRESULT)NtUserSetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZENS ) );
-
- case HTTOPLEFT:
- case HTBOTTOMRIGHT:
- return (LRESULT)NtUserSetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZENWSE ) );
-
- case HTTOPRIGHT:
- case HTBOTTOMLEFT:
- return (LRESULT)NtUserSetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZENESW ) );
- }
-
- /* Default cursor: arrow */
- return (LRESULT)NtUserSetCursor( LoadCursorA( 0, (LPSTR)IDC_ARROW ) );
-}
-
-
/***********************************************************************
* NC_TrackScrollBar
diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c
index e3025e68d02..a385d581d3a 100644
--- a/dlls/win32u/defwnd.c
+++ b/dlls/win32u/defwnd.c
@@ -414,6 +414,55 @@ static HICON set_window_icon( HWND hwnd, WPARAM type, HICON icon )
return ret;
}
+static LRESULT handle_set_cursor( HWND hwnd, WPARAM wparam, LPARAM lparam )
+{
+ UINT cursor_id = IDC_ARROW;
+ HCURSOR cursor;
+
+ hwnd = get_full_window_handle( (HWND)wparam );
+
+ switch((short)LOWORD( lparam ))
+ {
+ case HTERROR:
+ {
+ WORD msg = HIWORD( lparam );
+ if (msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN ||
+ msg == WM_RBUTTONDOWN || msg == WM_XBUTTONDOWN)
+ message_beep( 0 );
+ }
+ break;
+
+ case HTCLIENT:
+ cursor = (HCURSOR)get_class_long_ptr( hwnd, GCLP_HCURSOR, FALSE );
+ if (!cursor) return FALSE;
+ NtUserSetCursor( cursor );
+ return TRUE;
+
+ case HTLEFT:
+ case HTRIGHT:
+ cursor_id = IDC_SIZEWE;
+ break;
+
+ case HTTOP:
+ case HTBOTTOM:
+ cursor_id = IDC_SIZENS;
+ break;
+
+ case HTTOPLEFT:
+ case HTBOTTOMRIGHT:
+ cursor_id = IDC_SIZENWSE;
+ break;
+
+ case HTTOPRIGHT:
+ case HTBOTTOMLEFT:
+ cursor_id = IDC_SIZENESW;
+ }
+
+ cursor = LoadImageW( 0, MAKEINTRESOURCEW( cursor_id ), IMAGE_CURSOR,
+ 0, 0, LR_SHARED | LR_DEFAULTSIZE );
+ return (LRESULT)NtUserSetCursor( cursor );
+}
+
static LONG handle_window_pos_changing( HWND hwnd, WINDOWPOS *winpos )
{
LONG style = get_window_long( hwnd, GWL_STYLE );
@@ -2306,6 +2355,21 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
result = (LRESULT)get_window_icon( hwnd, wparam );
break;
+ case WM_SETCURSOR:
+ if (get_window_long( hwnd, GWL_STYLE ) & WS_CHILD)
+ {
+ /* with the exception of the border around a resizable window,
+ * give the parent first chance to set the cursor */
+ if ((LOWORD( lparam ) < HTSIZEFIRST) || (LOWORD( lparam ) > HTSIZELAST))
+ {
+ HWND parent = get_parent( hwnd );
+ if (parent != get_desktop_window() &&
+ send_message( parent, WM_SETCURSOR, wparam, lparam )) return TRUE;
+ }
+ }
+ handle_set_cursor( hwnd, wparam, lparam );
+ break;
+
case WM_SYSCOMMAND:
result = handle_sys_command( hwnd, wparam, lparam );
break;
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/261
More information about the wine-devel
mailing list