hw: fix crash when running on Wayland with X11 backend compiled

https://bugzilla.gnome.org/show_bug.cgi?id=707406