From 15fbc0dff47af6c303de08e70a7773bd93c49a52 Mon Sep 17 00:00:00 2001 From: tomaka Date: Sat, 23 Sep 2017 09:36:30 +0200 Subject: [PATCH] Publish 0.8.1 with fixes necessary for glutin (#296) --- CHANGELOG.md | 5 +++++ Cargo.toml | 2 +- src/os/unix.rs | 28 ++++++++++++++++++++++++++++ src/platform/linux/mod.rs | 16 ++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ee3c700..b25adcf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Unreleased +# Version 0.8.1 (2017-09-22) + +- Added various methods to `os::linux::EventsLoopExt`, plus some hidden items necessary to make + glutin work. + # Version 0.8.0 (2017-09-21) - Added `Window::set_maximized`, `WindowAttributes::maximized` and `WindowBuilder::with_maximized`. diff --git a/Cargo.toml b/Cargo.toml index 63295f18..ee986dc0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "winit" -version = "0.8.0" +version = "0.8.1" authors = ["The winit contributors, Pierre Krieger "] description = "Cross-platform window creation library." keywords = ["windowing"] diff --git a/src/os/unix.rs b/src/os/unix.rs index 891603cb..166126e5 100644 --- a/src/os/unix.rs +++ b/src/os/unix.rs @@ -12,6 +12,10 @@ use WindowBuilder; use platform::x11::XConnection; use platform::x11::ffi::XVisualInfo; +// TODO: stupid hack so that glutin can do its work +#[doc(hidden)] +pub use platform::x11; + pub use platform::XNotSupported; /// Additional methods on `EventsLoop` that are specific to Linux. @@ -23,6 +27,15 @@ pub trait EventsLoopExt { /// Builds a new `EventsLoop` that is forced to use Wayland. fn new_wayland() -> Self where Self: Sized; + + /// True if the `EventsLoop` uses Wayland. + fn is_wayland(&self) -> bool; + + /// True if the `EventsLoop` uses X11. + fn is_x11(&self) -> bool; + + #[doc(hidden)] + fn get_xlib_xconnection(&self) -> Option>; } impl EventsLoopExt for EventsLoop { @@ -40,6 +53,21 @@ impl EventsLoopExt for EventsLoop { } } } + + #[inline] + fn is_wayland(&self) -> bool { + self.events_loop.is_wayland() + } + + #[inline] + fn is_x11(&self) -> bool { + !self.events_loop.is_wayland() + } + + #[inline] + fn get_xlib_xconnection(&self) -> Option> { + self.events_loop.x_connection().cloned() + } } /// Additional methods on `Window` that are specific to Unix. diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index d5628040..553cde80 100644 --- a/src/platform/linux/mod.rs +++ b/src/platform/linux/mod.rs @@ -382,6 +382,22 @@ impl EventsLoop { EventsLoop::X(ref mut evlp) => evlp.run_forever(callback) } } + + #[inline] + pub fn is_wayland(&self) -> bool { + match *self { + EventsLoop::Wayland(_) => true, + EventsLoop::X(_) => false, + } + } + + #[inline] + pub fn x_connection(&self) -> Option<&Arc> { + match *self { + EventsLoop::Wayland(_) => None, + EventsLoop::X(ref ev) => Some(ev.x_connection()), + } + } } impl EventsLoopProxy {