There is one more level below Xlib. Newest versions of Xlib library use XCB to perform its work:
http://xcb.freedesktop.org/
Read about differences between Xlib and XCB here:
http://www.x.org/wiki/guide/xlib-and-xcb/
nxsy have created HH platfrom layer on Linux using XCB here:
https://forums.handmadehero.org/i...p/forum?view=topic&catid=4&id=151