How to make PTB work on "Retina" display?

PTB 3.0.11 does not handle screen resolutions properly for a "Retina" display, at least for OSX 10.9.2.  Can anyone suggest a fix or workaround?

When the screen resolution is initially set to 1920x1200,
this resolution is correctly reported by Screen('Resolution',0),
and I can adjust the resolution to 2880x1800 (the native resolution),
but I cannot set it back to 1920x1200 without an error.
Oddly, I cannot even set the resolution to 1920x1200 when it is *already* that resolution.

Here is example code:

r = Screen('Resolution', 0)
r = Screen('Resolution', 0, r.width, r.height, r.pixelSize, r.hz)

OUTPUT:
r = 
        width: 1920
       height: 1200
    pixelSize: 32
           hz: 0

Error in function Resolution: Invalid pixel size argument
Illegal depth value
Error using Screen
Usage:

oldResolution=Screen('Resolution', screenNumber [, newwidth][, newheight][, newHz][, newPixelSize][, specialMode]);

Error in laptop_resolution (line 7)
r = Screen('Resolution', 0, r.width, r.height, r.pixelSize, r.hz)

Either it's a PTB bug, or you provided the arguments to Screen('Resolution', ...); in the wrong order without double checking with the help "Screen Resolution?" after getting error messages. I wonder which it is?
-mario
Hi Mario,

It is PTB bug.  I am using the correct parameter order for Screen('Resolution', ...).

Here is some more example code and diagnostic output.
This code shows that NearestResolution correctly handles 2 available resolutions (2880x1800 and 1440x900), but it fails to handle the currently reported resolution (1920x1200) and instead reports 2048x1280 as the nearest.

CODE:
fprintf('Nearest Resolution to 2880 x 1800\n');
newres = NearestResolution(0, 2880, 1800)

fprintf('Nearest Resolution to 1440 x 900\n');
newres = NearestResolution(0, 1440, 900)

fprintf('Current Resolution ...\n');
res = Screen('Resolution', 0)

fprintf('Nearest Resolution to Current Resolution: %d x %d\n', res.width, res.height);
newres = NearestResolution(0, res.width, res.height)

OUTPUT:
Nearest Resolution to 2880 x 1800
newres = 
        width: 2880
       height: 1800
    pixelSize: []
           hz: 0

Nearest Resolution to 1440 x 900
newres = 
        width: 1440
       height: 900
    pixelSize: []
           hz: 0

Current Resolution ...
res = 
        width: 1920
       height: 1200
    pixelSize: 32
           hz: 0

Nearest Resolution to Current Resolution: 1920 x 1200
newres = 
        width: 2048
       height: 1280
    pixelSize: []
           hz: 0


I already replied, ... but here is some additional info.

NearestResolution does not seem to work properly for some supported resolutions,
or else Screen('Resolution') is misreported the current resolution, at least in some cases.

Here is what happens when I change the screen resolution using Mac OSX Preferences>Display
then call Screen('Resolution') to get the current resolution,
and then call NearestResolution with the current width,height.

"Current Resolution" => "Nearest Resolution"
1024 x 640 => 1024 x 768 (wrong)
1280 x 800 => 1280 x 800 (correct)
1680 x 1050 => 1680 x 1050 (correct)
1920 x 1200 => 2048 x 1280 (wrong)

Mac OSX 10.9.2 on MacBookProRetina

I just confirmed that my MacBookProRetina does in fact work properly for several PTB demos I tried, as long as you first set Screen('Resolution') to be the native resolution (ie, highest resolution available, which is 2880x1800 on my 15" Retina display).

There were no glitches or timing issues.

If using native resolution is the only limitation to get PTB working on a retina display,
I think most people will be happy with that.

-- David