From c970621d90372d14f982b41811efa4e4fe9e5ec8 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 15 Aug 2012 15:51:06 +0200 Subject: [PATCH] winex11: Create contexts at initialization time to avoid the need for locks. --- dlls/winex11.drv/mouse.c | 12 +++++------- dlls/winex11.drv/window.c | 6 +----- dlls/winex11.drv/x11drv.h | 4 ++++ dlls/winex11.drv/x11drv_main.c | 4 ++++ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index e8ba8e37753..caa25309356 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -121,10 +121,11 @@ static const UINT button_up_data[NB_BUTTONS] = XBUTTON2 }; +XContext cursor_context = 0; + static HWND cursor_window; static HCURSOR last_cursor; static DWORD last_cursor_change; -static XContext cursor_context; static RECT clip_rect; static Cursor create_cursor( HANDLE handle ); @@ -200,16 +201,13 @@ void set_window_cursor( Window window, HCURSOR handle ) { Cursor cursor, prev; - wine_tsx11_lock(); if (!handle) cursor = get_empty_cursor(); - else if (!cursor_context || XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor )) + else if (XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor )) { /* try to create it */ - wine_tsx11_unlock(); if (!(cursor = create_cursor( handle ))) return; wine_tsx11_lock(); - if (!cursor_context) cursor_context = XUniqueContext(); if (!XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&prev )) { /* someone else was here first */ @@ -221,12 +219,12 @@ void set_window_cursor( Window window, HCURSOR handle ) XSaveContext( gdi_display, (XID)handle, cursor_context, (char *)cursor ); TRACE( "cursor %p created %lx\n", handle, cursor ); } + wine_tsx11_unlock(); } XDefineCursor( gdi_display, window, cursor ); /* make the change take effect immediately */ XFlush( gdi_display ); - wine_tsx11_unlock(); } /*********************************************************************** @@ -1205,7 +1203,7 @@ void CDECL X11DRV_DestroyCursorIcon( HCURSOR handle ) Cursor cursor; wine_tsx11_lock(); - if (cursor_context && !XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor )) + if (!XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor )) { TRACE( "%p xid %lx\n", handle, cursor ); XFreeCursor( gdi_display, cursor ); diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index c69ef8c27f2..c8e48b26fd4 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -75,7 +75,7 @@ int clipping_cursor = 0; XContext winContext = 0; /* X context to associate a struct x11drv_win_data to an hwnd */ -static XContext win_data_context; +XContext win_data_context = 0; /* time of last user event and window where it's stored */ static Time last_user_time; @@ -1914,11 +1914,7 @@ static struct x11drv_win_data *alloc_win_data( Display *display, HWND hwnd ) if ((data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data)))) { data->hwnd = hwnd; - wine_tsx11_lock(); - if (!winContext) winContext = XUniqueContext(); - if (!win_data_context) win_data_context = XUniqueContext(); XSaveContext( display, (XID)hwnd, win_data_context, (char *)data ); - wine_tsx11_unlock(); } return data; } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index f24ccdc4a39..3aaedef06d5 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -615,6 +615,10 @@ static inline BOOL is_window_rect_fullscreen( const RECT *rect ) /* X context to associate a hwnd to an X window */ extern XContext winContext DECLSPEC_HIDDEN; +/* X context to associate a struct x11drv_win_data to an hwnd */ +extern XContext win_data_context DECLSPEC_HIDDEN; +/* X context to associate an X cursor to a Win32 cursor handle */ +extern XContext cursor_context DECLSPEC_HIDDEN; extern void X11DRV_InitClipboard(void) DECLSPEC_HIDDEN; extern int CDECL X11DRV_AcquireClipboard(HWND hWndClipWindow) DECLSPEC_HIDDEN; diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 14993292a6d..56591433eeb 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -570,6 +570,10 @@ static BOOL process_attach(void) XInternAtoms( display, (char **)atom_names, NB_XATOMS - FIRST_XATOM, False, X11DRV_Atoms ); + winContext = XUniqueContext(); + win_data_context = XUniqueContext(); + cursor_context = XUniqueContext(); + if (TRACE_ON(synchronous)) XSynchronize( display, True ); xinerama_init( WidthOfScreen(screen), HeightOfScreen(screen) );