On a typical dual-monitor setup (with xinerama) , there is only 1 x11 global "screen" (you can check that by calling ScreenCount(display))
As a result , when getDisplayDpi is called with screen != 0, it returns garbage. So the correct fix would be to just replace
d.dpi = getDisplayDPI (index);
d.dpi = getDisplayDPI (0);
(only in the Xinerama specific section)
It would be better to retrieve the individual DPI values of each xinerama display but I can't find a way to do that.