For modern X servers, there's also the XRandR extension, which provides the most up-to-date model of multi screen layout information, including overlapping screens and dynamic screen changes.
Documentation of it is available in the XRandR 1.3.1 Protocol spec and the libXrandr man page.