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 &lt;using retina display&gt;) else 1)

where &lt;using retina display&gt; is the check.
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