From ffa9b51d272c5e828f7e9cedc90b1e06c8f02bf2 Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Sat, 12 May 2018 13:58:11 +0200 Subject: [PATCH] wayland: improve diagnostic of failed init (#512) --- CHANGELOG.md | 1 + Cargo.toml | 2 +- src/platform/linux/mod.rs | 5 +++-- src/platform/linux/wayland/event_loop.rs | 11 ++++------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccd2586d..f9b63fe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Unreleased - `Icon::to_cardinals` is no longer public, since it was never supposed to be. +- Wayland: improve diagnostics if initialization fails # Version 0.14.0 (2018-05-09) diff --git a/Cargo.toml b/Cargo.toml index e0984862..889fe988 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ features = [ ] [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))'.dependencies] -wayland-client = { version = "0.20.4", features = [ "dlopen", "egl", "cursor"] } +wayland-client = { version = "0.20.6", features = [ "dlopen", "egl", "cursor"] } smithay-client-toolkit = "0.2.1" x11-dl = "2.17.5" parking_lot = "0.5" diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index 85fa550a..700f3784 100644 --- a/src/platform/linux/mod.rs +++ b/src/platform/linux/mod.rs @@ -6,6 +6,8 @@ use std::ffi::CStr; use std::os::raw::*; use std::sync::Arc; +use sctk::reexports::client::ConnectError; + // `std::os::raw::c_void` and `libc::c_void` are NOT interchangeable! use libc; @@ -395,10 +397,9 @@ r#"Failed to initialize any backend! panic!(err_string); } - pub fn new_wayland() -> Result { + pub fn new_wayland() -> Result { wayland::EventsLoop::new() .map(EventsLoop::Wayland) - .ok_or(()) } pub fn new_x11() -> Result { diff --git a/src/platform/linux/wayland/event_loop.rs b/src/platform/linux/wayland/event_loop.rs index 2c02d18d..a2e3b0ab 100644 --- a/src/platform/linux/wayland/event_loop.rs +++ b/src/platform/linux/wayland/event_loop.rs @@ -10,7 +10,7 @@ use super::window::WindowStore; use sctk::Environment; use sctk::output::OutputMgr; -use sctk::reexports::client::{Display, EventQueue, GlobalEvent, Proxy}; +use sctk::reexports::client::{Display, EventQueue, GlobalEvent, Proxy, ConnectError}; use sctk::reexports::client::commons::Implementation; use sctk::reexports::client::protocol::{wl_keyboard, wl_output, wl_pointer, wl_registry, wl_seat, wl_touch}; @@ -100,11 +100,8 @@ impl EventsLoopProxy { } impl EventsLoop { - pub fn new() -> Option { - let (display, mut event_queue) = match Display::connect_to_env() { - Ok(ret) => ret, - Err(_) => return None, - }; + pub fn new() -> Result { + let (display, mut event_queue) = Display::connect_to_env()?; let sink = Arc::new(Mutex::new(EventsLoopSink::new())); let store = Arc::new(Mutex::new(WindowStore::new())); @@ -120,7 +117,7 @@ impl EventsLoop { }, ).unwrap(); - Some(EventsLoop { + Ok(EventsLoop { display: Arc::new(display), evq: RefCell::new(event_queue), sink: sink,