This moves the X11 polling implementation to a separate file where it
can be used by either the X11 or Wayland backend or both.
This code should be POSIX compatible where necessary but will use the
lower latency but non-standard polling functions ppoll or pollts where
those are available.
This commit is based on work by OlivierSohn and kovidgoyal.
Fixes#1281Closes#1285