Because the X11 manual says we must.
From man:XInitThreads(3):
The XInitThreads function initializes Xlib support for concurrent
threads. This function must be the first Xlib function
a multi-threaded program calls, and it must complete before any other
Xlib call is made.
(See also Vulkan spec section "Xlib Platform")
Fixes crash in multithreaded test:
Test case 'dEQP-EGL.functional.multithread.window'..
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
deqp-egl: xcb_io.c:165: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
Aborted (core dumped)
Change-Id: I2124be592a8d2d9036423cc2f0d71066e0e22939
XlibDisplay::XlibDisplay (EventState& eventState, const char* name)
: DisplayBase (eventState)
{
+ // From man:XinitThreads(3):
+ //
+ // The XInitThreads function initializes Xlib support for concurrent
+ // threads. This function must be the first Xlib function
+ // a multi-threaded program calls, and it must complete before any other
+ // Xlib call is made.
+ DE_CHECK_RUNTIME_ERR(XInitThreads() != 0);
m_display = XOpenDisplay((char*)name); // Won't modify argument string.
if (!m_display)
throw ResourceError("Failed to open display", name, __FILE__, __LINE__);