Commit 06a1407c authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Explicitly request creation of the per-thread data where necessary.

parent b258f880
......@@ -317,7 +317,8 @@ static UINT wSeqNo = 0;
static Window thread_selection_wnd(void)
{
Window w = x11drv_thread_data()->selection_wnd;
struct x11drv_thread_data *thread_data = x11drv_init_thread_data();
Window w = thread_data->selection_wnd;
if (!w)
{
......@@ -327,12 +328,12 @@ static Window thread_selection_wnd(void)
ButtonPressMask | ButtonReleaseMask | EnterWindowMask);
wine_tsx11_lock();
w = XCreateWindow(thread_display(), root_window, 0, 0, 1, 1, 0, screen_depth,
w = XCreateWindow(thread_data->display, root_window, 0, 0, 1, 1, 0, screen_depth,
InputOutput, CopyFromParent, CWEventMask, &attr);
wine_tsx11_unlock();
if (w)
x11drv_thread_data()->selection_wnd = w;
thread_data->selection_wnd = w;
else
FIXME("Failed to create window. Fetching selection data will fail.\n");
}
......
......@@ -918,7 +918,7 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
*/
void X11DRV_SetCursor( CURSORICONINFO *lpCursor )
{
struct x11drv_thread_data *data = x11drv_thread_data();
struct x11drv_thread_data *data = x11drv_init_thread_data();
Cursor cursor;
if (lpCursor)
......
......@@ -1487,7 +1487,6 @@ void X11DRV_SetWindowStyle( HWND hwnd, DWORD old_style )
void X11DRV_DestroyWindow( HWND hwnd )
{
struct x11drv_thread_data *thread_data = x11drv_thread_data();
Display *display = thread_data->display;
struct x11drv_win_data *data;
if (!(data = X11DRV_get_win_data( hwnd ))) return;
......@@ -1506,13 +1505,13 @@ void X11DRV_DestroyWindow( HWND hwnd )
wine_tsx11_unlock();
}
destroy_whole_window( display, data, FALSE );
destroy_icon_window( display, data );
destroy_whole_window( thread_data->display, data, FALSE );
destroy_icon_window( thread_data->display, data );
if (data->colormap)
{
wine_tsx11_lock();
XFreeColormap( display, data->colormap );
XFreeColormap( thread_data->display, data->colormap );
wine_tsx11_unlock();
}
......@@ -1520,7 +1519,7 @@ void X11DRV_DestroyWindow( HWND hwnd )
if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap );
if (data->hWMIconMask) DeleteObject( data->hWMIconMask);
wine_tsx11_lock();
XDeleteContext( display, (XID)hwnd, win_data_context );
XDeleteContext( thread_data->display, (XID)hwnd, win_data_context );
wine_tsx11_unlock();
HeapFree( GetProcessHeap(), 0, data );
}
......@@ -1638,9 +1637,12 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
*/
struct x11drv_win_data *X11DRV_get_win_data( HWND hwnd )
{
struct x11drv_thread_data *thread_data = x11drv_thread_data();
char *data;
if (!hwnd || XFindContext( thread_display(), (XID)hwnd, win_data_context, &data )) data = NULL;
if (!thread_data) return NULL;
if (!hwnd) return NULL;
if (XFindContext( thread_data->display, (XID)hwnd, win_data_context, &data )) data = NULL;
return (struct x11drv_win_data *)data;
}
......@@ -1813,6 +1815,7 @@ void X11DRV_SetCapture( HWND hwnd, UINT flags )
{
struct x11drv_thread_data *thread_data = x11drv_thread_data();
if (!thread_data) return;
if (!(flags & (GUI_INMOVESIZE | GUI_INMENUMODE))) return;
if (hwnd)
......@@ -1924,7 +1927,7 @@ void X11DRV_SetWindowPos( HWND hwnd, HWND insert_after, UINT swp_flags,
const RECT *rectWindow, const RECT *rectClient,
const RECT *visible_rect, const RECT *valid_rects )
{
struct x11drv_thread_data *thread_data = x11drv_thread_data();
struct x11drv_thread_data *thread_data = x11drv_init_thread_data();
Display *display = thread_data->display;
struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
DWORD new_style = GetWindowLongW( hwnd, GWL_STYLE );
......
......@@ -490,7 +490,7 @@ void X11DRV_LoadTabletInfo(HWND hwnddefault)
const WCHAR SZ_DEVICE_NAME[] = {'W','i','n','e',' ','T','a','b','l','e','t',' ','D','e','v','i','c','e',0};
const WCHAR SZ_NON_PLUGINPLAY[] = {'n','o','n','-','p','l','u','g','i','n','p','l','a','y',0};
struct x11drv_thread_data *data = x11drv_thread_data();
struct x11drv_thread_data *data = x11drv_init_thread_data();
int num_devices;
int loop;
XDeviceInfo *devices;
......@@ -961,7 +961,7 @@ static void proximity_event( HWND hwnd, XEvent *event )
*/
int X11DRV_AttachEventQueueToTablet(HWND hOwner)
{
struct x11drv_thread_data *data = x11drv_thread_data();
struct x11drv_thread_data *data = x11drv_init_thread_data();
int num_devices;
int loop;
int cur_loop;
......
......@@ -77,6 +77,8 @@ static LRESULT WINAPI GrabWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
TRACE("hwnd=%p, grab=%ld\n", hWnd, wParam);
if (!data) return 0;
if (wParam)
{
/* find the X11 window that ddraw uses */
......
......@@ -522,12 +522,10 @@ extern DWORD thread_data_tls_index;
static inline struct x11drv_thread_data *x11drv_thread_data(void)
{
struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index );
if (!data) data = x11drv_init_thread_data();
return data;
return TlsGetValue( thread_data_tls_index );
}
static inline Display *thread_display(void) { return x11drv_thread_data()->display; }
static inline Display *thread_display(void) { return x11drv_init_thread_data()->display; }
static inline size_t get_property_size( int format, unsigned long count )
{
......
......@@ -616,7 +616,9 @@ static void set_queue_display_fd( Display *display )
*/
struct x11drv_thread_data *x11drv_init_thread_data(void)
{
struct x11drv_thread_data *data;
struct x11drv_thread_data *data = x11drv_thread_data();
if (data) return data;
if (!(data = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data) )))
{
......
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