From b269354f456b6abde1d01d304f158c0fd924c181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Thu, 25 Jun 2020 19:08:42 +0200 Subject: [PATCH] user32: Introduce rawinput_thread_data helper. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/user32/message.c | 10 +--------- dlls/user32/rawinput.c | 9 +++++++++ dlls/user32/user_private.h | 7 ++++++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dlls/user32/message.c b/dlls/user32/message.c index 89ffa07f700..c5c7db667cf 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -2286,15 +2286,7 @@ static void accept_hardware_message( UINT hw_id, BOOL remove ) static BOOL process_rawinput_message( MSG *msg, const struct hardware_msg_data *msg_data ) { - struct user_thread_info *thread_info = get_user_thread_info(); - RAWINPUT *rawinput = thread_info->rawinput; - - if (!rawinput) - { - thread_info->rawinput = HeapAlloc( GetProcessHeap(), 0, sizeof(*rawinput) ); - if (!(rawinput = thread_info->rawinput)) return FALSE; - } - + RAWINPUT *rawinput = rawinput_thread_data(); if (!rawinput_from_hardware_message(rawinput, msg_data)) return FALSE; diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 56efc09179d..1ec6c7bd236 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -223,6 +223,15 @@ static void find_devices(void) } +RAWINPUT *rawinput_thread_data(void) +{ + struct user_thread_info *thread_info = get_user_thread_info(); + RAWINPUT *rawinput = thread_info->rawinput; + if (!rawinput) rawinput = thread_info->rawinput = HeapAlloc( GetProcessHeap(), 0, RAWINPUT_BUFFER_SIZE ); + return rawinput; +} + + BOOL rawinput_from_hardware_message(RAWINPUT *rawinput, const struct hardware_msg_data *msg_data) { rawinput->header.dwType = msg_data->rawinput.type; diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 25bbeba6f0c..d7f4741ebe6 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -169,6 +169,10 @@ struct wm_char_mapping_data MSG get_msg; }; +/* on windows the buffer capacity is quite large as well, enough to */ +/* hold up to 10s of 1kHz mouse rawinput events */ +#define RAWINPUT_BUFFER_SIZE (512*1024) + /* this is the structure stored in TEB->Win32ClientInfo */ /* no attempt is made to keep the layout compatible with the Windows one */ struct user_thread_info @@ -192,7 +196,7 @@ struct user_thread_info struct user_key_state_info *key_state; /* Cache of global key state */ HWND top_window; /* Desktop window */ HWND msg_window; /* HWND_MESSAGE parent window */ - RAWINPUT *rawinput; + RAWINPUT *rawinput; /* Rawinput buffer */ }; C_ASSERT( sizeof(struct user_thread_info) <= sizeof(((TEB *)0)->Win32ClientInfo) ); @@ -232,6 +236,7 @@ struct tagWND; struct hardware_msg_data; extern BOOL rawinput_from_hardware_message(RAWINPUT *rawinput, const struct hardware_msg_data *msg_data); +extern RAWINPUT *rawinput_thread_data(void); extern void CLIPBOARD_ReleaseOwner( HWND hwnd ) DECLSPEC_HIDDEN; extern BOOL FOCUS_MouseActivate( HWND hwnd ) DECLSPEC_HIDDEN;