mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 23:23:14 -04:00
Add get_x11_xconnection function
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user