Commit 7c418f14 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

win32u: Move raw input thread data allocation from user32.

parent e2d3fc7c
...@@ -351,17 +351,6 @@ BOOL rawinput_device_get_usages(HANDLE handle, USAGE *usage_page, USAGE *usage) ...@@ -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.@) * GetRawInputDeviceList (USER32.@)
*/ */
......
...@@ -169,7 +169,6 @@ static const struct user_callbacks user_funcs = ...@@ -169,7 +169,6 @@ static const struct user_callbacks user_funcs =
register_imm, register_imm,
unregister_imm, unregister_imm,
try_finally, try_finally,
rawinput_thread_data,
}; };
static NTSTATUS WINAPI User32CopyImage( const struct copy_image_params *params, ULONG size ) static NTSTATUS WINAPI User32CopyImage( const struct copy_image_params *params, ULONG size )
...@@ -271,7 +270,6 @@ static void thread_detach(void) ...@@ -271,7 +270,6 @@ static void thread_detach(void)
NtUserCallNoParam( NtUserThreadDetach ); NtUserCallNoParam( NtUserThreadDetach );
HeapFree( GetProcessHeap(), 0, thread_info->wmchar_data ); HeapFree( GetProcessHeap(), 0, thread_info->wmchar_data );
HeapFree( GetProcessHeap(), 0, thread_info->rawinput );
exiting_thread_id = 0; exiting_thread_id = 0;
} }
......
...@@ -62,7 +62,6 @@ struct tagWND; ...@@ -62,7 +62,6 @@ struct tagWND;
struct hardware_msg_data; struct hardware_msg_data;
extern BOOL rawinput_device_get_usages(HANDLE handle, USAGE *usage_page, USAGE *usage); 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 void CDECL rawinput_update_device_list(void);
extern BOOL post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid, extern BOOL post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid,
......
...@@ -50,7 +50,6 @@ struct user_callbacks ...@@ -50,7 +50,6 @@ struct user_callbacks
void (WINAPI *unregister_imm)( HWND hwnd ); void (WINAPI *unregister_imm)( HWND hwnd );
NTSTATUS (CDECL *try_finally)( NTSTATUS (CDECL *func)( void *), void *arg, NTSTATUS (CDECL *try_finally)( NTSTATUS (CDECL *func)( void *), void *arg,
void (CALLBACK *finally_func)( BOOL )); void (CALLBACK *finally_func)( BOOL ));
struct rawinput_thread_data *(WINAPI *get_rawinput_thread_data)(void);
}; };
#define WM_SYSTIMER 0x0118 #define WM_SYSTIMER 0x0118
......
...@@ -58,6 +58,15 @@ typedef struct ...@@ -58,6 +58,15 @@ typedef struct
} RAWINPUT64; } RAWINPUT64;
#endif #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 ) static bool rawinput_from_hardware_message( RAWINPUT *rawinput, const struct hardware_msg_data *msg_data )
{ {
SIZE_T size; SIZE_T size;
...@@ -223,7 +232,7 @@ UINT WINAPI NtUserGetRawInputBuffer( RAWINPUT *data, UINT *data_size, UINT heade ...@@ -223,7 +232,7 @@ UINT WINAPI NtUserGetRawInputBuffer( RAWINPUT *data, UINT *data_size, UINT heade
return 0; 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; rawinput = thread_data->buffer;
/* first RAWINPUT block in the buffer is used for WM_INPUT message data */ /* 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, ...@@ -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", TRACE( "rawinput %p, command %#x, data %p, data_size %p, header_size %u.\n",
rawinput, command, data, data_size, header_size ); 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 ); SetLastError( ERROR_OUTOFMEMORY );
return ~0u; return ~0u;
...@@ -339,7 +348,7 @@ BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_d ...@@ -339,7 +348,7 @@ BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_d
{ {
struct rawinput_thread_data *thread_data; 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; return FALSE;
if (msg->message == WM_INPUT_DEVICE_CHANGE) if (msg->message == WM_INPUT_DEVICE_CHANGE)
......
...@@ -4689,6 +4689,7 @@ static void thread_detach(void) ...@@ -4689,6 +4689,7 @@ static void thread_detach(void)
free( thread_info->key_state ); free( thread_info->key_state );
thread_info->key_state = 0; thread_info->key_state = 0;
free( thread_info->rawinput );
destroy_thread_windows(); destroy_thread_windows();
NtClose( thread_info->server_queue ); NtClose( thread_info->server_queue );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment