Add some constants and functions.

Needs some discussion with @metajack

This set of changes fixes Linux NVidia (and properly uses the same X11 display connection for X pixmaps).