win32u: Move raw input thread data allocation from user32.

This commit is contained in:
Zebediah Figura 2022-05-15 15:58:34 -05:00 committed by Alexandre Julliard
parent e2d3fc7c07
commit 7c418f14f3
6 changed files with 13 additions and 18 deletions

View file

@ -351,17 +351,6 @@ BOOL rawinput_device_get_usages(HANDLE handle, USAGE *usage_page, USAGE *usage)
}
struct rawinput_thread_data * WINAPI rawinput_thread_data(void)
{
struct user_thread_info *thread_info = get_user_thread_info();
struct rawinput_thread_data *data = thread_info->rawinput;
if (data) return data;
data = thread_info->rawinput = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
RAWINPUT_BUFFER_SIZE + sizeof(struct user_thread_info) );
return data;
}
/***********************************************************************
* GetRawInputDeviceList (USER32.@)
*/

View file

@ -169,7 +169,6 @@ static const struct user_callbacks user_funcs =
register_imm,
unregister_imm,
try_finally,
rawinput_thread_data,
};
static NTSTATUS WINAPI User32CopyImage( const struct copy_image_params *params, ULONG size )
@ -271,7 +270,6 @@ static void thread_detach(void)
NtUserCallNoParam( NtUserThreadDetach );
HeapFree( GetProcessHeap(), 0, thread_info->wmchar_data );
HeapFree( GetProcessHeap(), 0, thread_info->rawinput );
exiting_thread_id = 0;
}

View file

@ -62,7 +62,6 @@ struct tagWND;
struct hardware_msg_data;
extern BOOL rawinput_device_get_usages(HANDLE handle, USAGE *usage_page, USAGE *usage);
extern struct rawinput_thread_data * WINAPI rawinput_thread_data(void);
extern void CDECL rawinput_update_device_list(void);
extern BOOL post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid,

View file

@ -50,7 +50,6 @@ struct user_callbacks
void (WINAPI *unregister_imm)( HWND hwnd );
NTSTATUS (CDECL *try_finally)( NTSTATUS (CDECL *func)( void *), void *arg,
void (CALLBACK *finally_func)( BOOL ));
struct rawinput_thread_data *(WINAPI *get_rawinput_thread_data)(void);
};
#define WM_SYSTIMER 0x0118

View file

@ -58,6 +58,15 @@ typedef struct
} RAWINPUT64;
#endif
static struct rawinput_thread_data *get_rawinput_thread_data(void)
{
struct user_thread_info *thread_info = get_user_thread_info();
struct rawinput_thread_data *data = thread_info->rawinput;
if (data) return data;
data = thread_info->rawinput = calloc( 1, RAWINPUT_BUFFER_SIZE + sizeof(struct user_thread_info) );
return data;
}
static bool rawinput_from_hardware_message( RAWINPUT *rawinput, const struct hardware_msg_data *msg_data )
{
SIZE_T size;
@ -223,7 +232,7 @@ UINT WINAPI NtUserGetRawInputBuffer( RAWINPUT *data, UINT *data_size, UINT heade
return 0;
}
if (!user_callbacks || !(thread_data = user_callbacks->get_rawinput_thread_data())) return ~0u;
if (!(thread_data = get_rawinput_thread_data())) return ~0u;
rawinput = thread_data->buffer;
/* first RAWINPUT block in the buffer is used for WM_INPUT message data */
@ -286,7 +295,7 @@ UINT WINAPI NtUserGetRawInputData( HRAWINPUT rawinput, UINT command, void *data,
TRACE( "rawinput %p, command %#x, data %p, data_size %p, header_size %u.\n",
rawinput, command, data, data_size, header_size );
if (!user_callbacks || !(thread_data = user_callbacks->get_rawinput_thread_data()))
if (!(thread_data = get_rawinput_thread_data()))
{
SetLastError( ERROR_OUTOFMEMORY );
return ~0u;
@ -339,7 +348,7 @@ BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_d
{
struct rawinput_thread_data *thread_data;
if (!user_callbacks || !(thread_data = user_callbacks->get_rawinput_thread_data()))
if (!(thread_data = get_rawinput_thread_data()))
return FALSE;
if (msg->message == WM_INPUT_DEVICE_CHANGE)

View file

@ -4689,6 +4689,7 @@ static void thread_detach(void)
free( thread_info->key_state );
thread_info->key_state = 0;
free( thread_info->rawinput );
destroy_thread_windows();
NtClose( thread_info->server_queue );