Detect if using retina display from python

I've got some BGL drawing code which draws some outlines over nodes in screen-space coordinates. It accounts for the DPI settings in the User Preferences and scales up the size and position of drawn objects accordingly.

The problem is, if a user is using a Retina display, the DPI value in the preferences doesn't actually change, even though it virtually doubles, thus the screen coordinates are all wrong:

The red outlines are supposed to sit exactly on top of the nodes. This works fine on a non-retina display.

So how can I check whether blender is running on a Retina display from python?

The code is all here: http://hastebin.com/gipifamoco.py - at line 607 is where I take into account the DPI and "Virtual Pixel Mode" option in the user prefs (which can be set to 'Double' to simulate using a Retina display, but stays at 'Native' when using an actual Retina display)

So theoretically I'd like to be able to change:

retinafac = (2 if bpy.context.user_preferences.system.virtual_pixel_mode == 'DOUBLE' else 1)

to:

retinafac = (2 if (bpy.context.user_preferences.system.virtual_pixel_mode == 'DOUBLE' or <using retina display>) else 1)

where <using retina display> is the check.

• Do you use the command line option --no-native-pixels "Do not use native pixel size, for high resolution displays (MacBook 'Retina')" Found here: wiki.blender.org/index.php/Doc:2.6/Manual/Render/Command_Line Feb 1 '15 at 9:06
• I know that option exists, but I'm not sure how it would help me. I simply want to check if the user is using a retina display. Feb 1 '15 at 14:30
• Added access to pixelsize: eg. bpy.context.user_preferences.system.pixel_size developer.blender.org/… Feb 1 '15 at 17:59
• @ideasman42: you should make that an answer (wasn't possible so far, but will be in future). Kudos for exposing it to Python. Feb 1 '15 at 22:32

You can can now access the pixel size with bpy.context.user_preferences.system.pixel_size (commit)
This works for retina scale or bpy.context.user_preferences.system.virtual_pixel_mode