From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winemac.drv/display.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index b981aa12e35..b731e50d187 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -51,9 +51,6 @@ static const WCHAR initial_mode_keyW[] = {'I','n','i','t','i','a','l',' ','D','i ' ','M','o','d','e'}; static const WCHAR pixelencodingW[] = {'P','i','x','e','l','E','n','c','o','d','i','n','g',0};
-static int cached_default_mode_bpp; -static pthread_mutex_t cached_modes_mutex = PTHREAD_MUTEX_INITIALIZER; - static BOOL inited_original_display_mode;
@@ -400,22 +397,26 @@ static BOOL display_mode_matches_descriptor(CGDisplayModeRef mode, const struct
static int get_default_bpp(void) { + static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + static int cached; int ret;
- if (!cached_default_mode_bpp) + pthread_mutex_lock(&mutex); + if (!cached) { CGDisplayModeRef mode = CGDisplayCopyDisplayMode(kCGDirectMainDisplay); if (mode) { - cached_default_mode_bpp = display_mode_bits_per_pixel(mode); + cached = display_mode_bits_per_pixel(mode); CFRelease(mode); }
- if (!cached_default_mode_bpp) - cached_default_mode_bpp = 32; + if (!cached) + cached = 32; } + pthread_mutex_unlock(&mutex);
- ret = cached_default_mode_bpp; + ret = cached;
TRACE(" -> %d\n", ret); return ret; @@ -800,9 +801,7 @@ LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, HWND hwnd, DWORD flags, L return DISP_CHANGE_FAILED; }
- pthread_mutex_lock(&cached_modes_mutex); bpp = get_default_bpp(); - pthread_mutex_unlock(&cached_modes_mutex);
desc = create_original_display_mode_descriptor(macdrv_displays[0].displayID);