mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 15:13:13 -04:00
Switch X11 and wayland to the new design
This commit is contained in:
@@ -162,9 +162,29 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||
|
||||
impl Window {
|
||||
pub fn new(builder: BuilderAttribs) -> Result<Window, CreationError> {
|
||||
let window = builder.window;
|
||||
let pf_reqs = builder.pf_reqs;
|
||||
let opengl = builder.opengl;
|
||||
|
||||
match *BACKEND {
|
||||
Backend::Wayland => wayland::Window::new(builder).map(Window::Wayland),
|
||||
Backend::X(ref connec) => x11::Window::new(connec, builder).map(Window::X),
|
||||
Backend::Wayland => {
|
||||
let opengl = opengl.map_sharing(|w| match w {
|
||||
&Window::Wayland(ref w) => w,
|
||||
_ => panic!() // TODO: return an error
|
||||
});
|
||||
|
||||
wayland::Window::new(&window, &pf_reqs, &opengl).map(Window::Wayland)
|
||||
},
|
||||
|
||||
Backend::X(ref connec) => {
|
||||
let opengl = opengl.map_sharing(|w| match w {
|
||||
&Window::X(ref w) => w,
|
||||
_ => panic!() // TODO: return an error
|
||||
});
|
||||
|
||||
x11::Window::new(connec, &window, &pf_reqs, &opengl).map(Window::X)
|
||||
},
|
||||
|
||||
Backend::Error(ref error) => Err(CreationError::NoBackendAvailable(Box::new(error.clone())))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user