Wayland

These patches provide support for the Wayland platform, but please note the TODO items in the main commit.