diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index d004032b70..d418ec1e55 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -18,8 +18,9 @@ gfx = "0.17" gfx_device_gl = { version = "0.15", optional = true } gfx_window_glutin = "0.28" glutin = "0.19" -conrod_core = "0.63" -conrod_winit = "0.63" +winit = "0.18" +conrod_core = { git = "https://gitlab.com/veloren/conrod.git" } +conrod_winit = { git = "https://gitlab.com/veloren/conrod.git" } # ECS specs = "0.14" diff --git a/voxygen/src/ui/mod.rs b/voxygen/src/ui/mod.rs index 2ab107e12b..11ac492547 100644 --- a/voxygen/src/ui/mod.rs +++ b/voxygen/src/ui/mod.rs @@ -43,7 +43,23 @@ pub enum UiError { pub struct Event(Input); impl Event { pub fn try_from(event: glutin::Event, window: &glutin::GlWindow) -> Option { - conrod_winit::convert_event(event, window.window()).map(|input| { + use conrod_winit::*; + use winit; + // A wrapper around the winit window that allows us to implement the trait necessary for enabling + // the winit <-> conrod conversion functions. + struct WindowRef<'a>(&'a winit::Window); + + // Implement the `WinitWindow` trait for `WindowRef` to allow for generating compatible conversion + // functions. + impl<'a> conrod_winit::WinitWindow for WindowRef<'a> { + fn get_inner_size(&self) -> Option<(u32, u32)> { + winit::Window::get_inner_size(&self.0).map(Into::into) + } + fn hidpi_factor(&self) -> f32 { + winit::Window::get_hidpi_factor(&self.0) as _ + } + } + convert_event!(event, &WindowRef(window.window())).map(|input| { Self(input) }) }