[PATCH 2/6] user32: Toggle the caret based on the timer ID in DispatchMessage().
Zebediah Figura
zfigura at codeweavers.com
Thu Apr 14 20:14:11 CDT 2022
Avoid passing a callback to NtUserSetSystemTimer(); it does not support one.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
dlls/user32/caret.c | 18 +++++++-----------
dlls/user32/message.c | 24 ++++++++++++++++++++++++
dlls/user32/user_private.h | 6 ++++++
3 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/dlls/user32/caret.c b/dlls/user32/caret.c
index 8bf4962b708..b51bfd926da 100644
--- a/dlls/user32/caret.c
+++ b/dlls/user32/caret.c
@@ -27,6 +27,7 @@
#include "winbase.h"
#include "wingdi.h"
#include "ntuser.h"
+#include "user_private.h"
#include "wine/server.h"
#include "wine/debug.h"
@@ -40,8 +41,6 @@ typedef struct
static CARET Caret = { 0, 500 };
-#define TIMERID 0xffff /* system timer id for the caret */
-
/*****************************************************************
* CARET_DisplayCaret
@@ -67,10 +66,7 @@ static void CARET_DisplayCaret( HWND hwnd, const RECT *r )
}
-/*****************************************************************
- * CARET_Callback
- */
-static void CALLBACK CARET_Callback( HWND hwnd, UINT msg, UINT_PTR id, DWORD ctime)
+void toggle_caret( HWND hwnd )
{
BOOL ret;
RECT r;
@@ -183,7 +179,7 @@ BOOL WINAPI CreateCaret( HWND hwnd, HBITMAP bitmap, INT width, INT height )
if (prev && !hidden) /* hide the previous one */
{
/* FIXME: won't work if prev belongs to a different process */
- KillSystemTimer( prev, TIMERID );
+ KillSystemTimer( prev, SYSTEM_TIMER_CARET );
if (old_state) CARET_DisplayCaret( prev, &r );
}
@@ -226,7 +222,7 @@ BOOL WINAPI DestroyCaret(void)
if (ret && prev && !hidden)
{
/* FIXME: won't work if prev belongs to a different process */
- KillSystemTimer( prev, TIMERID );
+ KillSystemTimer( prev, SYSTEM_TIMER_CARET );
if (old_state) CARET_DisplayCaret( prev, &r );
}
if (Caret.hBmp) DeleteObject( Caret.hBmp );
@@ -274,7 +270,7 @@ BOOL WINAPI SetCaretPos( INT x, INT y )
r.left = x;
r.top = y;
CARET_DisplayCaret( hwnd, &r );
- NtUserSetSystemTimer( hwnd, TIMERID, Caret.timeout, CARET_Callback );
+ NtUserSetSystemTimer( hwnd, SYSTEM_TIMER_CARET, Caret.timeout, NULL );
}
return ret;
}
@@ -314,7 +310,7 @@ BOOL WINAPI HideCaret( HWND hwnd )
if (ret && !hidden)
{
if (old_state) CARET_DisplayCaret( hwnd, &r );
- KillSystemTimer( hwnd, TIMERID );
+ KillSystemTimer( hwnd, SYSTEM_TIMER_CARET );
}
return ret;
}
@@ -352,7 +348,7 @@ BOOL WINAPI ShowCaret( HWND hwnd )
if (ret && (hidden == 1)) /* hidden was 1 so it's now 0 */
{
CARET_DisplayCaret( hwnd, &r );
- NtUserSetSystemTimer( hwnd, TIMERID, Caret.timeout, CARET_Callback );
+ NtUserSetSystemTimer( hwnd, SYSTEM_TIMER_CARET, Caret.timeout, NULL );
}
return ret;
}
diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index 51f183fdbc0..68f00b325c9 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -895,6 +895,22 @@ BOOL WINAPI TranslateMessage( const MSG *msg )
}
+static BOOL dispatch_systimer_message( const MSG *msg )
+{
+ if (msg->message != WM_SYSTIMER)
+ return FALSE;
+
+ switch (msg->wParam)
+ {
+ case SYSTEM_TIMER_CARET:
+ toggle_caret( msg->hwnd );
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
/***********************************************************************
* DispatchMessageA (USER32.@)
*
@@ -922,6 +938,10 @@ LRESULT WINAPI DECLSPEC_HOTPATCH DispatchMessageA( const MSG* msg )
return retval;
}
}
+
+ if (dispatch_systimer_message( msg ))
+ return 0;
+
return NtUserDispatchMessageA( msg );
}
@@ -970,6 +990,10 @@ LRESULT WINAPI DECLSPEC_HOTPATCH DispatchMessageW( const MSG* msg )
return retval;
}
}
+
+ if (dispatch_systimer_message( msg ))
+ return 0;
+
return NtUserDispatchMessage( msg );
}
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index 52e57a5e6f1..bb86ed6ffca 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -38,6 +38,11 @@
#define WINE_MOUSE_HANDLE ((HANDLE)1)
#define WINE_KEYBOARD_HANDLE ((HANDLE)2)
+enum system_timer_id
+{
+ SYSTEM_TIMER_CARET = 0xffff,
+};
+
struct received_message_info;
/* data to store state for A/W mappings of WM_CHAR */
@@ -99,6 +104,7 @@ extern HBRUSH SYSCOLOR_Get55AABrush(void) DECLSPEC_HIDDEN;
extern void SYSPARAMS_Init(void) DECLSPEC_HIDDEN;
extern void USER_CheckNotLock(void) DECLSPEC_HIDDEN;
extern BOOL USER_IsExitingThread( DWORD tid ) DECLSPEC_HIDDEN;
+extern void toggle_caret( HWND hwnd ) DECLSPEC_HIDDEN;
typedef LRESULT (*winproc_callback_t)( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
LRESULT *result, void *arg );
--
2.35.1
More information about the wine-devel
mailing list