Skip to content

Commit

Permalink
win32u: Move cursor clipping functions to input.c.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbernon authored and julliard committed May 31, 2023
1 parent c22c10d commit 1cea2be
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 76 deletions.
75 changes: 0 additions & 75 deletions dlls/win32u/cursoricon.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,81 +150,6 @@ HCURSOR WINAPI NtUserGetCursor(void)
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 )
{
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;
}

BOOL get_clip_cursor( RECT *rect )
{
UINT dpi;
BOOL ret;

if (!rect) return FALSE;

SERVER_START_REQ( set_cursor )
{
req->flags = 0;
if ((ret = !wine_server_call( req )))
{
rect->left = reply->new_clip.left;
rect->top = reply->new_clip.top;
rect->right = reply->new_clip.right;
rect->bottom = reply->new_clip.bottom;
}
}
SERVER_END_REQ;

if (ret && (dpi = get_thread_dpi()))
{
HMONITOR monitor = monitor_from_rect( rect, MONITOR_DEFAULTTOPRIMARY, 0 );
*rect = map_dpi_rect( *rect, get_monitor_dpi( monitor ), dpi );
}
return ret;
}

HICON alloc_cursoricon_handle( BOOL is_icon )
{
struct cursoricon_object *obj;
Expand Down
75 changes: 75 additions & 0 deletions dlls/win32u/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -2468,3 +2468,78 @@ BOOL WINAPI NtUserGetPointerInfoList( UINT32 id, POINTER_INPUT_TYPE type, UINT_P
RtlSetLastWin32Error( ERROR_CALL_NOT_IMPLEMENTED );
return FALSE;
}

BOOL get_clip_cursor( RECT *rect )
{
UINT dpi;
BOOL ret;

if (!rect) return FALSE;

SERVER_START_REQ( set_cursor )
{
req->flags = 0;
if ((ret = !wine_server_call( req )))
{
rect->left = reply->new_clip.left;
rect->top = reply->new_clip.top;
rect->right = reply->new_clip.right;
rect->bottom = reply->new_clip.bottom;
}
}
SERVER_END_REQ;

if (ret && (dpi = get_thread_dpi()))
{
HMONITOR monitor = monitor_from_rect( rect, MONITOR_DEFAULTTOPRIMARY, 0 );
*rect = map_dpi_rect( *rect, get_monitor_dpi( monitor ), dpi );
}
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 )
{
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;
}
2 changes: 1 addition & 1 deletion dlls/win32u/win32u_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ extern void release_clipboard_owner( HWND hwnd ) DECLSPEC_HIDDEN;

/* cursoricon.c */
extern HICON alloc_cursoricon_handle( BOOL is_icon ) DECLSPEC_HIDDEN;
extern BOOL get_clip_cursor( RECT *rect ) DECLSPEC_HIDDEN;
extern ULONG_PTR get_icon_param( HICON handle ) DECLSPEC_HIDDEN;
extern ULONG_PTR set_icon_param( HICON handle, ULONG_PTR param ) DECLSPEC_HIDDEN;

Expand Down Expand Up @@ -101,6 +100,7 @@ extern BOOL set_caret_pos( int x, int y ) DECLSPEC_HIDDEN;
extern BOOL set_foreground_window( HWND hwnd, BOOL mouse ) DECLSPEC_HIDDEN;
extern void toggle_caret( HWND hwnd ) DECLSPEC_HIDDEN;
extern void update_mouse_tracking_info( HWND hwnd ) DECLSPEC_HIDDEN;
extern BOOL get_clip_cursor( RECT *rect ) DECLSPEC_HIDDEN;

/* menu.c */
extern HMENU create_menu( BOOL is_popup ) DECLSPEC_HIDDEN;
Expand Down

0 comments on commit 1cea2be

Please sign in to comment.