#![warn(missing_docs)]
#[macro_use]
extern crate bitflags;
extern crate libc;
extern crate token_store;
#[macro_use]
extern crate wayland_sys;
pub use generated::client as protocol;
pub use generated::interfaces as protocol_interfaces;
use wayland_sys::client::wl_proxy;
use wayland_sys::common::{wl_argument, wl_interface};
mod display;
mod event_queue;
mod env;
#[cfg(feature = "egl")]
pub mod egl;
#[cfg(feature = "cursor")]
pub mod cursor;
pub use display::{connect_to, default_connect, ConnectError, FatalError};
pub use env::{EnvHandler, EnvHandlerInner, EnvNotify};
pub use event_queue::{EventQueue, EventQueueHandle, ReadEventsGuard, RegisterStatus, State, StateProxy,
StateToken};
pub unsafe trait Proxy {
fn ptr(&self) -> *mut wl_proxy;
unsafe fn from_ptr_new(*mut wl_proxy) -> Self;
unsafe fn from_ptr_initialized(*mut wl_proxy) -> Self;
fn interface_ptr() -> *const wl_interface;
fn interface_name() -> &'static str;
fn supported_version() -> u32;
fn version(&self) -> u32;
fn status(&self) -> Liveness;
fn equals(&self, &Self) -> bool;
fn set_user_data(&self, ptr: *mut ());
fn get_user_data(&self) -> *mut ();
fn clone(&self) -> Option<Self>
where
Self: Sized,
{
if self.status() == Liveness::Alive {
Some(unsafe { self.clone_unchecked() })
} else {
None
}
}
unsafe fn clone_unchecked(&self) -> Self
where
Self: Sized;
}
pub unsafe trait Implementable<ID: 'static>: Proxy {
type Implementation: PartialEq + Copy + 'static;
#[doc(hidden)]
unsafe fn __dispatch_msg(&self, opcode: u32, args: *const wl_argument) -> Result<(), ()>;
}
#[derive(Debug)]
pub enum RequestResult<T> {
Sent(T),
Destroyed,
}
impl<T> RequestResult<T> {
pub fn expect(self, error: &str) -> T {
match self {
RequestResult::Sent(v) => v,
RequestResult::Destroyed => panic!("{}", error),
}
}
}
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum Liveness {
Alive,
Dead,
Unmanaged,
}
mod generated {
#![allow(dead_code, non_camel_case_types, unused_unsafe, unused_variables)]
#![allow(non_upper_case_globals, non_snake_case, unused_imports)]
#![allow(missing_docs)]
pub mod interfaces {
include!(concat!(env!("OUT_DIR"), "/wayland_interfaces.rs"));
}
pub mod client {
pub(crate) use super::interfaces;
pub(crate) use {Implementable, Liveness, Proxy, RequestResult};
pub(crate) use event_queue::EventQueueHandle;
include!(concat!(env!("OUT_DIR"), "/wayland_api.rs"));
}
}
pub mod sys {
pub use wayland_sys::client::*;
pub use wayland_sys::common::*;
}