autotests: Don't try to run X11-specific code under Wayland
Some tests were failing under Wayland because they assumed an X11 environment without checking first. To make them pass, we skip most but also fix one by passing a file descriptor when running as a Wayland client.