win32u: Move NtUserSetCursor implementation from user32.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4f1853c576
commit
744853fd56
|
@ -1707,44 +1707,6 @@ BOOL WINAPI DrawIcon( HDC hdc, INT x, INT y, HICON hIcon )
|
|||
return DrawIconEx( hdc, x, y, hIcon, 0, 0, 0, 0, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetCursor (USER32.@)
|
||||
*
|
||||
* Set the cursor shape.
|
||||
*
|
||||
* RETURNS
|
||||
* A handle to the previous cursor shape.
|
||||
*/
|
||||
HCURSOR WINAPI DECLSPEC_HOTPATCH SetCursor( HCURSOR hCursor /* [in] Handle of cursor to show */ )
|
||||
{
|
||||
struct cursoricon_object *obj;
|
||||
HCURSOR hOldCursor;
|
||||
int show_count;
|
||||
BOOL ret;
|
||||
|
||||
TRACE("%p\n", hCursor);
|
||||
|
||||
SERVER_START_REQ( set_cursor )
|
||||
{
|
||||
req->flags = SET_CURSOR_HANDLE;
|
||||
req->handle = wine_server_user_handle( hCursor );
|
||||
if ((ret = !wine_server_call_err( req )))
|
||||
{
|
||||
hOldCursor = wine_server_ptr_handle( reply->prev_handle );
|
||||
show_count = reply->prev_count;
|
||||
}
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
||||
if (!ret) return 0;
|
||||
USER_Driver->pSetCursor( show_count >= 0 ? hCursor : 0 );
|
||||
|
||||
if (!(obj = get_icon_ptr( hOldCursor ))) return 0;
|
||||
release_user_handle_ptr( obj );
|
||||
return hOldCursor;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetClipCursor (USER32.@)
|
||||
*/
|
||||
|
|
|
@ -128,10 +128,6 @@ static void CDECL nulldrv_UnregisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
|
|||
{
|
||||
}
|
||||
|
||||
static void CDECL nulldrv_SetCursor( HCURSOR cursor )
|
||||
{
|
||||
}
|
||||
|
||||
static BOOL CDECL nulldrv_SetCursorPos( INT x, INT y )
|
||||
{
|
||||
return TRUE;
|
||||
|
@ -280,11 +276,6 @@ static void CDECL loaderdrv_UnregisterHotKey( HWND hwnd, UINT modifiers, UINT vk
|
|||
load_driver()->pUnregisterHotKey( hwnd, modifiers, vk );
|
||||
}
|
||||
|
||||
static void CDECL loaderdrv_SetCursor( HCURSOR cursor )
|
||||
{
|
||||
load_driver()->pSetCursor( cursor );
|
||||
}
|
||||
|
||||
static BOOL CDECL loaderdrv_SetCursorPos( INT x, INT y )
|
||||
{
|
||||
return load_driver()->pSetCursorPos( x, y );
|
||||
|
@ -352,7 +343,7 @@ static struct user_driver_funcs lazy_load_driver =
|
|||
NULL,
|
||||
/* cursor/icon functions */
|
||||
NULL,
|
||||
loaderdrv_SetCursor,
|
||||
NULL,
|
||||
NULL,
|
||||
loaderdrv_SetCursorPos,
|
||||
loaderdrv_ClipCursor,
|
||||
|
@ -411,7 +402,6 @@ void CDECL __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT v
|
|||
|
||||
SET_USER_FUNC(RegisterHotKey);
|
||||
SET_USER_FUNC(UnregisterHotKey);
|
||||
SET_USER_FUNC(SetCursor);
|
||||
SET_USER_FUNC(SetCursorPos);
|
||||
SET_USER_FUNC(ClipCursor);
|
||||
SET_USER_FUNC(UpdateClipboard);
|
||||
|
|
|
@ -1151,7 +1151,7 @@ LRESULT NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam )
|
|||
{
|
||||
HCURSOR hCursor = (HCURSOR)GetClassLongPtrW(hwnd, GCLP_HCURSOR);
|
||||
if(hCursor) {
|
||||
SetCursor(hCursor);
|
||||
NtUserSetCursor(hCursor);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -1159,23 +1159,23 @@ LRESULT NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam )
|
|||
|
||||
case HTLEFT:
|
||||
case HTRIGHT:
|
||||
return (LRESULT)SetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZEWE ) );
|
||||
return (LRESULT)NtUserSetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZEWE ) );
|
||||
|
||||
case HTTOP:
|
||||
case HTBOTTOM:
|
||||
return (LRESULT)SetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZENS ) );
|
||||
return (LRESULT)NtUserSetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZENS ) );
|
||||
|
||||
case HTTOPLEFT:
|
||||
case HTBOTTOMRIGHT:
|
||||
return (LRESULT)SetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZENWSE ) );
|
||||
return (LRESULT)NtUserSetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZENWSE ) );
|
||||
|
||||
case HTTOPRIGHT:
|
||||
case HTBOTTOMLEFT:
|
||||
return (LRESULT)SetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZENESW ) );
|
||||
return (LRESULT)NtUserSetCursor( LoadCursorA( 0, (LPSTR)IDC_SIZENESW ) );
|
||||
}
|
||||
|
||||
/* Default cursor: arrow */
|
||||
return (LRESULT)SetCursor( LoadCursorA( 0, (LPSTR)IDC_ARROW ) );
|
||||
return (LRESULT)NtUserSetCursor( LoadCursorA( 0, (LPSTR)IDC_ARROW ) );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
|
@ -1532,7 +1532,7 @@ LRESULT WINAPI USER_ScrollBarProc( HWND hwnd, UINT message, WPARAM wParam, LPARA
|
|||
if (GetWindowLongW( hwnd, GWL_STYLE ) & SBS_SIZEGRIP)
|
||||
{
|
||||
ULONG_PTR cursor = (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL) ? IDC_SIZENESW : IDC_SIZENWSE;
|
||||
return (LRESULT)SetCursor( LoadCursorA( 0, (LPSTR)cursor ));
|
||||
return (LRESULT)NtUserSetCursor( LoadCursorA( 0, (LPSTR)cursor ));
|
||||
}
|
||||
return DefWindowProcW( hwnd, message, wParam, lParam );
|
||||
|
||||
|
|
|
@ -657,7 +657,7 @@
|
|||
@ stdcall SetClipboardViewer(long)
|
||||
@ stdcall SetCoalescableTimer(long long long ptr long)
|
||||
# @ stub SetConsoleReserveKeys
|
||||
@ stdcall SetCursor(long)
|
||||
@ stdcall -import SetCursor(long) NtUserSetCursor
|
||||
@ stub SetCursorContents
|
||||
@ stdcall -import SetCursorPos(long long) NtUserSetCursorPos
|
||||
@ stdcall SetDebugErrorLevel(long)
|
||||
|
|
|
@ -2761,7 +2761,7 @@ static LONG start_size_move( HWND hwnd, WPARAM wParam, POINT *capturePoint, LONG
|
|||
}
|
||||
else /* SC_SIZE */
|
||||
{
|
||||
SetCursor( LoadCursorW( 0, (LPWSTR)IDC_SIZEALL ) );
|
||||
NtUserSetCursor( LoadCursorW( 0, (LPWSTR)IDC_SIZEALL ) );
|
||||
pt.x = pt.y = 0;
|
||||
while(!hittest)
|
||||
{
|
||||
|
|
|
@ -38,6 +38,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(cursor);
|
|||
|
||||
static struct list icon_cache = LIST_INIT( icon_cache );
|
||||
|
||||
static struct cursoricon_object *get_icon_ptr( HICON handle )
|
||||
{
|
||||
struct cursoricon_object *obj = get_user_handle_ptr( handle, NTUSER_OBJ_ICON );
|
||||
if (obj == OBJ_OTHER_PROCESS)
|
||||
{
|
||||
WARN( "icon handle %p from other process\n", handle );
|
||||
obj = NULL;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* NtUserShowCursor (win32u.@)
|
||||
*/
|
||||
|
@ -65,6 +76,37 @@ INT WINAPI NtUserShowCursor( BOOL show )
|
|||
return count;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* NtUserSetCursor (win32u.@)
|
||||
*/
|
||||
HCURSOR WINAPI NtUserSetCursor( HCURSOR cursor )
|
||||
{
|
||||
struct cursoricon_object *obj;
|
||||
HCURSOR old_cursor;
|
||||
int show_count;
|
||||
BOOL ret;
|
||||
|
||||
TRACE( "%p\n", cursor );
|
||||
|
||||
SERVER_START_REQ( set_cursor )
|
||||
{
|
||||
req->flags = SET_CURSOR_HANDLE;
|
||||
req->handle = wine_server_user_handle( cursor );
|
||||
if ((ret = !wine_server_call_err( req )))
|
||||
{
|
||||
old_cursor = wine_server_ptr_handle( reply->prev_handle );
|
||||
show_count = reply->prev_count;
|
||||
}
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
if (!ret) return 0;
|
||||
|
||||
user_driver->pSetCursor( show_count >= 0 ? cursor : 0 );
|
||||
|
||||
if (!(obj = get_icon_ptr( old_cursor ))) return 0;
|
||||
release_user_handle_ptr( obj );
|
||||
return old_cursor;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* NtUserGetCursor (win32u.@)
|
||||
|
@ -170,17 +212,6 @@ HICON alloc_cursoricon_handle( BOOL is_icon )
|
|||
return handle;
|
||||
}
|
||||
|
||||
static struct cursoricon_object *get_icon_ptr( HICON handle )
|
||||
{
|
||||
struct cursoricon_object *obj = get_user_handle_ptr( handle, NTUSER_OBJ_ICON );
|
||||
if (obj == OBJ_OTHER_PROCESS)
|
||||
{
|
||||
WARN( "icon handle %p from other process\n", handle );
|
||||
obj = NULL;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
static BOOL free_icon_handle( HICON handle )
|
||||
{
|
||||
struct cursoricon_object *obj = free_user_handle( handle, NTUSER_OBJ_ICON );
|
||||
|
|
|
@ -1171,6 +1171,7 @@ static struct unix_funcs unix_funcs =
|
|||
NtUserMapVirtualKeyEx,
|
||||
NtUserScrollDC,
|
||||
NtUserSelectPalette,
|
||||
NtUserSetCursor,
|
||||
NtUserSetCursorIconData,
|
||||
NtUserSetCursorPos,
|
||||
NtUserSetSysColors,
|
||||
|
|
|
@ -1178,7 +1178,7 @@
|
|||
@ stub NtUserSetClipboardViewer
|
||||
@ stub NtUserSetCoreWindow
|
||||
@ stub NtUserSetCoreWindowPartner
|
||||
@ stub NtUserSetCursor
|
||||
@ stdcall NtUserSetCursor(long)
|
||||
@ stub NtUserSetCursorContents
|
||||
@ stdcall NtUserSetCursorIconData(long ptr ptr ptr)
|
||||
@ stdcall NtUserSetCursorPos(long long)
|
||||
|
|
|
@ -209,6 +209,7 @@ struct unix_funcs
|
|||
BOOL (WINAPI *pNtUserScrollDC)( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
|
||||
HRGN ret_update_rgn, RECT *update_rect );
|
||||
HPALETTE (WINAPI *pNtUserSelectPalette)( HDC hdc, HPALETTE hpal, WORD bkg );
|
||||
HCURSOR (WINAPI *pNtUserSetCursor)( HCURSOR cursor );
|
||||
BOOL (WINAPI *pNtUserSetCursorIconData)( HCURSOR cursor, UNICODE_STRING *module,
|
||||
UNICODE_STRING *res_name, struct cursoricon_desc *desc );
|
||||
BOOL (WINAPI *pNtUserSetCursorPos)( INT x, INT y );
|
||||
|
|
|
@ -832,6 +832,12 @@ HPALETTE WINAPI NtUserSelectPalette( HDC hdc, HPALETTE hpal, WORD bkg )
|
|||
return unix_funcs->pNtUserSelectPalette( hdc, hpal, bkg );
|
||||
}
|
||||
|
||||
HCURSOR WINAPI NtUserSetCursor( HCURSOR cursor )
|
||||
{
|
||||
if (!unix_funcs) return 0;
|
||||
return unix_funcs->pNtUserSetCursor( cursor );
|
||||
}
|
||||
|
||||
BOOL WINAPI NtUserSetCursorIconData( HCURSOR cursor, UNICODE_STRING *module, UNICODE_STRING *res_name,
|
||||
struct cursoricon_desc *desc )
|
||||
{
|
||||
|
|
|
@ -236,6 +236,7 @@ HANDLE WINAPI NtUserRemoveProp( HWND hwnd, const WCHAR *str );
|
|||
BOOL WINAPI NtUserScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
|
||||
HRGN ret_update_rgn, RECT *update_rect );
|
||||
HPALETTE WINAPI NtUserSelectPalette( HDC hdc, HPALETTE palette, WORD force_background );
|
||||
HCURSOR WINAPI NtUserSetCursor( HCURSOR cursor );
|
||||
BOOL WINAPI NtUserSetCursorIconData( HCURSOR cursor, UNICODE_STRING *module, UNICODE_STRING *res_name,
|
||||
struct cursoricon_desc *desc );
|
||||
BOOL WINAPI NtUserSetCursorPos( INT x, INT y );
|
||||
|
|
Loading…
Reference in New Issue