From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/macdrv.h | 1 + dlls/winemac.drv/macdrv_main.c | 1 + dlls/winemac.drv/window.c | 32 +++++++++++++++++++------------- 3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 0a0c42aefd0..71a8d9f5bd2 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -205,6 +205,7 @@ struct macdrv_win_data
extern struct macdrv_win_data *get_win_data(HWND hwnd) DECLSPEC_HIDDEN; extern void release_win_data(struct macdrv_win_data *data) DECLSPEC_HIDDEN; +extern void init_win_context(void) DECLSPEC_HIDDEN; extern macdrv_window macdrv_get_cocoa_window(HWND hwnd, BOOL require_on_screen) DECLSPEC_HIDDEN; extern RGNDATA *get_region_data(HRGN hrgn, HDC hdc_lptodp) DECLSPEC_HIDDEN; extern void activate_on_following_focus(void) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 5f61c9491b7..f7b530f50a7 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -459,6 +459,7 @@ static BOOL process_attach(void) if (status != noErr || !(attributes & sessionHasGraphicAccess)) return FALSE;
+ init_win_context(); setup_options(); load_strings(macdrv_module);
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index b00514d30bf..147c979ebde 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -38,15 +38,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(macdrv);
-static CRITICAL_SECTION win_data_section; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &win_data_section, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": win_data_section") } -}; -static CRITICAL_SECTION win_data_section = { &critsect_debug, -1, 0, 0, 0, 0 }; - +static pthread_mutex_t win_data_mutex; static CFMutableDictionaryRef win_datas;
static DWORD activate_on_focus_time; @@ -251,7 +243,7 @@ static struct macdrv_win_data *alloc_win_data(HWND hwnd) data->hwnd = hwnd; data->color_key = CLR_INVALID; data->swap_interval = 1; - EnterCriticalSection(&win_data_section); + pthread_mutex_lock(&win_data_mutex); if (!win_datas) win_datas = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); CFDictionarySetValue(win_datas, hwnd, data); @@ -270,10 +262,10 @@ struct macdrv_win_data *get_win_data(HWND hwnd) struct macdrv_win_data *data;
if (!hwnd) return NULL; - EnterCriticalSection(&win_data_section); + pthread_mutex_lock(&win_data_mutex); if (win_datas && (data = (struct macdrv_win_data*)CFDictionaryGetValue(win_datas, hwnd))) return data; - LeaveCriticalSection(&win_data_section); + pthread_mutex_unlock(&win_data_mutex); return NULL; }
@@ -285,7 +277,7 @@ struct macdrv_win_data *get_win_data(HWND hwnd) */ void release_win_data(struct macdrv_win_data *data) { - if (data) LeaveCriticalSection(&win_data_section); + if (data) pthread_mutex_unlock(&win_data_mutex); }
@@ -2910,3 +2902,17 @@ BOOL query_min_max_info(HWND hwnd) sync_window_min_max_info(hwnd); return TRUE; } + + +/*********************************************************************** + * init_win_context + */ +void init_win_context(void) +{ + pthread_mutexattr_t attr; + + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&win_data_mutex, &attr); + pthread_mutexattr_destroy(&attr); +}