Jacek Caban : winex11: Use TEB to store driver thread data.
Alexandre Julliard
julliard at winehq.org
Tue Apr 19 16:20:13 CDT 2022
Module: wine
Branch: master
Commit: db9b7b0f511197255d0cbe81605a42e34bf630d6
URL: https://source.winehq.org/git/wine.git/?a=commit;h=db9b7b0f511197255d0cbe81605a42e34bf630d6
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Apr 19 15:31:41 2022 +0200
winex11: Use TEB to store driver thread data.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winex11.drv/event.c | 2 +-
dlls/winex11.drv/x11drv.h | 6 +-----
dlls/winex11.drv/x11drv_main.c | 9 +++------
include/ntuser.h | 1 +
4 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index 7ac31e326c6..900f24c4002 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -478,8 +478,8 @@ static BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*,X
DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
DWORD timeout, DWORD mask, DWORD flags )
{
+ struct x11drv_thread_data *data = x11drv_thread_data();
DWORD ret;
- struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index );
if (!data)
{
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 086e66b2366..23886936dd4 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -395,14 +395,10 @@ struct x11drv_thread_data
};
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)
{
- DWORD err = GetLastError(); /* TlsGetValue always resets last error */
- struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index );
- SetLastError( err );
- return data;
+ return NtUserGetThreadInfo()->driver_data;
}
/* retrieve the thread display, or NULL if not created yet */
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index 203237f24aa..14ee13dc676 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -81,7 +81,6 @@ BOOL client_side_with_render = TRUE;
BOOL shape_layered_windows = TRUE;
int copy_default_colors = 128;
int alloc_system_colors = 256;
-DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
int xrender_error_base = 0;
HMODULE x11drv_module = 0;
char *process_name = NULL;
@@ -650,8 +649,6 @@ static BOOL process_attach(void)
setup_options();
- if ((thread_data_tls_index = TlsAlloc()) == TLS_OUT_OF_INDEXES) return FALSE;
-
/* Open display */
if (!XInitThreads()) ERR( "XInitThreads failed, trouble ahead\n" );
@@ -702,7 +699,7 @@ static BOOL process_attach(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)
{
@@ -712,7 +709,7 @@ void X11DRV_ThreadDetach(void)
XCloseDisplay( data->display );
HeapFree( GetProcessHeap(), 0, data );
/* 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)
if (TRACE_ON(synchronous)) XSynchronize( data->display, True );
set_queue_display_fd( data->display );
- TlsSetValue( thread_data_tls_index, data );
+ NtUserGetThreadInfo()->driver_data = data;
if (use_xim) X11DRV_SetupXIM();
diff --git a/include/ntuser.h b/include/ntuser.h
index e391940d63e..8eafd78beef 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -45,6 +45,7 @@ enum
/* TEB thread info, not compatible with Windows */
struct ntuser_thread_info
{
+ void *driver_data; /* driver-specific data */
DWORD message_time; /* value for GetMessageTime */
DWORD message_pos; /* value for GetMessagePos */
ULONG_PTR message_extra; /* value for GetMessageExtraInfo */
More information about the wine-cvs
mailing list