Prepared winit for glutin porting

This commit is contained in:
Andrey Lesnikov 2016-10-19 19:11:02 +03:00
parent 1f170264ed
commit f5daac771e
4 changed files with 33 additions and 9 deletions

0
src/os/macos.rs Normal file → Executable file
View file

View file

@ -1,13 +1,17 @@
#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
use std::sync::Arc;
use libc;
use Window;
use platform::Window as LinuxWindow;
use WindowBuilder;
use api::x11::XConnection;
use wayland_client::protocol::wl_display::WlDisplay;
use wayland_client::protocol::wl_surface::WlSurface;
pub use api::x11;
/// Additional methods on `Window` that are specific to Unix.
pub trait WindowExt {
/// Returns a pointer to the `Window` object of xlib that is used by this window.
@ -23,8 +27,11 @@ pub trait WindowExt {
///
/// The pointer will become invalid when the glutin `Window` is destroyed.
fn get_xlib_display(&self) -> Option<*mut libc::c_void>;
fn get_xlib_screen_id(&self) -> Option<*mut libc::c_void>;
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>;
///
/// This function returns the underlying `xcb_connection_t` of an xlib `Display`.
///
/// Returns `None` if the window doesn't use xlib (if it uses wayland for example).
@ -82,6 +89,20 @@ impl WindowExt for Window {
}
}
fn get_xlib_screen_id(&self) -> Option<*mut libc::c_void> {
match self.window {
LinuxWindow::X(ref w) => Some(w.get_xlib_screen_id()),
_ => None
}
}
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>> {
match self.window {
LinuxWindow::X(ref w) => Some(w.get_xlib_xconnection()),
_ => None
}
}
fn get_xcb_connection(&self) -> Option<*mut libc::c_void> {
match self.window {
LinuxWindow::X(ref w) => Some(w.get_xcb_connection()),