diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index dfb18341..94117303 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -584,13 +584,12 @@ impl EventLoop { } pub fn new_x11_any_thread() -> Result, XNotSupported> { - X11_BACKEND - .lock() - .as_ref() - .map(Arc::clone) - .map(x11::EventLoop::new) - .map(EventLoop::X) - .map_err(|err| err.clone()) + let xconn = match X11_BACKEND.lock().as_ref() { + Ok(xconn) => xconn.clone(), + Err(err) => return Err(err.clone()), + }; + + Ok(EventLoop::X(x11::EventLoop::new(xconn))) } #[inline]