winex11: Use pthread for settings locking.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6db4613be9
commit
870d0080b0
|
@ -70,14 +70,7 @@ static DWORD cached_flags;
|
||||||
static DEVMODEW *cached_modes;
|
static DEVMODEW *cached_modes;
|
||||||
static UINT cached_mode_count;
|
static UINT cached_mode_count;
|
||||||
|
|
||||||
static CRITICAL_SECTION modes_section;
|
static pthread_mutex_t settings_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static CRITICAL_SECTION_DEBUG modes_critsect_debug =
|
|
||||||
{
|
|
||||||
0, 0, &modes_section,
|
|
||||||
{&modes_critsect_debug.ProcessLocksList, &modes_critsect_debug.ProcessLocksList},
|
|
||||||
0, 0, {(DWORD_PTR)(__FILE__ ": modes_section")}
|
|
||||||
};
|
|
||||||
static CRITICAL_SECTION modes_section = {&modes_critsect_debug, -1, 0, 0, 0, 0};
|
|
||||||
|
|
||||||
void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *new_handler)
|
void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *new_handler)
|
||||||
{
|
{
|
||||||
|
@ -427,13 +420,13 @@ static void set_display_depth(ULONG_PTR display_id, DWORD depth)
|
||||||
{
|
{
|
||||||
struct x11drv_display_depth *display_depth;
|
struct x11drv_display_depth *display_depth;
|
||||||
|
|
||||||
EnterCriticalSection(&modes_section);
|
pthread_mutex_lock( &settings_mutex );
|
||||||
LIST_FOR_EACH_ENTRY(display_depth, &x11drv_display_depth_list, struct x11drv_display_depth, entry)
|
LIST_FOR_EACH_ENTRY(display_depth, &x11drv_display_depth_list, struct x11drv_display_depth, entry)
|
||||||
{
|
{
|
||||||
if (display_depth->display_id == display_id)
|
if (display_depth->display_id == display_id)
|
||||||
{
|
{
|
||||||
display_depth->depth = depth;
|
display_depth->depth = depth;
|
||||||
LeaveCriticalSection(&modes_section);
|
pthread_mutex_unlock( &settings_mutex );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,14 +435,14 @@ static void set_display_depth(ULONG_PTR display_id, DWORD depth)
|
||||||
if (!display_depth)
|
if (!display_depth)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate memory.\n");
|
ERR("Failed to allocate memory.\n");
|
||||||
LeaveCriticalSection(&modes_section);
|
pthread_mutex_unlock( &settings_mutex );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
display_depth->display_id = display_id;
|
display_depth->display_id = display_id;
|
||||||
display_depth->depth = depth;
|
display_depth->depth = depth;
|
||||||
list_add_head(&x11drv_display_depth_list, &display_depth->entry);
|
list_add_head(&x11drv_display_depth_list, &display_depth->entry);
|
||||||
LeaveCriticalSection(&modes_section);
|
pthread_mutex_unlock( &settings_mutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD get_display_depth(ULONG_PTR display_id)
|
static DWORD get_display_depth(ULONG_PTR display_id)
|
||||||
|
@ -457,17 +450,17 @@ static DWORD get_display_depth(ULONG_PTR display_id)
|
||||||
struct x11drv_display_depth *display_depth;
|
struct x11drv_display_depth *display_depth;
|
||||||
DWORD depth;
|
DWORD depth;
|
||||||
|
|
||||||
EnterCriticalSection(&modes_section);
|
pthread_mutex_lock( &settings_mutex );
|
||||||
LIST_FOR_EACH_ENTRY(display_depth, &x11drv_display_depth_list, struct x11drv_display_depth, entry)
|
LIST_FOR_EACH_ENTRY(display_depth, &x11drv_display_depth_list, struct x11drv_display_depth, entry)
|
||||||
{
|
{
|
||||||
if (display_depth->display_id == display_id)
|
if (display_depth->display_id == display_id)
|
||||||
{
|
{
|
||||||
depth = display_depth->depth;
|
depth = display_depth->depth;
|
||||||
LeaveCriticalSection(&modes_section);
|
pthread_mutex_unlock( &settings_mutex );
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&modes_section);
|
pthread_mutex_unlock( &settings_mutex );
|
||||||
return screen_bpp;
|
return screen_bpp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,13 +500,13 @@ BOOL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DW
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&modes_section);
|
pthread_mutex_lock( &settings_mutex );
|
||||||
if (n == 0 || lstrcmpiW(cached_device_name, name) || cached_flags != flags)
|
if (n == 0 || lstrcmpiW(cached_device_name, name) || cached_flags != flags)
|
||||||
{
|
{
|
||||||
if (!handler.get_id(name, &id) || !handler.get_modes(id, flags, &modes, &mode_count))
|
if (!handler.get_id(name, &id) || !handler.get_modes(id, flags, &modes, &mode_count))
|
||||||
{
|
{
|
||||||
ERR("Failed to get %s supported display modes.\n", wine_dbgstr_w(name));
|
ERR("Failed to get %s supported display modes.\n", wine_dbgstr_w(name));
|
||||||
LeaveCriticalSection(&modes_section);
|
pthread_mutex_unlock( &settings_mutex );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,14 +522,14 @@ BOOL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DW
|
||||||
|
|
||||||
if (n >= cached_mode_count)
|
if (n >= cached_mode_count)
|
||||||
{
|
{
|
||||||
LeaveCriticalSection(&modes_section);
|
pthread_mutex_unlock( &settings_mutex );
|
||||||
WARN("handler:%s device:%s mode index:%#x not found.\n", handler.name, wine_dbgstr_w(name), n);
|
WARN("handler:%s device:%s mode index:%#x not found.\n", handler.name, wine_dbgstr_w(name), n);
|
||||||
SetLastError(ERROR_NO_MORE_FILES);
|
SetLastError(ERROR_NO_MORE_FILES);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(devmode, (BYTE *)cached_modes + (sizeof(*cached_modes) + cached_modes[0].dmDriverExtra) * n, sizeof(*devmode));
|
memcpy(devmode, (BYTE *)cached_modes + (sizeof(*cached_modes) + cached_modes[0].dmDriverExtra) * n, sizeof(*devmode));
|
||||||
LeaveCriticalSection(&modes_section);
|
pthread_mutex_unlock( &settings_mutex );
|
||||||
|
|
||||||
done:
|
done:
|
||||||
/* Set generic fields */
|
/* Set generic fields */
|
||||||
|
|
Loading…
Reference in New Issue