Jacek Caban : win32u: Move GetCursorPos implementation from user.
Alexandre Julliard
julliard at winehq.org
Mon Feb 14 15:41:31 CST 2022
Module: wine
Branch: master
Commit: b5b9126c7364adf551ab440548d234238151571c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=b5b9126c7364adf551ab440548d234238151571c
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Feb 14 14:08:27 2022 +0100
win32u: Move GetCursorPos implementation from user.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/driver.c | 13 +------------
dlls/user32/input.c | 28 +---------------------------
dlls/win32u/driver.c | 6 ++++++
dlls/win32u/input.c | 32 ++++++++++++++++++++++++++++++++
dlls/win32u/sysparams.c | 2 ++
dlls/win32u/win32u_private.h | 3 +++
include/ntuser.h | 1 +
7 files changed, 46 insertions(+), 39 deletions(-)
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
index 247093bfc17..6dbc07d318a 100644
--- a/dlls/user32/driver.c
+++ b/dlls/user32/driver.c
@@ -136,11 +136,6 @@ static void CDECL nulldrv_SetCursor( HCURSOR cursor )
{
}
-static BOOL CDECL nulldrv_GetCursorPos( LPPOINT pt )
-{
- return TRUE;
-}
-
static BOOL CDECL nulldrv_SetCursorPos( INT x, INT y )
{
return TRUE;
@@ -298,11 +293,6 @@ static void CDECL loaderdrv_SetCursor( HCURSOR cursor )
load_driver()->pSetCursor( cursor );
}
-static BOOL CDECL loaderdrv_GetCursorPos( LPPOINT pt )
-{
- return load_driver()->pGetCursorPos( pt );
-}
-
static BOOL CDECL loaderdrv_SetCursorPos( INT x, INT y )
{
return load_driver()->pSetCursorPos( x, y );
@@ -371,7 +361,7 @@ static struct user_driver_funcs lazy_load_driver =
/* cursor/icon functions */
nulldrv_DestroyCursorIcon,
loaderdrv_SetCursor,
- loaderdrv_GetCursorPos,
+ NULL,
loaderdrv_SetCursorPos,
loaderdrv_ClipCursor,
/* clipboard functions */
@@ -431,7 +421,6 @@ void CDECL __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT v
SET_USER_FUNC(UnregisterHotKey);
SET_USER_FUNC(DestroyCursorIcon);
SET_USER_FUNC(SetCursor);
- SET_USER_FUNC(GetCursorPos);
SET_USER_FUNC(SetCursorPos);
SET_USER_FUNC(ClipCursor);
SET_USER_FUNC(UpdateClipboard);
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index 210cc368527..b3329eb3c07 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -305,33 +305,7 @@ void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
*/
BOOL WINAPI DECLSPEC_HOTPATCH GetCursorPos( POINT *pt )
{
- BOOL ret;
- DWORD last_change;
- UINT dpi;
-
- if (!pt) return FALSE;
-
- SERVER_START_REQ( set_cursor )
- {
- if ((ret = !wine_server_call( req )))
- {
- pt->x = reply->new_x;
- pt->y = reply->new_y;
- last_change = reply->last_change;
- }
- }
- SERVER_END_REQ;
-
- /* query new position from graphics driver if we haven't updated recently */
- if (ret && GetTickCount() - last_change > 100) ret = USER_Driver->pGetCursorPos( pt );
- if (ret && (dpi = get_thread_dpi()))
- {
- DPI_AWARENESS_CONTEXT context;
- context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
- *pt = map_dpi_point( *pt, get_monitor_dpi( MonitorFromPoint( *pt, MONITOR_DEFAULTTOPRIMARY )), dpi );
- SetThreadDpiAwarenessContext( context );
- }
- return ret;
+ return NtUserCallOneParam( (UINT_PTR)pt, NtUserGetCursorPos );
}
diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c
index 24815922bbb..ea8d32d62f9 100644
--- a/dlls/win32u/driver.c
+++ b/dlls/win32u/driver.c
@@ -1010,6 +1010,11 @@ static void CDECL loaderdrv_SetCursor( HCURSOR cursor )
load_driver()->pSetCursor( cursor );
}
+static BOOL CDECL loaderdrv_GetCursorPos( POINT *pt )
+{
+ return load_driver()->pGetCursorPos( pt );
+}
+
static BOOL CDECL loaderdrv_SetCursorPos( INT x, INT y )
{
return load_driver()->pSetCursorPos( x, y );
@@ -1049,6 +1054,7 @@ static const struct user_driver_funcs lazy_load_driver =
.pVkKeyScanEx = loaderdrv_VkKeyScanEx,
/* cursor/icon functions */
.pSetCursor = loaderdrv_SetCursor,
+ .pGetCursorPos = loaderdrv_GetCursorPos,
.pSetCursorPos = loaderdrv_SetCursorPos,
.pClipCursor = loaderdrv_ClipCursor,
/* clipboard functions */
diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c
index 493efcd605b..328546c9f77 100644
--- a/dlls/win32u/input.c
+++ b/dlls/win32u/input.c
@@ -96,6 +96,38 @@ BOOL WINAPI NtUserSetCursorPos( INT x, INT y )
return ret;
}
+/***********************************************************************
+ * get_cursor_pos
+ */
+BOOL get_cursor_pos( POINT *pt )
+{
+ BOOL ret;
+ DWORD last_change;
+ UINT dpi;
+
+ if (!pt) return FALSE;
+
+ SERVER_START_REQ( set_cursor )
+ {
+ if ((ret = !wine_server_call( req )))
+ {
+ pt->x = reply->new_x;
+ pt->y = reply->new_y;
+ last_change = reply->last_change;
+ }
+ }
+ SERVER_END_REQ;
+
+ /* query new position from graphics driver if we haven't updated recently */
+ if (ret && NtGetTickCount() - last_change > 100) ret = user_driver->pGetCursorPos( pt );
+ if (ret && (dpi = get_thread_dpi()))
+ {
+ HMONITOR monitor = monitor_from_point( *pt, MONITOR_DEFAULTTOPRIMARY, 0 );
+ *pt = map_dpi_point( *pt, get_monitor_dpi( monitor ), dpi );
+ }
+ return ret;
+}
+
/***********************************************************************
* get_locale_kbd_layout
*/
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c
index 603c16acd41..ae9b4f73cfb 100644
--- a/dlls/win32u/sysparams.c
+++ b/dlls/win32u/sysparams.c
@@ -4492,6 +4492,8 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code )
{
case NtUserGetClipCursor:
return get_clip_cursor( (RECT *)arg );
+ case NtUserGetCursorPos:
+ return get_cursor_pos( (POINT *)arg );
case NtUserGetSysColor:
return get_sys_color( arg );
case NtUserRealizePalette:
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index 0a5f6ce10b8..cd50b48feec 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -245,6 +245,9 @@ struct unix_funcs
/* cursoricon.c */
extern BOOL get_clip_cursor( RECT *rect ) DECLSPEC_HIDDEN;
+/* input.c */
+extern BOOL get_cursor_pos( POINT *pt ) DECLSPEC_HIDDEN;
+
/* sysparams.c */
extern RECT get_display_rect( const WCHAR *display ) DECLSPEC_HIDDEN;
extern UINT get_monitor_dpi( HMONITOR monitor ) DECLSPEC_HIDDEN;
diff --git a/include/ntuser.h b/include/ntuser.h
index 92173300a35..a115f7c9259 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -53,6 +53,7 @@ struct enum_display_monitor_params
enum
{
NtUserGetClipCursor,
+ NtUserGetCursorPos,
NtUserGetSysColor,
NtUserGetSysColorBrush,
NtUserGetSysColorPen,
More information about the wine-cvs
mailing list