mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-03 07:10:05 -04:00
api/wayland: core context
This commit is contained in:
42
src/api/wayland/context.rs
Normal file
42
src/api/wayland/context.rs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
use wayland_client::EventIterator;
|
||||||
|
use wayland_client::wayland::get_display;
|
||||||
|
use wayland_client::wayland::compositor::WlCompositor;
|
||||||
|
use wayland_client::wayland::seat::WlSeat;
|
||||||
|
use wayland_client::wayland::shell::WlShell;
|
||||||
|
use wayland_client::wayland::shm::WlShm;
|
||||||
|
use wayland_client::wayland::subcompositor::WlSubcompositor;
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub static ref WAYLAND_CONTEXT: Option<WaylandContext> = {
|
||||||
|
WaylandContext::init()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
wayland_env!(InnerEnv,
|
||||||
|
compositor: WlCompositor,
|
||||||
|
seat: WlSeat,
|
||||||
|
shell: WlShell,
|
||||||
|
shm: WlShm,
|
||||||
|
subcompositor: WlSubcompositor
|
||||||
|
);
|
||||||
|
|
||||||
|
pub struct WaylandContext {
|
||||||
|
inner: InnerEnv,
|
||||||
|
iterator: EventIterator
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WaylandContext {
|
||||||
|
fn init() -> Option<WaylandContext> {
|
||||||
|
let display = match get_display() {
|
||||||
|
Some(display) => display,
|
||||||
|
None => return None
|
||||||
|
};
|
||||||
|
|
||||||
|
let (inner_env, iterator) = InnerEnv::init(display);
|
||||||
|
|
||||||
|
Some(WaylandContext {
|
||||||
|
inner: inner_env,
|
||||||
|
iterator: iterator
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,10 +6,11 @@ pub use self::window::{PollEventsIterator, WaitEventsIterator, Window, WindowPro
|
|||||||
extern crate wayland_kbd;
|
extern crate wayland_kbd;
|
||||||
extern crate wayland_window;
|
extern crate wayland_window;
|
||||||
|
|
||||||
|
mod context;
|
||||||
mod monitor;
|
mod monitor;
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_available() -> bool {
|
pub fn is_available() -> bool {
|
||||||
false
|
context::WAYLAND_CONTEXT.is_some()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user