Commit db9b7b0f authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winex11: Use TEB to store driver thread data.

parent 3e948645
...@@ -478,8 +478,8 @@ static BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*,X ...@@ -478,8 +478,8 @@ static BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*,X
DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
DWORD timeout, DWORD mask, DWORD flags ) DWORD timeout, DWORD mask, DWORD flags )
{ {
struct x11drv_thread_data *data = x11drv_thread_data();
DWORD ret; DWORD ret;
struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index );
if (!data) if (!data)
{ {
......
...@@ -395,14 +395,10 @@ struct x11drv_thread_data ...@@ -395,14 +395,10 @@ struct x11drv_thread_data
}; };
extern struct x11drv_thread_data *x11drv_init_thread_data(void) DECLSPEC_HIDDEN; extern struct x11drv_thread_data *x11drv_init_thread_data(void) DECLSPEC_HIDDEN;
extern DWORD thread_data_tls_index DECLSPEC_HIDDEN;
static inline struct x11drv_thread_data *x11drv_thread_data(void) static inline struct x11drv_thread_data *x11drv_thread_data(void)
{ {
DWORD err = GetLastError(); /* TlsGetValue always resets last error */ return NtUserGetThreadInfo()->driver_data;
struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index );
SetLastError( err );
return data;
} }
/* retrieve the thread display, or NULL if not created yet */ /* retrieve the thread display, or NULL if not created yet */
......
...@@ -81,7 +81,6 @@ BOOL client_side_with_render = TRUE; ...@@ -81,7 +81,6 @@ BOOL client_side_with_render = TRUE;
BOOL shape_layered_windows = TRUE; BOOL shape_layered_windows = TRUE;
int copy_default_colors = 128; int copy_default_colors = 128;
int alloc_system_colors = 256; int alloc_system_colors = 256;
DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
int xrender_error_base = 0; int xrender_error_base = 0;
HMODULE x11drv_module = 0; HMODULE x11drv_module = 0;
char *process_name = NULL; char *process_name = NULL;
...@@ -650,8 +649,6 @@ static BOOL process_attach(void) ...@@ -650,8 +649,6 @@ static BOOL process_attach(void)
setup_options(); setup_options();
if ((thread_data_tls_index = TlsAlloc()) == TLS_OUT_OF_INDEXES) return FALSE;
/* Open display */ /* Open display */
if (!XInitThreads()) ERR( "XInitThreads failed, trouble ahead\n" ); if (!XInitThreads()) ERR( "XInitThreads failed, trouble ahead\n" );
...@@ -702,7 +699,7 @@ static BOOL process_attach(void) ...@@ -702,7 +699,7 @@ static BOOL process_attach(void)
*/ */
void X11DRV_ThreadDetach(void) void X11DRV_ThreadDetach(void)
{ {
struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index ); struct x11drv_thread_data *data = x11drv_thread_data();
if (data) if (data)
{ {
...@@ -712,7 +709,7 @@ void X11DRV_ThreadDetach(void) ...@@ -712,7 +709,7 @@ void X11DRV_ThreadDetach(void)
XCloseDisplay( data->display ); XCloseDisplay( data->display );
HeapFree( GetProcessHeap(), 0, data ); HeapFree( GetProcessHeap(), 0, data );
/* clear data in case we get re-entered from user32 before the thread is truly dead */ /* clear data in case we get re-entered from user32 before the thread is truly dead */
TlsSetValue( thread_data_tls_index, NULL ); NtUserGetThreadInfo()->driver_data = NULL;
} }
} }
...@@ -773,7 +770,7 @@ struct x11drv_thread_data *x11drv_init_thread_data(void) ...@@ -773,7 +770,7 @@ struct x11drv_thread_data *x11drv_init_thread_data(void)
if (TRACE_ON(synchronous)) XSynchronize( data->display, True ); if (TRACE_ON(synchronous)) XSynchronize( data->display, True );
set_queue_display_fd( data->display ); set_queue_display_fd( data->display );
TlsSetValue( thread_data_tls_index, data ); NtUserGetThreadInfo()->driver_data = data;
if (use_xim) X11DRV_SetupXIM(); if (use_xim) X11DRV_SetupXIM();
......
...@@ -45,6 +45,7 @@ enum ...@@ -45,6 +45,7 @@ enum
/* TEB thread info, not compatible with Windows */ /* TEB thread info, not compatible with Windows */
struct ntuser_thread_info struct ntuser_thread_info
{ {
void *driver_data; /* driver-specific data */
DWORD message_time; /* value for GetMessageTime */ DWORD message_time; /* value for GetMessageTime */
DWORD message_pos; /* value for GetMessagePos */ DWORD message_pos; /* value for GetMessagePos */
ULONG_PTR message_extra; /* value for GetMessageExtraInfo */ ULONG_PTR message_extra; /* value for GetMessageExtraInfo */
......
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