wayland: improve diagnostic of failed init (#512)
This commit is contained in:
parent
b4a8c08f43
commit
ffa9b51d27
4 changed files with 9 additions and 10 deletions
|
|
@ -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<EventsLoop, ()> {
|
||||
pub fn new_wayland() -> Result<EventsLoop, ConnectError> {
|
||||
wayland::EventsLoop::new()
|
||||
.map(EventsLoop::Wayland)
|
||||
.ok_or(())
|
||||
}
|
||||
|
||||
pub fn new_x11() -> Result<EventsLoop, XNotSupported> {
|
||||
|
|
|
|||
|
|
@ -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<EventsLoop> {
|
||||
let (display, mut event_queue) = match Display::connect_to_env() {
|
||||
Ok(ret) => ret,
|
||||
Err(_) => return None,
|
||||
};
|
||||
pub fn new() -> Result<EventsLoop, ConnectError> {
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue