[PATCH v3 2/6] user32: Toggle the caret based on the timer ID in DispatchMessage().
Zebediah Figura
zfigura at codeweavers.com
Wed Apr 20 15:26:45 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/user_main.c | 1 +
dlls/user32/user_private.h | 1 +
dlls/win32u/message.c | 11 +++++++++++
dlls/win32u/ntuser_private.h | 6 ++++++
5 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/dlls/user32/caret.c b/dlls/user32/caret.c
index 8bf4962b708..708f4e39f97 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 CDECL 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/user_main.c b/dlls/user32/user_main.c
index c477d0325d3..80d5e62b2b2 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -178,6 +178,7 @@ static const struct user_callbacks user_funcs =
register_builtin_classes,
MENU_SetMenu,
SCROLL_SetStandardScrollPainted,
+ toggle_caret,
unpack_dde_message,
register_imm,
unregister_imm,
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index 52e57a5e6f1..96c47a71753 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -99,6 +99,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 CDECL toggle_caret( HWND hwnd ) DECLSPEC_HIDDEN;
typedef LRESULT (*winproc_callback_t)( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
LRESULT *result, void *arg );
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c
index 400cc242156..7b3ad1d1f73 100644
--- a/dlls/win32u/message.c
+++ b/dlls/win32u/message.c
@@ -2469,6 +2469,17 @@ LRESULT dispatch_message( const MSG *msg, BOOL ansi )
__ENDTRY
return retval;
}
+ if (msg->message == WM_SYSTIMER)
+ {
+ switch (msg->wParam)
+ {
+ case SYSTEM_TIMER_CARET:
+ if (!user_callbacks) break;
+ user_callbacks->toggle_caret( msg->hwnd );
+ return 0;
+ }
+ }
+
if (!msg->hwnd) return 0;
spy_enter_message( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message, msg->wParam, msg->lParam );
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h
index 801bc445b36..044fb835dec 100644
--- a/dlls/win32u/ntuser_private.h
+++ b/dlls/win32u/ntuser_private.h
@@ -52,6 +52,7 @@ struct user_callbacks
void (CDECL *register_builtin_classes)(void);
BOOL (CDECL *set_menu)( HWND hwnd, HMENU menu );
void (WINAPI *set_standard_scroll_painted)( HWND hwnd, INT bar, BOOL visible );
+ void (CDECL *toggle_caret)( HWND hwnd );
BOOL (CDECL *unpack_dde_message)( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
void **buffer, size_t size );
BOOL (WINAPI *register_imm)( HWND hwnd );
@@ -61,6 +62,11 @@ struct user_callbacks
#define WM_SYSTIMER 0x0118
#define WM_POPUPSYSTEMMENU 0x0313
+enum system_timer_id
+{
+ SYSTEM_TIMER_CARET = 0xffff,
+};
+
struct user_object
{
HANDLE handle;
--
2.35.1
More information about the wine-devel
mailing list