From 06a1407c13aabd577ef2b1a8a4387aa92b5ddd58 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 26 Jun 2008 15:08:08 +0200 Subject: [PATCH] winex11: Explicitly request creation of the per-thread data where necessary. --- dlls/winex11.drv/clipboard.c | 7 ++++--- dlls/winex11.drv/mouse.c | 2 +- dlls/winex11.drv/window.c | 17 ++++++++++------- dlls/winex11.drv/wintab.c | 4 ++-- dlls/winex11.drv/x11ddraw.c | 2 ++ dlls/winex11.drv/x11drv.h | 6 ++---- dlls/winex11.drv/x11drv_main.c | 4 +++- 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index af5ff9d0534..36755273ebb 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -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"); } diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 354f74ce849..0d4aa5f9acb 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -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) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 26f037a5902..22de5caee53 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -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 ); diff --git a/dlls/winex11.drv/wintab.c b/dlls/winex11.drv/wintab.c index ed04ad56a5d..e73f000d9a9 100644 --- a/dlls/winex11.drv/wintab.c +++ b/dlls/winex11.drv/wintab.c @@ -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; diff --git a/dlls/winex11.drv/x11ddraw.c b/dlls/winex11.drv/x11ddraw.c index e0bda0a11fa..e618618d5eb 100644 --- a/dlls/winex11.drv/x11ddraw.c +++ b/dlls/winex11.drv/x11ddraw.c @@ -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 */ diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 3bfe1184968..cfcfba4cd4d 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -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 ) { diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 4ca1bb64d22..75b9bd9f23e 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -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) ))) { -- 2.11.4.GIT