Consume events in a thread to prevent Wayland's event buffer from overflowing and closing the connection.
Details:
- This is a workaround for a known bug in Wayland [0]. Threaded event handling has been if-defed so it can be removed when it's no longer needed.
- GTK & QT use threaded event handling to avoid this problem (SDL on the other hand doesn't).
- The complexity and number of locks needed to handle events in a separate thread is a significant down-side, but as far as I can see this is necessary.
- Re-connecting to the server is possible but not practical as the OpenGL context is lost and as far as I can tell it's not possible to keep it active (see: D16492).
[0]: https://gitlab.freedesktop.org/wayland/wayland/-/issues/159