Commit 91c095cd authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move NtUserClipCursor implementation from user32.

parent db8fcc1c
......@@ -1943,55 +1943,6 @@ HCURSOR WINAPI DECLSPEC_HOTPATCH SetCursor( HCURSOR hCursor /* [in] Handle of cu
/***********************************************************************
* ClipCursor (USER32.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH ClipCursor( const RECT *rect )
{
UINT dpi;
BOOL ret;
RECT new_rect;
TRACE( "Clipping to %s\n", wine_dbgstr_rect(rect) );
if (rect)
{
if (rect->left > rect->right || rect->top > rect->bottom) return FALSE;
if ((dpi = get_thread_dpi()))
{
new_rect = map_dpi_rect( *rect, dpi,
get_monitor_dpi( MonitorFromRect( rect, MONITOR_DEFAULTTOPRIMARY )));
rect = &new_rect;
}
}
SERVER_START_REQ( set_cursor )
{
req->clip_msg = WM_WINE_CLIPCURSOR;
if (rect)
{
req->flags = SET_CURSOR_CLIP;
req->clip.left = rect->left;
req->clip.top = rect->top;
req->clip.right = rect->right;
req->clip.bottom = rect->bottom;
}
else req->flags = SET_CURSOR_NOCLIP;
if ((ret = !wine_server_call( req )))
{
new_rect.left = reply->new_clip.left;
new_rect.top = reply->new_clip.top;
new_rect.right = reply->new_clip.right;
new_rect.bottom = reply->new_clip.bottom;
}
}
SERVER_END_REQ;
if (ret) USER_Driver->pClipCursor( &new_rect );
return ret;
}
/***********************************************************************
* GetClipCursor (USER32.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH GetClipCursor( RECT *rect )
......
......@@ -72,7 +72,7 @@
@ stub ClientThreadConnect
@ stub ClientThreadSetup
@ stdcall ClientToScreen(long ptr)
@ stdcall ClipCursor(ptr)
@ stdcall -import ClipCursor(ptr) NtUserClipCursor
@ stdcall CloseClipboard()
@ stdcall CloseDesktop(long) NtUserCloseDesktop
@ stdcall CloseTouchInputHandle(long)
......
......@@ -2849,7 +2849,7 @@ void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
pt.x = (short)LOWORD(dwPoint);
pt.y = (short)HIWORD(dwPoint);
capturePoint = pt;
ClipCursor( NULL );
NtUserClipCursor( NULL );
TRACE("hwnd %p command %04lx, hittest %d, pos %d,%d\n",
hwnd, syscommand, hittest, pt.x, pt.y);
......
......@@ -79,3 +79,51 @@ HCURSOR WINAPI NtUserGetCursor(void)
SERVER_END_REQ;
return ret;
}
/***********************************************************************
* NtUserClipCursor (win32u.@)
*/
BOOL WINAPI NtUserClipCursor( const RECT *rect )
{
UINT dpi;
BOOL ret;
RECT new_rect;
TRACE( "Clipping to %s\n", wine_dbgstr_rect(rect) );
if (rect)
{
if (rect->left > rect->right || rect->top > rect->bottom) return FALSE;
if ((dpi = get_thread_dpi()))
{
HMONITOR monitor = monitor_from_rect( rect, MONITOR_DEFAULTTOPRIMARY, dpi );
new_rect = map_dpi_rect( *rect, dpi, get_monitor_dpi( monitor ));
rect = &new_rect;
}
}
SERVER_START_REQ( set_cursor )
{
req->clip_msg = WM_WINE_CLIPCURSOR;
if (rect)
{
req->flags = SET_CURSOR_CLIP;
req->clip.left = rect->left;
req->clip.top = rect->top;
req->clip.right = rect->right;
req->clip.bottom = rect->bottom;
}
else req->flags = SET_CURSOR_NOCLIP;
if ((ret = !wine_server_call( req )))
{
new_rect.left = reply->new_clip.left;
new_rect.top = reply->new_clip.top;
new_rect.right = reply->new_clip.right;
new_rect.bottom = reply->new_clip.bottom;
}
}
SERVER_END_REQ;
if (ret) user_driver->pClipCursor( &new_rect );
return ret;
}
......@@ -1005,6 +1005,11 @@ static void CDECL loaderdrv_SetCursor( HCURSOR cursor )
load_driver()->pSetCursor( cursor );
}
static BOOL CDECL loaderdrv_ClipCursor( const RECT *clip )
{
return load_driver()->pClipCursor( clip );
}
static void CDECL loaderdrv_UpdateClipboard(void)
{
load_driver()->pUpdateClipboard();
......@@ -1034,6 +1039,7 @@ static const struct user_driver_funcs lazy_load_driver =
.pEnumDisplaySettingsEx = loaderdrv_EnumDisplaySettingsEx,
.pUpdateDisplayDevices = loaderdrv_UpdateDisplayDevices,
.pSetCursor = loaderdrv_SetCursor,
.pClipCursor = loaderdrv_ClipCursor,
.pUpdateClipboard = loaderdrv_UpdateClipboard,
.pScrollDC = nulldrv_ScrollDC,
.pSystemParametersInfo = nulldrv_SystemParametersInfo,
......
......@@ -1153,6 +1153,7 @@ static struct unix_funcs unix_funcs =
NtUserCallOneParam,
NtUserCallTwoParam,
NtUserChangeDisplaySettings,
NtUserClipCursor,
NtUserCountClipboardFormats,
NtUserEnumDisplayDevices,
NtUserEnumDisplayMonitors,
......
......@@ -1342,7 +1342,7 @@ void release_display_dc( HDC hdc )
/**********************************************************************
* get_monitor_dpi
*/
static UINT get_monitor_dpi( HMONITOR monitor )
UINT get_monitor_dpi( HMONITOR monitor )
{
/* FIXME: use the monitor DPI instead */
return system_dpi;
......@@ -1379,7 +1379,7 @@ static DPI_AWARENESS get_thread_dpi_awareness(void)
/**********************************************************************
* get_thread_dpi
*/
static UINT get_thread_dpi(void)
UINT get_thread_dpi(void)
{
switch (get_thread_dpi_awareness())
{
......@@ -1936,7 +1936,7 @@ static BOOL get_monitor_info( HMONITOR handle, MONITORINFO *info )
return FALSE;
}
static HMONITOR monitor_from_rect( const RECT *rect, DWORD flags, UINT dpi )
HMONITOR monitor_from_rect( const RECT *rect, DWORD flags, UINT dpi )
{
HMONITOR primary = 0, nearest = 0, ret = 0;
UINT max_area = 0, min_distance = ~0u;
......
......@@ -792,7 +792,7 @@
@ stub NtUserCheckWindowThreadDesktop
@ stub NtUserChildWindowFromPointEx
@ stub NtUserClearForeground
@ stub NtUserClipCursor
@ stdcall NtUserClipCursor(ptr)
@ stub NtUserCloseClipboard
@ stdcall -syscall NtUserCloseDesktop(long)
@ stdcall -syscall NtUserCloseWindowStation(long)
......
......@@ -196,6 +196,7 @@ struct unix_funcs
ULONG_PTR (WINAPI *pNtUserCallTwoParam)( ULONG_PTR arg1, ULONG_PTR arg2, ULONG code );
LONG (WINAPI *pNtUserChangeDisplaySettings)( UNICODE_STRING *devname, DEVMODEW *devmode, HWND hwnd,
DWORD flags, void *lparam );
BOOL (WINAPI *pNtUserClipCursor)( const RECT *rect );
INT (WINAPI *pNtUserCountClipboardFormats)(void);
NTSTATUS (WINAPI *pNtUserEnumDisplayDevices)( UNICODE_STRING *device, DWORD index,
DISPLAY_DEVICEW *info, DWORD flags );
......@@ -241,9 +242,13 @@ struct unix_funcs
};
extern RECT get_display_rect( const WCHAR *display ) DECLSPEC_HIDDEN;
extern UINT get_monitor_dpi( HMONITOR monitor ) DECLSPEC_HIDDEN;
extern UINT get_system_dpi(void) DECLSPEC_HIDDEN;
extern int get_system_metrics( int index ) DECLSPEC_HIDDEN;
extern UINT get_thread_dpi(void) DECLSPEC_HIDDEN;
extern RECT get_virtual_screen_rect( UINT dpi ) DECLSPEC_HIDDEN;
extern RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN;
extern HMONITOR monitor_from_rect( const RECT *rect, DWORD flags, UINT dpi ) DECLSPEC_HIDDEN;
extern void wrappers_init( unixlib_handle_t handle ) DECLSPEC_HIDDEN;
extern NTSTATUS gdi_init(void) DECLSPEC_HIDDEN;
......
......@@ -720,6 +720,12 @@ LONG WINAPI NtUserChangeDisplaySettings( UNICODE_STRING *devname, DEVMODEW *devm
return unix_funcs->pNtUserChangeDisplaySettings( devname, devmode, hwnd, flags, lparam );
}
BOOL WINAPI NtUserClipCursor( const RECT *rect )
{
if (!unix_funcs) return FALSE;
return unix_funcs->pNtUserClipCursor( rect );
}
INT WINAPI NtUserCountClipboardFormats(void)
{
if (!unix_funcs) return 0;
......
......@@ -131,6 +131,7 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code );
ULONG_PTR WINAPI NtUserCallTwoParam( ULONG_PTR arg1, ULONG_PTR arg2, ULONG code );
LONG WINAPI NtUserChangeDisplaySettings( UNICODE_STRING *devname, DEVMODEW *devmode, HWND hwnd,
DWORD flags, void *lparam );
BOOL WINAPI NtUserClipCursor( const RECT *rect );
BOOL WINAPI NtUserCloseDesktop( HDESK handle );
BOOL WINAPI NtUserCloseWindowStation( HWINSTA handle );
INT WINAPI NtUserCountClipboardFormats(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment