Rémi Bernon : user32: Introduce rawinput_thread_data helper.

Alexandre Julliard julliard at winehq.org
Tue Jun 30 14:55:07 CDT 2020


Module: wine
Branch: master
Commit: b269354f456b6abde1d01d304f158c0fd924c181
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b269354f456b6abde1d01d304f158c0fd924c181

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Thu Jun 25 19:08:42 2020 +0200

user32: Introduce rawinput_thread_data helper.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 89ffa07f70..c5c7db667c 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 56efc09179..1ec6c7bd23 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 25bbeba6f0..d7f4741ebe 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;




More information about the wine-cvs mailing list