Add get_x11_xconnection function
This commit is contained in:
parent
d4b8fd9f5a
commit
f5812018ca
3 changed files with 20 additions and 9 deletions
|
|
@ -5,6 +5,7 @@ use std::ptr;
|
|||
use libc;
|
||||
use Window;
|
||||
use platform::Window as LinuxWindow;
|
||||
use platform::{UnixBackend, UNIX_BACKEND};
|
||||
use WindowBuilder;
|
||||
use api::x11::XConnection;
|
||||
use api::x11::ffi::XVisualInfo;
|
||||
|
|
@ -14,6 +15,13 @@ use wayland_client::protocol::wl_surface::WlSurface;
|
|||
|
||||
pub use api::x11;
|
||||
|
||||
pub fn get_x11_xconnection() -> Option<Arc<XConnection>> {
|
||||
match *UNIX_BACKEND {
|
||||
UnixBackend::X(ref connec) => Some(connec.clone()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// 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.
|
||||
|
|
@ -144,21 +152,21 @@ impl WindowExt for Window {
|
|||
|
||||
/// Additional methods on `WindowBuilder` that are specific to Unix.
|
||||
pub trait WindowBuilderExt {
|
||||
fn with_visual(self, visual_infos: *const XVisualInfo) -> WindowBuilder;
|
||||
fn with_screen(self, screen_id: i32) -> WindowBuilder;
|
||||
fn with_x11_visual<T>(self, visual_infos: *const T) -> WindowBuilder;
|
||||
fn with_x11_screen(self, screen_id: i32) -> WindowBuilder;
|
||||
}
|
||||
|
||||
impl WindowBuilderExt for WindowBuilder {
|
||||
#[inline]
|
||||
fn with_visual(mut self, visual_infos: *const XVisualInfo) -> WindowBuilder {
|
||||
fn with_x11_visual<T>(mut self, visual_infos: *const T) -> WindowBuilder {
|
||||
self.platform_specific.visual_infos = Some(
|
||||
unsafe { ptr::read(visual_infos) }
|
||||
);
|
||||
unsafe { ptr::read(visual_infos as *const XVisualInfo) }
|
||||
);
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn with_screen(mut self, screen_id: i32) -> WindowBuilder {
|
||||
fn with_x11_screen(mut self, screen_id: i32) -> WindowBuilder {
|
||||
self.platform_specific.screen_id = Some(screen_id);
|
||||
self
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue