> On Jun 29, 2017, at 2:40 PM, Martin Crane <[email protected]> wrote:
> 
> 
>> On 29 Jun 2017, at 22:27, James Walker <[email protected]> wrote:
>> 
>> On 6/29/2017 12:59 AM, Martin Crane wrote:
>>> James, as the author of such an app I can tell you that it’s definitely 
>>> worthwhile overall. For the most part, everything "just works" in HiDPI 
>>> mode, with some exceptions. It’s certainly a huge improvement on the 
>>> low-res pixelated look on retina Macs :)
>>> 
>>> If you get stuck and need some pointers I’ll be happy to help.
>> 
>> Since you kindly offered... what's the deal with kHICoordSpace72DPIGlobal 
>> and kHICoordSpaceScreenPixel?  I thought it would start making a difference 
>> which of these I use once I go to HiDPI.  But at least when calling 
>> HIWindowGetBounds to get the structure or content region of a HiDPI Carbon 
>> window, I get the same result either way.
>> 
> 
> I don’t use either of those in my entire app, but you’ll find that 
> HIGetScaleFactor always returns 1.0, which explains why there is no 
> difference in the two.

That’s strange, but it simplifies my life if I don’t have to think about which 
to use.


> If you’re looking to find a way to pragmatically determine whether your app 
> is running in HiDPI mode, the only way I discovered is something like below, 
> from which I cache the result.


I don’t know how useful it would be to test whether an app is running in HiDPI 
mode, since a particular Carbon window may or may not have framework scaling 
enabled.  Given a Carbon window, you can find out using 
HIWindowGetBackingScaleFactor.  (In Cocoa, there is an NSWindow property 
backingScaleFactor.)


> 
> -Martin
> 
> 
>       CGContextRef    browserContext = 0;
>       WindowRef       testWind;
>       Rect            r = {0,0,600,600};
>       Boolean         isRetina = false;
> 
>       CreateNewWindow(kDocumentWindowClass,kWindowCompositingAttribute | 
> kWindowFrameworkScaledAttribute, &r, &testWind);
>       
>       if (testWind)
>       {
>               CreateCGContextForPort(GetWindowPort(testWind),&browserContext);
>               
>               if (browserContext)
>               {
>                       CGRect  deviceRect, userRect;
>                       
>                       userRect = CGRectMake( 0, 0, 128, 128 );
>                                                               
>                       deviceRect = 
> CGContextConvertRectToDeviceSpace(browserContext, userRect);
>                       
>                       if (!CGRectEqualToRect(deviceRect, userRect))
>                       {
>                               float   scaleFactor = deviceRect.size.height / 
> userRect.size.height;
>                               
>                               if (scaleFactor != 1.0)
>                                       isRetina = true;
>                       }
>                       
>                       CGContextRelease(browserContext);
>               }
>               
>               DisposeWindow(testWind);
>       }
>       
>       return isRetina;
> 
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Carbon-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/carbon-dev/osx%40jwwalker.com
> 
> This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/carbon-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to