CGDisplayPixelsWide/High does not in fact return pixels, docs don't mention this

Originator:phil
Number:rdar://34994629 Date Originated:October 14 2017
Status:Open Resolved:
Product:macOS + SDK Product Version:10.11.6+10.13.1b2+others
Classification:other bug Reproducible:always
 
Area:
Core Graphics

Summary:
It turns out that CGDisplayPixelsWide() and CGDisplayPixelsHigh() from Quartz Display Services do not in fact return the display/framebuffer dimensions in pixels, but in points. While this is probably a concession to backwards-compatibility, and I don't expect the functionality to change at this stage, the header and documentation should probably make it abundantly clear that the name no longer reflects the functionality.

Yet the documentation states:

"Returns the display width in pixel units."

and

"Return Value
The display width in pixel units."

See https://developer.apple.com/documentation/coregraphics/1456361-cgdisplaypixelswide?language=objc

The comments in CGDirectDisplay.h are similarly misleading and should be fixed.


Steps to Reproduce:

1. Save the following code as e.g. cgdisplaypixels.c, and build it with
clang -Wextra -framework CoreGraphics cgdisplaypixels.c -o cgdisplaypixels

/**************************************************************/
#include  
#include  

int main()
{
        uint32_t num_displays = 32;
        CGDirectDisplayID displays[num_displays];
        CGError err = CGGetActiveDisplayList(num_displays, displays, &num_displays);
        if (err != 0)
                return 1;
        for (unsigned i = 0; i < num_displays; ++i)
        {
                size_t w = CGDisplayPixelsWide(displays[i]);
                size_t h = CGDisplayPixelsHigh(displays[i]);
                printf("%u - 0x%x: %4zu x %4zu\n", i, displays[i], w, h);
        }
        return 0;
}
/**************************************************************/

2. Run on a Mac with at least one "Retina" display.

Expected Results:
An output listing the dimensions of the attached displays, in pixels, as described in the documentation.

Actual Results:
An output listing the dimensions of the attached displays, in points.

Version/Build:
Confirmed on OS X 10.11.6 and 10.13.1 Beta 2, but probably (hopefully!) all versions of macOS/OS X which support retina mode.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!