winemac has functions+structs to enumerate "adapters", "monitors", and "displays", but these are all reporting the same underlying objects (macOS screens/displays) in slightly different ways.
"displays" is the oldest one, and the least connected to the current win32u concepts of sources and monitors.
To remove `macdrv_display`, I essentially integrated `macdrv_get_displays()` into `macdrv_get_monitors()` (where it was used to get `RcMonitor` and `RcWork`). I converted one other caller to use `macdrv_get_monitors()` instead, and the other callers didn't actually support multiple monitors anyway.
I may work on eliminating the redundancy between "adapters" and "monitors" in the future, as far as I can tell "monitors" are a superset of "adapters" (monitors includes mirrors, adapters does not).
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 7628ca32ec2..db183962826 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -1109,7 +1109,7 @@ UINT macdrv_UpdateDisplayDevices(const struct gdi_device_manager *device_manager UINT dpi = NtUserGetSystemDpiForProcess( NULL ); char buffer[32];
- sprintf( buffer, "%04x", adapter->id ); + snprintf( buffer, sizeof(buffer), "%04x", adapter->id ); device_manager->add_source( buffer, adapter->state_flags, dpi, param );
if (macdrv_get_monitors(adapter->id, &monitors, &monitor_count)) break;
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/cocoa_display.m | 2 +- dlls/winemac.drv/macdrv_cocoa.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m index 3f6246e7e1b..4e3e65dd69a 100644 --- a/dlls/winemac.drv/cocoa_display.m +++ b/dlls/winemac.drv/cocoa_display.m @@ -656,7 +656,7 @@ void macdrv_free_adapters(struct macdrv_adapter* adapters) * * Returns non-zero value on failure with parameters unchanged and zero on success. */ -int macdrv_get_monitors(uint32_t adapter_id, struct macdrv_monitor** new_monitors, int* count) +int macdrv_get_monitors(CGDirectDisplayID adapter_id, struct macdrv_monitor** new_monitors, int* count) { struct macdrv_monitor* monitors = NULL; struct macdrv_monitor* realloc_monitors; diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index 4b4bc72401b..bf98a4f05d7 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -245,8 +245,8 @@ static inline CGPoint cgpoint_win_from_mac(CGPoint point) /* Represent an adapter in EnumDisplayDevices context */ struct macdrv_adapter { - /* ID to uniquely identify an adapter. Currently it's a CGDirectDisplayID */ - uint32_t id; + /* ID to uniquely identify an adapter */ + CGDirectDisplayID id; /* as StateFlags in DISPLAY_DEVICE struct */ uint32_t state_flags; }; @@ -268,7 +268,7 @@ extern int macdrv_set_display_mode(const struct macdrv_display* display, extern void macdrv_free_gpus(struct macdrv_gpu* gpus); extern int macdrv_get_adapters(uint64_t gpu_id, struct macdrv_adapter** adapters, int* count); extern void macdrv_free_adapters(struct macdrv_adapter* adapters); -extern int macdrv_get_monitors(uint32_t adapter_id, struct macdrv_monitor** monitors, int* count); +extern int macdrv_get_monitors(CGDirectDisplayID adapter_id, struct macdrv_monitor** monitors, int* count); extern void macdrv_free_monitors(struct macdrv_monitor* monitors);
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/cocoa_display.m | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m index 4e3e65dd69a..56d9b5029a5 100644 --- a/dlls/winemac.drv/cocoa_display.m +++ b/dlls/winemac.drv/cocoa_display.m @@ -37,11 +37,11 @@ * Converts an NSRect in Cocoa's y-goes-up-from-bottom coordinate system * to a CGRect in y-goes-down-from-top coordinates. */ -static inline void convert_display_rect(CGRect* out_rect, NSRect in_rect, - NSRect primary_frame) +static inline CGRect convert_display_rect(NSRect in_rect, NSRect primary_frame) { - *out_rect = NSRectToCGRect(in_rect); - out_rect->origin.y = NSMaxY(primary_frame) - NSMaxY(in_rect); + CGRect out_rect = NSRectToCGRect(in_rect); + out_rect.origin.y = NSMaxY(primary_frame) - NSMaxY(in_rect); + return out_rect; }
@@ -83,11 +83,8 @@ int macdrv_get_displays(struct macdrv_display** displays, int* count) primary_frame = frame;
disps[i].displayID = [[screen deviceDescription][@"NSScreenNumber"] unsignedIntValue]; - convert_display_rect(&disps[i].frame, frame, primary_frame); - convert_display_rect(&disps[i].work_frame, visible_frame, - primary_frame); - disps[i].frame = cgrect_win_from_mac(disps[i].frame); - disps[i].work_frame = cgrect_win_from_mac(disps[i].work_frame); + disps[i].frame = cgrect_win_from_mac(convert_display_rect(frame, primary_frame)); + disps[i].work_frame = cgrect_win_from_mac(convert_display_rect(visible_frame, primary_frame)); }
*displays = disps;
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/cocoa_app.m | 5 ++--- dlls/winemac.drv/display.c | 2 +- dlls/winemac.drv/macdrv_cocoa.h | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 9c7e5d770bf..2a9dab26989 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -2432,13 +2432,12 @@ void macdrv_beep(void) /*********************************************************************** * macdrv_set_display_mode */ -int macdrv_set_display_mode(const struct macdrv_display* display, - CGDisplayModeRef display_mode) +int macdrv_set_display_mode(CGDirectDisplayID displayID, CGDisplayModeRef display_mode) { __block int ret;
OnMainThread(^{ - ret = [[WineApplicationController sharedController] setMode:display_mode forDisplay:display->displayID]; + ret = [[WineApplicationController sharedController] setMode:display_mode forDisplay:displayID]; });
return ret; diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index db183962826..950aa2f2ef2 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -799,7 +799,7 @@ LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, LPCWSTR primary_name, HWN bpp, mode->dmDisplayFrequency); ret = DISP_CHANGE_BADMODE; } - else if (!macdrv_set_display_mode(&macdrv_displays[0], best_display_mode)) + else if (!macdrv_set_display_mode(macdrv_displays[0].displayID, best_display_mode)) { WARN("Failed to set display mode\n"); ret = DISP_CHANGE_FAILED; diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index bf98a4f05d7..771fb81b54c 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -262,8 +262,7 @@ static inline CGPoint cgpoint_win_from_mac(CGPoint point)
extern int macdrv_get_displays(struct macdrv_display** displays, int* count); extern void macdrv_free_displays(struct macdrv_display* displays); -extern int macdrv_set_display_mode(const struct macdrv_display* display, - CGDisplayModeRef display_mode); +extern int macdrv_set_display_mode(CGDirectDisplayID id, CGDisplayModeRef display_mode); extern int macdrv_get_gpus(struct macdrv_gpu** gpus, int* count); extern void macdrv_free_gpus(struct macdrv_gpu* gpus); extern int macdrv_get_adapters(uint64_t gpu_id, struct macdrv_adapter** adapters, int* count);
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/cocoa_display.m | 28 ++++++++++++++++++---------- dlls/winemac.drv/macdrv_cocoa.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m index 56d9b5029a5..9b9c01dc9e1 100644 --- a/dlls/winemac.drv/cocoa_display.m +++ b/dlls/winemac.drv/cocoa_display.m @@ -654,15 +654,17 @@ void macdrv_free_adapters(struct macdrv_adapter* adapters) * Returns non-zero value on failure with parameters unchanged and zero on success. */ int macdrv_get_monitors(CGDirectDisplayID adapter_id, struct macdrv_monitor** new_monitors, int* count) +{ +@autoreleasepool { struct macdrv_monitor* monitors = NULL; struct macdrv_monitor* realloc_monitors; - struct macdrv_display* displays = NULL; CGDirectDisplayID display_ids[16]; uint32_t display_id_count; + NSArray<NSScreen *> *screens = [NSScreen screens]; + NSRect primary_frame; int primary_index = 0; int monitor_count = 0; - int display_count; int capacity; int ret = -1; int i, j; @@ -677,19 +679,25 @@ int macdrv_get_monitors(CGDirectDisplayID adapter_id, struct macdrv_monitor** ne != kCGErrorSuccess) goto done;
- if (macdrv_get_displays(&displays, &display_count)) + screens = [NSScreen screens]; + if (!screens || screens.count < 1) goto done;
+ primary_frame = screens[0].frame; + 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++) + for (j = 0; j < screens.count; j++) { - if (displays[j].displayID == display_ids[i] - || CGDisplayMirrorsDisplay(display_ids[i]) == displays[j].displayID) + NSScreen* screen = screens[j]; + CGDirectDisplayID screen_displayID = [[screen deviceDescription][@"NSScreenNumber"] unsignedIntValue]; + + if (screen_displayID == display_ids[i] + || CGDisplayMirrorsDisplay(display_ids[i]) == screen_displayID) { /* Allocate more space if needed */ if (monitor_count >= capacity) @@ -704,8 +712,9 @@ int macdrv_get_monitors(CGDirectDisplayID adapter_id, struct macdrv_monitor** ne if (j == 0) primary_index = monitor_count;
- monitors[monitor_count].rc_monitor = displays[j].frame; - monitors[monitor_count].rc_work = displays[j].work_frame; + monitors[monitor_count].id = display_ids[i]; + monitors[monitor_count].rc_monitor = convert_display_rect(screen.frame, primary_frame); + monitors[monitor_count].rc_work = convert_display_rect(screen.visibleFrame, primary_frame); monitor_count++; break; } @@ -725,12 +734,11 @@ int macdrv_get_monitors(CGDirectDisplayID adapter_id, struct macdrv_monitor** ne *count = monitor_count; ret = 0; done: - if (displays) - macdrv_free_displays(displays); if (ret) macdrv_free_monitors(monitors); return ret; } +}
/*********************************************************************** * macdrv_free_monitors diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index 771fb81b54c..ad56615dbb2 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -254,6 +254,7 @@ static inline CGPoint cgpoint_win_from_mac(CGPoint point) /* Represent a monitor in EnumDisplayDevices context */ struct macdrv_monitor { + CGDirectDisplayID id; /* as RcMonitor in MONITORINFO struct after conversion by rect_from_cgrect */ CGRect rc_monitor; /* as RcWork in MONITORINFO struct after conversion by rect_from_cgrect */
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/display.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-)
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 950aa2f2ef2..8289dda23a5 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -885,16 +885,16 @@ static DEVMODEW *display_get_modes(CGDirectDisplayID display_id, int *modes_coun return devmodes; }
-static void display_get_current_mode(struct macdrv_display *display, DEVMODEW *devmode) +static void display_get_current_mode(struct macdrv_monitor *monitor, DEVMODEW *devmode) { CGDisplayModeRef display_mode; CGDirectDisplayID display_id;
- display_id = display->displayID; + display_id = monitor->id; display_mode = CGDisplayCopyDisplayMode(display_id);
- devmode->dmPosition.x = CGRectGetMinX(display->frame); - devmode->dmPosition.y = CGRectGetMinY(display->frame); + devmode->dmPosition.x = CGRectGetMinX(monitor->rc_monitor); + devmode->dmPosition.y = CGRectGetMinY(monitor->rc_monitor); devmode->dmFields |= DM_POSITION;
display_mode_to_devmode_fields(display_id, display_mode, devmode); @@ -1070,16 +1070,9 @@ UINT macdrv_UpdateDisplayDevices(const struct gdi_device_manager *device_manager struct macdrv_adapter *adapters, *adapter; struct macdrv_monitor *monitors, *monitor; struct macdrv_gpu *gpus, *gpu; - struct macdrv_display *displays, *display; - INT gpu_count, adapter_count, monitor_count, mode_count, display_count; + INT gpu_count, adapter_count, monitor_count, mode_count; DEVMODEW *modes;
- if (macdrv_get_displays(&displays, &display_count)) - { - displays = NULL; - display_count = 0; - } - /* Initialize GPUs */ if (macdrv_get_gpus(&gpus, &gpu_count)) { @@ -1124,19 +1117,10 @@ UINT macdrv_UpdateDisplayDevices(const struct gdi_device_manager *device_manager .rc_work = rect_from_cgrect(monitor->rc_work), }; device_manager->add_monitor( &gdi_monitor, param ); - }
- /* Get the current mode */ - if (displays) - { - for (display = displays; display < displays + display_count; display++) - { - if (display->displayID == adapter->id) - { - display_get_current_mode(display, ¤t_mode); - break; - } - } + /* Get the current mode */ + if (monitor->id == adapter->id) + display_get_current_mode(monitor, ¤t_mode); }
if (!(modes = display_get_modes(adapter->id, &mode_count))) break; @@ -1149,6 +1133,5 @@ UINT macdrv_UpdateDisplayDevices(const struct gdi_device_manager *device_manager }
macdrv_free_gpus(gpus); - macdrv_free_displays(displays); return STATUS_SUCCESS; }
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/display.c | 42 ++++++++------------------------------ 1 file changed, 9 insertions(+), 33 deletions(-)
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 8289dda23a5..3100dc3dc9b 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -747,8 +747,6 @@ LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, LPCWSTR primary_name, HWN LONG ret = DISP_CHANGE_SUCCESSFUL; DEVMODEW *mode; int bpp; - struct macdrv_display *macdrv_displays; - int num_displays; CFArrayRef display_modes; struct display_mode_descriptor *desc; CGDisplayModeRef best_display_mode; @@ -757,19 +755,14 @@ LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, LPCWSTR primary_name, HWN
init_original_display_mode();
- if (macdrv_get_displays(&macdrv_displays, &num_displays)) - return DISP_CHANGE_FAILED; - - display_modes = copy_display_modes(macdrv_displays[0].displayID, FALSE); + /* TODO: support displays other than the main one */ + display_modes = copy_display_modes(CGMainDisplayID(), FALSE); if (!display_modes) - { - macdrv_free_displays(macdrv_displays); return DISP_CHANGE_FAILED; - }
bpp = get_default_bpp();
- desc = create_original_display_mode_descriptor(macdrv_displays[0].displayID); + desc = create_original_display_mode_descriptor(CGMainDisplayID());
for (mode = displays; mode->dmSize && !ret; mode = NEXT_DEVMODEW(mode)) { @@ -799,7 +792,7 @@ LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, LPCWSTR primary_name, HWN bpp, mode->dmDisplayFrequency); ret = DISP_CHANGE_BADMODE; } - else if (!macdrv_set_display_mode(macdrv_displays[0].displayID, best_display_mode)) + else if (!macdrv_set_display_mode(CGMainDisplayID(), best_display_mode)) { WARN("Failed to set display mode\n"); ret = DISP_CHANGE_FAILED; @@ -808,7 +801,6 @@ LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, LPCWSTR primary_name, HWN
free_display_mode_descriptor(desc); CFRelease(display_modes); - macdrv_free_displays(macdrv_displays); macdrv_reset_device_metrics();
return ret; @@ -919,8 +911,6 @@ BOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp) { BOOL ret = FALSE; DDGAMMARAMP *r = ramp; - struct macdrv_display *displays; - int num_displays; uint32_t mac_entries; int win_entries = ARRAY_SIZE(r->red); CGGammaValue *red, *green, *blue; @@ -929,20 +919,15 @@ BOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp)
TRACE("dev %p ramp %p\n", dev, ramp);
- if (macdrv_get_displays(&displays, &num_displays)) - { - WARN("failed to get Mac displays\n"); - return FALSE; - } - - mac_entries = CGDisplayGammaTableCapacity(displays[0].displayID); + /* TODO: support displays other than the main one */ + mac_entries = CGDisplayGammaTableCapacity(CGMainDisplayID()); red = malloc(mac_entries * sizeof(red[0]) * 3); if (!red) goto done; green = red + mac_entries; blue = green + mac_entries;
- err = CGGetDisplayTransferByTable(displays[0].displayID, mac_entries, red, green, + err = CGGetDisplayTransferByTable(CGMainDisplayID(), mac_entries, red, green, blue, &mac_entries); if (err != kCGErrorSuccess) { @@ -992,7 +977,6 @@ BOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp)
done: free(red); - macdrv_free_displays(displays); return ret; }
@@ -1002,8 +986,6 @@ done: BOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp) { DDGAMMARAMP *r = ramp; - struct macdrv_display *displays; - int num_displays; int win_entries = ARRAY_SIZE(r->red); CGGammaValue *red, *green, *blue; int i; @@ -1017,12 +999,6 @@ BOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp) return FALSE; }
- if (macdrv_get_displays(&displays, &num_displays)) - { - WARN("failed to get Mac displays\n"); - return FALSE; - } - red = malloc(win_entries * sizeof(red[0]) * 3); if (!red) goto done; @@ -1036,13 +1012,13 @@ BOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp) blue[i] = r->blue[i] / 65535.0; }
- err = CGSetDisplayTransferByTable(displays[0].displayID, win_entries, red, green, blue); + /* TODO: support displays other than the main one */ + err = CGSetDisplayTransferByTable(CGMainDisplayID(), win_entries, red, green, blue); if (err != kCGErrorSuccess) WARN("failed to set display gamma table: %d\n", err);
done: free(red); - macdrv_free_displays(displays); return (err == kCGErrorSuccess); }
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/cocoa_display.m | 5 ++++- dlls/winemac.drv/display.c | 14 ++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m index 9b9c01dc9e1..2cb6a8f1ce5 100644 --- a/dlls/winemac.drv/cocoa_display.m +++ b/dlls/winemac.drv/cocoa_display.m @@ -650,6 +650,7 @@ void macdrv_free_adapters(struct macdrv_adapter* adapters) * * Get a list of monitors under adapter_id. The first monitor is primary if adapter is primary. * Call macdrv_free_monitors() when you are done using the data. + * An adapter_id of kCGNullDirectDisplay will return monitors for all adapters. * * Returns non-zero value on failure with parameters unchanged and zero on success. */ @@ -687,7 +688,9 @@ int macdrv_get_monitors(CGDirectDisplayID adapter_id, struct macdrv_monitor** ne
for (i = 0; i < display_id_count; i++) { - if (display_ids[i] != adapter_id && CGDisplayMirrorsDisplay(display_ids[i]) != adapter_id) + if (adapter_id != kCGNullDirectDisplay && + display_ids[i] != adapter_id && + CGDisplayMirrorsDisplay(display_ids[i]) != adapter_id) continue;
/* Find and fill in monitor info */ diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 3100dc3dc9b..8b012379b2e 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -212,8 +212,8 @@ static void init_original_display_mode(void) BOOL success = FALSE; HKEY mac_driver_hkey, parent_hkey; DWORD disposition; - struct macdrv_display *displays = NULL; - int num_displays, i; + struct macdrv_monitor *monitors = NULL; + int num_monitors, i;
if (inited_original_display_mode) return; @@ -237,12 +237,14 @@ static void init_original_display_mode(void) if (disposition != REG_CREATED_NEW_KEY) goto done;
- if (macdrv_get_displays(&displays, &num_displays)) + if (macdrv_get_monitors(kCGNullDirectDisplay, &monitors, &num_monitors)) goto fail;
- for (i = 0; i < num_displays; i++) + for (i = 0; i < num_monitors; i++) { - if (!write_display_settings(parent_hkey, displays[i].displayID)) + if (CGDisplayMirrorsDisplay(monitors[i].id) != kCGNullDirectDisplay) + continue; + if (!write_display_settings(parent_hkey, monitors[i].id)) goto fail; }
@@ -250,7 +252,7 @@ done: success = TRUE;
fail: - macdrv_free_displays(displays); + macdrv_free_monitors(monitors); NtClose(parent_hkey); if (!success && parent_hkey) reg_delete_tree(mac_driver_hkey, initial_mode_keyW, sizeof(initial_mode_keyW));
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/cocoa_display.m | 64 -------------------------------- dlls/winemac.drv/macdrv_cocoa.h | 8 ---- 2 files changed, 72 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m index 2cb6a8f1ce5..372d89381f1 100644 --- a/dlls/winemac.drv/cocoa_display.m +++ b/dlls/winemac.drv/cocoa_display.m @@ -45,70 +45,6 @@ static inline CGRect convert_display_rect(NSRect in_rect, NSRect primary_frame) }
-/*********************************************************************** - * macdrv_get_displays - * - * Returns information about the displays. - * - * Returns 0 on success and *displays contains a newly-allocated array - * of macdrv_display structures and *count contains the number of - * elements in that array. The first element of the array is the - * primary display. When the caller is done with the array, it should - * use macdrv_free_displays() to deallocate it. - * - * Returns non-zero on failure and *displays and *count are unchanged. - */ -int macdrv_get_displays(struct macdrv_display** displays, int* count) -{ -@autoreleasepool -{ - NSArray* screens = [NSScreen screens]; - if (screens) - { - NSUInteger num_screens = [screens count]; - struct macdrv_display* disps = malloc(num_screens * sizeof(disps[0])); - - if (disps) - { - NSRect primary_frame; - - NSUInteger i; - for (i = 0; i < num_screens; i++) - { - NSScreen* screen = screens[i]; - NSRect frame = [screen frame]; - NSRect visible_frame = [screen visibleFrame]; - - if (i == 0) - primary_frame = frame; - - disps[i].displayID = [[screen deviceDescription][@"NSScreenNumber"] unsignedIntValue]; - disps[i].frame = cgrect_win_from_mac(convert_display_rect(frame, primary_frame)); - disps[i].work_frame = cgrect_win_from_mac(convert_display_rect(visible_frame, primary_frame)); - } - - *displays = disps; - *count = num_screens; - return 0; - } - } - - return -1; -} -} - - -/*********************************************************************** - * macdrv_free_displays - * - * Deallocates an array of macdrv_display structures previously returned - * from macdrv_get_displays(). - */ -void macdrv_free_displays(struct macdrv_display* displays) -{ - free(displays); -} - /*********************************************************************** * get_entry_property_uint32 * diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index ad56615dbb2..954acb0fc67 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -110,12 +110,6 @@ struct macdrv_event; struct macdrv_query;
-struct macdrv_display { - CGDirectDisplayID displayID; - CGRect frame; - CGRect work_frame; -}; -
/* main */ extern bool macdrv_err_on; @@ -261,8 +255,6 @@ static inline CGPoint cgpoint_win_from_mac(CGPoint point) CGRect rc_work; };
-extern int macdrv_get_displays(struct macdrv_display** displays, int* count); -extern void macdrv_free_displays(struct macdrv_display* displays); extern int macdrv_set_display_mode(CGDirectDisplayID id, CGDisplayModeRef display_mode); extern int macdrv_get_gpus(struct macdrv_gpu** gpus, int* count); extern void macdrv_free_gpus(struct macdrv_gpu* gpus);