From 5400db15ca9983a06df2f5071705e0256e95e11e Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 12 Apr 2021 17:55:19 +0200 Subject: [PATCH] winemac.drv: Don't filter non active displays out. On Windows 10 the DISPLAY_DEVICE_ACTIVE flag is set even if monitor is in power saving mode or switched off. Monitors without DISPLAY_DEVICE_ACTIVE are only reported when display is disabled. This doesn't match with CGDisplayIsActive function. Current code causes rendering problems when native .NET is used. When monitors are updated when in power saving mode (e.g. due to race on machine wake-up) we might end up with no monitors being enumerated by EnumDisplayMonitors. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/winemac.drv/cocoa_display.m | 89 ++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 50 deletions(-) diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m index 05f1c75d53b..3bb1b5151d5 100644 --- a/dlls/winemac.drv/cocoa_display.m +++ b/dlls/winemac.drv/cocoa_display.m @@ -646,65 +646,54 @@ int macdrv_get_monitors(uint32_t adapter_id, struct macdrv_monitor** new_monitor if (!monitors) return -1; - /* Report an inactive monitor */ - if (!CGDisplayIsActive(adapter_id) && !CGDisplayIsInMirrorSet(adapter_id)) - { - strcpy(monitors[monitor_count].name, "Generic Non-PnP Monitor"); - monitors[monitor_count].state_flags = DISPLAY_DEVICE_ATTACHED; - monitor_count++; - } - /* Report active and mirrored monitors in the same mirroring set */ - else - { - if (CGGetOnlineDisplayList(sizeof(display_ids) / sizeof(display_ids[0]), display_ids, &display_id_count) - != kCGErrorSuccess) - goto done; + if (CGGetOnlineDisplayList(sizeof(display_ids) / sizeof(display_ids[0]), display_ids, &display_id_count) + != kCGErrorSuccess) + goto done; - if (macdrv_get_displays(&displays, &display_count)) - goto done; + if (macdrv_get_displays(&displays, &display_count)) + goto done; - for (i = 0; i < display_id_count; i++) - { - if (display_ids[i] != adapter_id && CGDisplayMirrorsDisplay(display_ids[i]) != adapter_id) - continue; + for (i = 0; i < display_id_count; i++) + { + if (display_ids[i] != adapter_id && CGDisplayMirrorsDisplay(display_ids[i]) != adapter_id) + continue; - /* Find and fill in monitor info */ - for (j = 0; j < display_count; j++) + /* Find and fill in monitor info */ + for (j = 0; j < display_count; j++) + { + if (displays[j].displayID == display_ids[i] + || CGDisplayMirrorsDisplay(display_ids[i]) == displays[j].displayID) { - if (displays[j].displayID == display_ids[i] - || CGDisplayMirrorsDisplay(display_ids[i]) == displays[j].displayID) + /* Allocate more space if needed */ + if (monitor_count >= capacity) { - /* Allocate more space if needed */ - if (monitor_count >= capacity) - { - capacity *= 2; - realloc_monitors = realloc(monitors, sizeof(*monitors) * capacity); - if (!realloc_monitors) - goto done; - monitors = realloc_monitors; - } - - if (j == 0) - primary_index = monitor_count; - - strcpy(monitors[monitor_count].name, "Generic Non-PnP Monitor"); - monitors[monitor_count].state_flags = DISPLAY_DEVICE_ATTACHED | DISPLAY_DEVICE_ACTIVE; - monitors[monitor_count].rc_monitor = displays[j].frame; - monitors[monitor_count].rc_work = displays[j].work_frame; - monitor_count++; - break; + capacity *= 2; + realloc_monitors = realloc(monitors, sizeof(*monitors) * capacity); + if (!realloc_monitors) + goto done; + monitors = realloc_monitors; } + + if (j == 0) + primary_index = monitor_count; + + strcpy(monitors[monitor_count].name, "Generic Non-PnP Monitor"); + monitors[monitor_count].state_flags = DISPLAY_DEVICE_ATTACHED | DISPLAY_DEVICE_ACTIVE; + monitors[monitor_count].rc_monitor = displays[j].frame; + monitors[monitor_count].rc_work = displays[j].work_frame; + monitor_count++; + break; } } + } - /* Make sure the first monitor on primary adapter is primary */ - if (primary_index) - { - struct macdrv_monitor tmp; - tmp = monitors[0]; - monitors[0] = monitors[primary_index]; - monitors[primary_index] = tmp; - } + /* Make sure the first monitor on primary adapter is primary */ + if (primary_index) + { + struct macdrv_monitor tmp; + tmp = monitors[0]; + monitors[0] = monitors[primary_index]; + monitors[primary_index] = tmp; } *new_monitors = monitors; -- 2.11.4.GIT