nix-archive-1(type directoryentry(namesharenode(type directoryentry(namecargonode(type directoryentry(nameregistrynode(type directoryentry(namewayland-sys-0.23.6.cratenode(typeregularcontentslwayland-sys-0.23.6.crate=s6YܴTF%?ᤙ8i I>l$A )M4wbbrsi/};pp78yfGpsFޭ?pxo8_a7qbG0')>ya;Ǭ{YHDs lD|^FKl%"6wv^2K'sn/w2DqC' - t;v(_=(`Oy4@r?wt\;F}{Ә%!Kf]ؑ1q6Ax~ SwYKp3'μ [B;2;cV8g)[Da:U*`~N+=,<'|(h޼89 Xh2e`NyD?r~xɇWϞ~{y'س'_<<`f҅ڨXiħ^&!1b3% a4}wexsʃ ƞ%x L+,ȁP>_F(31Uk$,(4`:K*+v Fc

=p`Cju (6gm3HK{& z,df/E DL祥3c'm*?)1jf)GN97]Ocw  ӏH6PSթFM~{ƾswk>SW"SAc+">a~xqܿJaxOl:ˤՏ4HR6: N\^/}faD!&>>A,곸wZ*W-(U2Hp6&G٧$s%uC;51z~ӥk$Wro4;2rU(@:5 z *$F =qqhn;SLO>#qF?d1] iA /AHJaw)nDFlrRޕizi/_#034R3z2u9zӀtimCTwГwkKtL5vy QuO B VЂƗ0K1u1Bu)Spch2 `!CgOеDzޮ|Z.TZɔN%Y4'Q87&=v@*2쑡g B@g!!1;FtȀ2X8 Y?#KRK {&^"Cb IN ,! \]baP:,,YUdjY4u6N;S&yU HY3{L@iwuz |%#)H Ҷ,mHhH?0IHAef)C.,Cz<<[)ff, y[ӛ~:Ijsy B/S ;θ7%3%s+;ZWum1,\䂸3 `]ISL|&!jlp*ҒWAc|ݮ_uN:O!$jb 5cRUJ,JQX݈{D}Xs]&jТlѯX0>N1ЭKɳMRTAQ(kG"ߟ|MG(g{] C!hBp#IU>,U f>ٙ7 _*}Cp7'}r-$h:@JT9OX߃)z%rwo={]P]l{P FHN5;w3;jbP2>Eҍ0RBS-`7XހV\KXirCApx+/0 -Ӄϴ ϗR qc4<`N|>`W3?50 9%f5o<3 Pf刯L]H։MWW0u/v& >[K˛nI7.xF BR,F[5g2|3lh 3M" 3Nj)]p{Ӌg6 ؃Rll98vX  ,[T, U\s&㌁dPD( /A|^cLL( LwƣG@¹ЎmAr΢QQA4Dq] D7CMt0ª@Nޗ61+$'-2A8X6%ٓnNi!SllRl(B$/I|T|!uj78M6SJc,éWe 0kցrr;bT1f]5? Vd*5ΏBJ q# IE /@a&B`!uedWʓmܫVd~Z c7L4@ħ*sC;UЯ J͓O^<7YOX,T#Pm ҕA{]R>1M  S/ 0nb!Kua[?){oj}f;稪a}3idCN LN\17vrJ(@HFg7.VQ$jo{0:wE_:=y ?,T(F[=<5%$7B$g~\mx6_t[!XNѪ8Cxs%_&Wy#ߎ0{ jXxS.2 `Vɲ%Fm&Buc20-μL`fiȳs-\䂒ˊysky}v1 a7+/4#S\JKp9X)\%TJk #k( (=c^d*4)šբ `ZErT=*d 6Jj|3hkarus=QIuXݭJ€a\)z+c慸V3+$9k -l r<)>T@M o9O4VQ+PYX \_n]1% 7kfW5ТvC{dn( 6 CI\V57HoQ/)'JHfXd enҖsXi{&x!ڂop~Q2Q]ZlUT2SiueDz2eUYQW.Un;*TKזhgYJbF^RBV8Εvj1vwWMk5`CRA|8\\ ʢKY+$ :<ުW!*i#<E#Hn[y[޹'T%nl ώTԕӵ{Vhmҟb\E1.jw,vܟX rwNq5j\"nX9WpUueNo5R~fX)֎Y ׎ lD :H!JiZ_UG_qkxiܔl"B~` -: #*d(U0<v؇wߙU,^Y(w~V[f7di&Kjժь? .A7J'l$D |8RkYLх?{1}㑑Q`0Lr[ِ ,bIm8Un74ToX[0V-v_c$8e$^o &{_ \ Y2_BWu /RB;;8tG ݡs0:w*l?՟EE))))entry(namesrcnode(type directoryentry(namewayland-sys-0.23.6node(type directoryentry(name.cargo_vcs_info.jsonnode(typeregularcontentsJ{ "git": { "sha1": "a59359cd90e76cafd4e1920356d14ead0d0c510c" } } ))entry(name Cargo.tomlnode(typeregularcontents# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "wayland-sys" version = "0.23.6" authors = ["Victor Berger "] description = "FFI bindings to the various libwayland-*.so libraries. You should only need this crate if you are working on custom wayland protocol extensions. Look at the crate wayland-client for usable bindings." documentation = "https://smithay.github.io/wayland-rs/wayland_sys/" categories = ["external-ffi-bindings"] license = "MIT" repository = "https://github.com/smithay/wayland-rs" [package.metadata.docs.rs] all-features = true [dependencies.dlib] version = "0.4" optional = true [dependencies.lazy_static] version = "1" optional = true [dependencies.libc] version = "0.2" optional = true [features] client = ["dlib"] cursor = ["client"] dlopen = ["dlib/dlopen", "lazy_static"] egl = ["client"] server = ["libc", "dlib"] [badges.travis-ci] repository = "Smithay/wayland-rs" ))entry(nameCargo.toml.orignode(typeregularcontents~[package] name = "wayland-sys" version = "0.23.6" repository = "https://github.com/smithay/wayland-rs" documentation = "https://smithay.github.io/wayland-rs/wayland_sys/" authors = ["Victor Berger "] description = "FFI bindings to the various libwayland-*.so libraries. You should only need this crate if you are working on custom wayland protocol extensions. Look at the crate wayland-client for usable bindings." license = "MIT" categories = ["external-ffi-bindings"] [badges] travis-ci = { repository = "Smithay/wayland-rs" } [dependencies] dlib = { version = "0.4", optional = true } libc = { version = "0.2", optional = true } lazy_static = { version = "1", optional = true } [features] dlopen = ["dlib/dlopen", "lazy_static"] client = [ "dlib" ] cursor = [ "client" ] egl = [ "client" ] server = ["libc", "dlib" ] [package.metadata.docs.rs] all-features = true ))entry(namesrcnode(type directoryentry(name client.rsnode(typeregularcontents//! Bindings to the client library `libwayland-client.so` //! //! The generated handle is named `WAYLAND_CLIENT_HANDLE` #![cfg_attr(rustfmt, rustfmt_skip)] #[cfg(feature = "client")] use super::common::*; #[cfg(feature = "client")] use std::os::raw::{c_char, c_int, c_void}; pub enum wl_proxy {} pub enum wl_display {} pub enum wl_event_queue {} #[cfg(feature = "client")] external_library!(WaylandClient, "wayland-client", functions: // display creation and destruction fn wl_display_connect_to_fd(c_int) -> *mut wl_display, fn wl_display_connect(*const c_char) -> *mut wl_display, fn wl_display_disconnect(*mut wl_display) -> (), fn wl_display_get_fd(*mut wl_display) -> c_int, // display events handling fn wl_display_roundtrip(*mut wl_display) -> c_int, fn wl_display_read_events(*mut wl_display) -> c_int, fn wl_display_prepare_read(*mut wl_display) -> c_int, fn wl_display_cancel_read(*mut wl_display) -> (), fn wl_display_dispatch(*mut wl_display) -> c_int, fn wl_display_dispatch_pending(*mut wl_display) -> c_int, // error handling fn wl_display_get_error(*mut wl_display) -> c_int, fn wl_display_get_protocol_error(*mut wl_display, *mut *mut wl_interface, *mut u32) -> u32, // requests handling fn wl_display_flush(*mut wl_display) -> c_int, // event queues fn wl_event_queue_destroy(*mut wl_event_queue) -> (), fn wl_display_create_queue(*mut wl_display) -> *mut wl_event_queue, fn wl_display_roundtrip_queue(*mut wl_display, *mut wl_event_queue) -> c_int, fn wl_display_prepare_read_queue(*mut wl_display, *mut wl_event_queue) -> c_int, fn wl_display_dispatch_queue(*mut wl_display, *mut wl_event_queue) -> c_int, fn wl_display_dispatch_queue_pending(*mut wl_display, *mut wl_event_queue) -> c_int, // proxys fn wl_proxy_create(*mut wl_proxy, *const wl_interface) -> *mut wl_proxy, fn wl_proxy_destroy(*mut wl_proxy) -> (), fn wl_proxy_add_listener(*mut wl_proxy, *mut extern fn(), *mut c_void) -> c_int, fn wl_proxy_get_listener(*mut wl_proxy) -> *const c_void, fn wl_proxy_add_dispatcher(*mut wl_proxy, wl_dispatcher_func_t, *const c_void, *mut c_void) -> c_int, fn wl_proxy_marshal_array_constructor(*mut wl_proxy, u32, *mut wl_argument, *const wl_interface) -> *mut wl_proxy, fn wl_proxy_marshal_array_constructor_versioned(*mut wl_proxy, u32, *mut wl_argument, *const wl_interface, u32) -> *mut wl_proxy, fn wl_proxy_marshal_array(*mut wl_proxy, u32, *mut wl_argument ) -> (), fn wl_proxy_set_user_data(*mut wl_proxy, *mut c_void) -> (), fn wl_proxy_get_user_data(*mut wl_proxy) -> *mut c_void, fn wl_proxy_get_id(*mut wl_proxy) -> u32, fn wl_proxy_get_class(*mut wl_proxy) -> *const c_char, fn wl_proxy_set_queue(*mut wl_proxy, *mut wl_event_queue) -> (), fn wl_proxy_get_version(*mut wl_proxy) -> u32, fn wl_proxy_create_wrapper(*mut wl_proxy) -> *mut wl_proxy, fn wl_proxy_wrapper_destroy(*mut wl_proxy) -> (), // log fn wl_log_set_handler_client(wl_log_func_t) -> (), // lists fn wl_list_init(*mut wl_list) -> (), fn wl_list_insert(*mut wl_list, *mut wl_list) -> (), fn wl_list_remove(*mut wl_list) -> (), fn wl_list_length(*const wl_list) -> c_int, fn wl_list_empty(*const wl_list) -> c_int, fn wl_list_insert_list(*mut wl_list,*mut wl_list) -> (), // arrays fn wl_array_init(*mut wl_array) -> (), fn wl_array_release(*mut wl_array) -> (), fn wl_array_add(*mut wl_array,usize) -> (), fn wl_array_copy(*mut wl_array, *mut wl_array) -> (), varargs: fn wl_proxy_marshal_constructor(*mut wl_proxy, u32, *const wl_interface) -> *mut wl_proxy, fn wl_proxy_marshal_constructor_versioned(*mut wl_proxy, u32, *const wl_interface, u32) -> *mut wl_proxy, fn wl_proxy_marshal(*mut wl_proxy, u32) -> (), ); #[cfg(all(feature = "client", feature = "dlopen"))] lazy_static!( pub static ref WAYLAND_CLIENT_OPTION: Option = { // This is a workaround for Ubuntu 17.04, which doesn't have a bare symlink // for libwayland-client.so but does have it with the version numbers for // whatever reason. // // We could do some trickery with str slices but that is more trouble // than its worth let versions = ["libwayland-client.so", "libwayland-client.so.0"]; for ver in &versions { match WaylandClient::open(ver) { Ok(h) => return Some(h), Err(::dlib::DlError::NotFound) => continue, Err(::dlib::DlError::MissingSymbol(s)) => { if ::std::env::var_os("WAYLAND_RS_DEBUG").is_some() { // only print debug messages if WAYLAND_RS_DEBUG is set eprintln!("[wayland-client] Found library {} cannot be used: symbol {} is missing.", ver, s); } return None; } } } None }; pub static ref WAYLAND_CLIENT_HANDLE: &'static WaylandClient = { WAYLAND_CLIENT_OPTION.as_ref().expect("Library libwayland-client.so could not be loaded.") }; ); #[cfg(all(feature = "client", not(feature = "dlopen")))] pub fn is_lib_available() -> bool { true } #[cfg(all(feature = "client", feature = "dlopen"))] pub fn is_lib_available() -> bool { WAYLAND_CLIENT_OPTION.is_some() } ))entry(name common.rsnode(typeregularcontents//! Various types and functions that are used by both the client and the server //! libraries. use std::os::raw::{c_char, c_int, c_void}; use std::os::unix::io::RawFd; #[repr(C)] pub struct wl_message { pub name: *const c_char, pub signature: *const c_char, pub types: *const *const wl_interface, } #[repr(C)] pub struct wl_interface { pub name: *const c_char, pub version: c_int, pub request_count: c_int, pub requests: *const wl_message, pub event_count: c_int, pub events: *const wl_message, } #[repr(C)] pub struct wl_list { pub prev: *mut wl_list, pub next: *mut wl_list, } #[repr(C)] pub struct wl_array { pub size: usize, pub alloc: usize, pub data: *mut c_void, } pub type wl_fixed_t = i32; pub fn wl_fixed_to_double(f: wl_fixed_t) -> f64 { f64::from(f) / 256. } pub fn wl_fixed_from_double(d: f64) -> wl_fixed_t { (d * 256.) as i32 } pub fn wl_fixed_to_int(f: wl_fixed_t) -> i32 { f / 256 } pub fn wl_fixed_from_int(i: i32) -> wl_fixed_t { i * 256 } // must be the appropriate size // can contain i32, u32 and pointers #[repr(C)] pub union wl_argument { pub i: i32, pub u: u32, pub f: wl_fixed_t, pub s: *const c_char, pub o: *const c_void, pub n: u32, pub a: *const wl_array, pub h: RawFd, } pub type wl_dispatcher_func_t = unsafe extern "C" fn(*const c_void, *mut c_void, u32, *const wl_message, *const wl_argument) -> c_int; pub type wl_log_func_t = unsafe extern "C" fn(*const c_char, ...); ))entry(name cursor.rsnode(typeregularcontents //! Bindings to the `wayland-cursor.so` library //! //! The created handle is named `WAYLAND_CURSOR_HANDLE`. use client::wl_proxy; use std::os::raw::{c_char, c_int, c_uint}; pub enum wl_cursor_theme {} #[repr(C)] pub struct wl_cursor_image { /// actual width pub width: u32, /// actual height pub height: u32, /// hot spot x (must be inside image) pub hotspot_x: u32, /// hot spot y (must be inside image) pub hotspot_y: u32, /// animation delay to next frame pub delay: u32, } #[repr(C)] pub struct wl_cursor { pub image_count: c_uint, pub images: *mut *mut wl_cursor_image, pub name: *mut c_char, } external_library!(WaylandCursor, "wayland-cursor", functions: fn wl_cursor_theme_load(*const c_char, c_int, *mut wl_proxy) -> *mut wl_cursor_theme, fn wl_cursor_theme_destroy(*mut wl_cursor_theme) -> (), fn wl_cursor_theme_get_cursor(*mut wl_cursor_theme, *const c_char) -> *mut wl_cursor, fn wl_cursor_image_get_buffer(*mut wl_cursor_image) -> *mut wl_proxy, fn wl_cursor_frame(*mut wl_cursor, u32) -> c_int, fn wl_cursor_frame_and_duration(*mut wl_cursor, u32, *mut u32) -> c_int, ); #[cfg(feature = "dlopen")] lazy_static!( pub static ref WAYLAND_CURSOR_OPTION: Option = { // This is a workaround for Ubuntu 17.04, which doesn't have a bare symlink // for libwayland-client.so but does have it with the version numbers for // whatever reason. // // We could do some trickery with str slices but that is more trouble // than its worth let versions = ["libwayland-cursor.so", "libwayland-cursor.so.0"]; for ver in &versions { match WaylandCursor::open(ver) { Ok(h) => return Some(h), Err(::dlib::DlError::NotFound) => continue, Err(::dlib::DlError::MissingSymbol(s)) => { if ::std::env::var_os("WAYLAND_RS_DEBUG").is_some() { // only print debug messages if WAYLAND_RS_DEBUG is set eprintln!("[wayland-client] Found library {} cannot be used: symbol {} is missing.", ver, s); } return None; } } } None }; pub static ref WAYLAND_CURSOR_HANDLE: &'static WaylandCursor = { WAYLAND_CURSOR_OPTION.as_ref().expect("Library libwayland-cursor.so could not be loaded.") }; ); #[cfg(not(feature = "dlopen"))] pub fn is_lib_available() -> bool { true } #[cfg(feature = "dlopen")] pub fn is_lib_available() -> bool { WAYLAND_CURSOR_OPTION.is_some() } ))entry(nameegl.rsnode(typeregularcontentsH//! Bindings to the EGL library `libwayland-egl.so` //! //! This lib allows to create EGL surfaces out of wayland surfaces. //! //! The created handle is named `WAYLAND_EGl_HANDLE`. use client::wl_proxy; use std::os::raw::c_int; pub enum wl_egl_window {} external_library!(WaylandEgl, "wayland-egl", functions: fn wl_egl_window_create(*mut wl_proxy, c_int, c_int) -> *mut wl_egl_window, fn wl_egl_window_destroy(*mut wl_egl_window) -> (), fn wl_egl_window_resize(*mut wl_egl_window, c_int, c_int, c_int, c_int) -> (), fn wl_egl_window_get_attached_size(*mut wl_egl_window, *mut c_int, *mut c_int) -> (), ); #[cfg(feature = "dlopen")] lazy_static!( pub static ref WAYLAND_EGL_OPTION: Option = { // This is a workaround for Ubuntu 17.04, which doesn't have a bare symlink // for libwayland-client.so but does have it with the version numbers for // whatever reason. // // We could do some trickery with str slices but that is more trouble // than its worth let versions = ["libwayland-egl.so", "libwayland-egl.so.1"]; for ver in &versions { match WaylandEgl::open(ver) { Ok(h) => return Some(h), Err(::dlib::DlError::NotFound) => continue, Err(::dlib::DlError::MissingSymbol(s)) => { if ::std::env::var_os("WAYLAND_RS_DEBUG").is_some() { // only print debug messages if WAYLAND_RS_DEBUG is set eprintln!("[wayland-client] Found library {} cannot be used: symbol {} is missing.", ver, s); } return None; } } } None }; pub static ref WAYLAND_EGL_HANDLE: &'static WaylandEgl = { WAYLAND_EGL_OPTION.as_ref().expect("Library libwayland-egl.so could not be loaded.") }; ); #[cfg(not(feature = "dlopen"))] pub fn is_lib_available() -> bool { true } #[cfg(feature = "dlopen")] pub fn is_lib_available() -> bool { WAYLAND_EGL_OPTION.is_some() } ))entry(namelib.rsnode(typeregularcontents //! FFI bindings to the wayland system libraries. //! //! The names exported by this crate should *not* be used directly, but through //! the `ffi_dispatch` macro, like this: //! //! ```ignore //! ffi_dispatch!(HANDLE_NAME, func_name, arg1, arg2, arg3); //! ``` //! //! Where `HANDLE_NAME` is the name of the handle generated if the cargo feature `dlopen` is on. //! //! For this to work, you must ensure every needed symbol is in scope (aka the static handle //! if `dlopen` is on, the extern function if not). The easiest way to do this is to glob import //! the appropriate module. For example: //! //! ```ignore //! #[macro_use] extern crate wayland_sys; //! //! use wayland_sys::client::*; //! //! fn main() { //! let display_ptr = unsafe { //! ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_display_connect, ::std::ptr::null()) //! }; //! } //! ``` //! //! Each module except `common` corresponds to a system library. They all define a function named //! `is_lib_available()` which returns whether the library could be loaded. They always return true //! if the feature `dlopen` is absent, as we link against the library directly in that case. #![allow(non_camel_case_types)] // If compiling with neither the `client` or `server` feature (non-sensical but // it's what happens when running `cargo test --all` from the workspace root), // dlib isn't actually used. This is not an issue, so don't warn about it. #[allow(unused_imports)] #[cfg(any(feature = "client", feature = "server"))] #[macro_use] extern crate dlib; // Same as with dlib, only that it's a little harder to accidentally trigger // (dlopen feature enabled, client and server features disabled) #[allow(unused_imports)] #[cfg(feature = "dlopen")] #[macro_use] extern crate lazy_static; #[cfg(feature = "server")] extern crate libc; /// Magic static for wayland objects managed by wayland-client or wayland-server /// /// This static serves no purpose other than existing at a stable address. /// /// It is used internally by wayland-client, wayland-server and wayland-scanner to ensure safety /// regarding wayland objects that are created by other libraries. pub static RUST_MANAGED: u8 = 42; pub mod common; pub mod client; pub mod server; #[cfg(all(feature = "egl", feature = "client"))] pub mod egl; #[cfg(all(feature = "cursor", feature = "client"))] pub mod cursor; #[cfg(feature = "server")] pub use libc::{gid_t, pid_t, uid_t}; // Small hack while #[macro_reexport] is not stable #[cfg(feature = "dlopen")] #[macro_export] macro_rules! ffi_dispatch( ($handle: ident, $func: ident, $($arg: expr),*) => ( ($handle.$func)($($arg),*) ) ); #[cfg(not(feature = "dlopen"))] #[macro_export] macro_rules! ffi_dispatch( ($handle: ident, $func: ident, $($arg: expr),*) => ( $func($($arg),*) ) ); ))entry(name server.rsnode(typeregularcontentsO5//! Bindings to the client library `libwayland-server.so` //! //! The generated handle is named `WAYLAND_SERVER_HANDLE` #![cfg_attr(rustfmt, rustfmt_skip)] use super::common::*; #[cfg(feature = "server")] use libc::{gid_t, pid_t, uid_t}; #[cfg(feature = "server")] use std::os::raw::c_char; use std::os::raw::{c_int, c_void}; pub enum wl_client {} pub enum wl_display {} pub enum wl_event_loop {} pub enum wl_event_source {} pub enum wl_global {} pub enum wl_resource {} pub enum wl_shm_buffer {} pub type wl_event_loop_fd_func_t = unsafe extern "C" fn(c_int, u32, *mut c_void) -> c_int; pub type wl_event_loop_timer_func_t = unsafe extern "C" fn(*mut c_void) -> c_int; pub type wl_event_loop_signal_func_t = unsafe extern "C" fn(c_int, *mut c_void) -> c_int; pub type wl_event_loop_idle_func_t = unsafe extern "C" fn(*mut c_void) -> (); pub type wl_global_bind_func_t = unsafe extern "C" fn(*mut wl_client, *mut c_void, u32, u32) -> (); pub type wl_notify_func_t = unsafe extern "C" fn(*mut wl_listener, *mut c_void) -> (); pub type wl_resource_destroy_func_t = unsafe extern "C" fn(*mut wl_resource) -> (); pub type wl_display_global_filter_func_t = unsafe extern "C" fn(*const wl_client, *const wl_global, *mut c_void) -> bool; #[repr(C)] pub struct wl_listener { pub link: wl_list, pub notify: wl_notify_func_t, } #[repr(C)] pub struct wl_signal { pub listener_list: wl_list, } #[cfg(feature = "server")] external_library!(WaylandServer, "wayland-server", functions: // wl_client fn wl_client_flush(*mut wl_client) -> (), fn wl_client_destroy(*mut wl_client) -> (), fn wl_client_get_display(*mut wl_client) -> *mut wl_display, fn wl_client_get_credentials(*mut wl_client, *mut pid_t, *mut uid_t, *mut gid_t) -> (), fn wl_client_get_object(*mut wl_client, u32) -> *mut wl_resource, fn wl_client_add_destroy_listener(*mut wl_client, *mut wl_listener) -> (), fn wl_client_get_destroy_listener(*mut wl_client, wl_notify_func_t) -> *mut wl_listener, fn wl_client_post_no_memory(*mut wl_client) -> (), fn wl_resource_create(*mut wl_client, *const wl_interface, c_int, u32) -> *mut wl_resource, // wl_display fn wl_client_create(*mut wl_display, c_int) -> *mut wl_client, fn wl_display_create() -> *mut wl_display, fn wl_display_destroy(*mut wl_display) -> (), fn wl_display_destroy_clients(*mut wl_display) -> (), fn wl_display_get_serial(*mut wl_display) -> u32, fn wl_display_next_serial(*mut wl_display) -> u32, fn wl_display_add_socket(*mut wl_display, *const c_char) -> c_int, fn wl_display_add_socket_auto(*mut wl_display) -> *const c_char, fn wl_display_add_socket_fd(*mut wl_display, c_int) -> c_int, fn wl_display_add_shm_format(*mut wl_display, u32) -> *mut u32, fn wl_display_get_event_loop(*mut wl_display) -> *mut wl_event_loop, fn wl_display_terminate(*mut wl_display) -> (), fn wl_display_run(*mut wl_display) -> (), fn wl_display_flush_clients(*mut wl_display) -> (), fn wl_display_add_destroy_listener(*mut wl_display, *mut wl_listener) -> (), fn wl_display_get_destroy_listener(*mut wl_display, wl_notify_func_t) -> *mut wl_listener, fn wl_global_create(*mut wl_display, *const wl_interface, c_int, *mut c_void, wl_global_bind_func_t) -> *mut wl_global, fn wl_display_init_shm(*mut wl_display) -> c_int, fn wl_display_add_client_created_listener(*mut wl_display, *mut wl_listener) -> (), fn wl_display_set_global_filter(*mut wl_display, wl_display_global_filter_func_t, *mut c_void) -> (), // wl_event_loop fn wl_event_loop_create() -> *mut wl_event_loop, fn wl_event_loop_destroy(*mut wl_event_loop) -> (), fn wl_event_loop_add_fd(*mut wl_event_loop, c_int, u32, wl_event_loop_fd_func_t, *mut c_void) -> *mut wl_event_source, fn wl_event_loop_add_timer(*mut wl_event_loop, wl_event_loop_timer_func_t, *mut c_void) -> *mut wl_event_source, fn wl_event_loop_add_signal(*mut wl_event_loop, c_int, wl_event_loop_signal_func_t, *mut c_void) -> *mut wl_event_source, fn wl_event_loop_dispatch(*mut wl_event_loop, c_int) -> c_int, fn wl_event_loop_dispatch_idle(*mut wl_event_loop) -> (), fn wl_event_loop_add_idle(*mut wl_event_loop, wl_event_loop_idle_func_t, *mut c_void) -> *mut wl_event_source, fn wl_event_loop_get_fd(*mut wl_event_loop) -> c_int, fn wl_event_loop_add_destroy_listener(*mut wl_event_loop, *mut wl_listener) -> (), fn wl_event_loop_get_destroy_listener(*mut wl_event_loop, wl_notify_func_t) -> *mut wl_listener, // wl_event_source fn wl_event_source_fd_update(*mut wl_event_source, u32) -> c_int, fn wl_event_source_timer_update(*mut wl_event_source, c_int) -> c_int, fn wl_event_source_remove(*mut wl_event_source) -> c_int, fn wl_event_source_check(*mut wl_event_source) -> (), // wl_global fn wl_global_destroy(*mut wl_global) -> (), fn wl_global_get_user_data(*const wl_global) -> *mut c_void, // wl_resource fn wl_resource_post_event_array(*mut wl_resource, u32, *mut wl_argument) -> (), fn wl_resource_queue_event_array(*mut wl_resource, u32, *mut wl_argument) -> (), fn wl_resource_post_no_memory(*mut wl_resource) -> (), fn wl_resource_set_implementation(*mut wl_resource, *const c_void, *mut c_void, Option) -> (), fn wl_resource_set_dispatcher(*mut wl_resource, wl_dispatcher_func_t, *const c_void, *mut c_void, Option) -> (), fn wl_resource_destroy(*mut wl_resource) -> (), fn wl_resource_get_client(*mut wl_resource) -> *mut wl_client, fn wl_resource_get_id(*mut wl_resource) -> u32, fn wl_resource_get_link(*mut wl_resource) -> *mut wl_list, fn wl_resource_from_link(*mut wl_list) -> *mut wl_resource, fn wl_resource_find_for_client(*mut wl_list, *mut wl_client) -> (), fn wl_resource_set_user_data(*mut wl_resource, *mut c_void) -> (), fn wl_resource_get_user_data(*mut wl_resource) -> *mut c_void, fn wl_resource_get_version(*mut wl_resource) -> c_int, fn wl_resource_set_destructor(*mut wl_resource, Option) -> (), fn wl_resource_instance_of(*mut wl_resource, *const wl_interface, *const c_void) -> c_int, fn wl_resource_add_destroy_listener(*mut wl_resource, wl_notify_func_t) -> (), fn wl_resource_get_destroy_listener(*mut wl_resource,wl_notify_func_t) -> *mut wl_listener, // wl_shm fn wl_shm_buffer_begin_access(*mut wl_shm_buffer) -> (), fn wl_shm_buffer_end_access(*mut wl_shm_buffer) -> (), fn wl_shm_buffer_get(*mut wl_resource) -> *mut wl_shm_buffer, fn wl_shm_buffer_get_data(*mut wl_shm_buffer) -> *mut c_void, fn wl_shm_buffer_get_stride(*mut wl_shm_buffer) -> i32, fn wl_shm_buffer_get_format(*mut wl_shm_buffer) -> u32, fn wl_shm_buffer_get_width(*mut wl_shm_buffer) -> i32, fn wl_shm_buffer_get_height(*mut wl_shm_buffer) -> i32, // wl_log fn wl_log_set_handler_server(wl_log_func_t) -> (), // wl_list fn wl_list_init(*mut wl_list) -> (), fn wl_list_insert(*mut wl_list, *mut wl_list) -> (), fn wl_list_remove(*mut wl_list) -> (), fn wl_list_length(*const wl_list) -> c_int, fn wl_list_empty(*const wl_list) -> c_int, fn wl_list_insert_list(*mut wl_list,*mut wl_list) -> (), // arrays fn wl_array_init(*mut wl_array) -> (), fn wl_array_release(*mut wl_array) -> (), fn wl_array_add(*mut wl_array,usize) -> (), fn wl_array_copy(*mut wl_array, *mut wl_array) -> (), varargs: fn wl_resource_post_event(*mut wl_resource, u32) -> (), fn wl_resource_queue_event(*mut wl_resource, u32) -> (), fn wl_resource_post_error(*mut wl_resource, u32, *const c_char) -> (), ); #[cfg(all(feature = "server", feature = "dlopen"))] lazy_static!( pub static ref WAYLAND_SERVER_OPTION: Option = { // This is a workaround for Ubuntu 17.04, which doesn't have a bare symlink // for libwayland-server.so but does have it with the version numbers for // whatever reason. // // We could do some trickery with str slices but that is more trouble // than its worth let versions = ["libwayland-server.so", "libwayland-server.so.0"]; for ver in &versions { match WaylandServer::open(ver) { Ok(h) => return Some(h), Err(::dlib::DlError::NotFound) => continue, Err(::dlib::DlError::MissingSymbol(s)) => { if ::std::env::var_os("WAYLAND_RS_DEBUG").is_some() { // only print debug messages if WAYLAND_RS_DEBUG is set eprintln!("[wayland-server] Found library {} cannot be used: symbol {} is missing.", ver, s); } return None; } } } None }; pub static ref WAYLAND_SERVER_HANDLE: &'static WaylandServer = { WAYLAND_SERVER_OPTION.as_ref().expect("Library libwayland-server.so could not be loaded.") }; ); #[cfg(all(feature = "server", not(feature = "dlopen")))] pub fn is_lib_available() -> bool { true } #[cfg(all(feature = "server", feature = "dlopen"))] pub fn is_lib_available() -> bool { WAYLAND_SERVER_OPTION.is_some() } #[cfg(feature = "server")] pub mod signal { #![cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] #[cfg(not(feature = "dlopen"))] use super::{wl_list_init, wl_list_insert}; use super::{wl_listener, wl_notify_func_t, wl_signal}; #[cfg(feature = "dlopen")] use super::WAYLAND_SERVER_HANDLE as WSH; use common::wl_list; use std::os::raw::c_void; use std::ptr; // TODO: Is this really not UB ? macro_rules! offset_of( ($ty:ty, $field:ident) => { &(*(ptr::null() as *const $ty)).$field as *const _ as usize } ); macro_rules! container_of( ($ptr: expr, $container: ty, $field: ident) => { ($ptr as *mut u8).offset(-(offset_of!($container, $field) as isize)) as *mut $container } ); macro_rules! list_for_each( ($pos: ident, $head:expr, $container: ty, $field: ident, $action: block) => { let mut $pos = container_of!((*$head).next, $container, $field); while &mut (*$pos).$field as *mut _ != $head { $action; $pos = container_of!((*$pos).$field.next, $container, $field); } } ); macro_rules! list_for_each_safe( ($pos: ident, $head: expr, $container: ty, $field: ident, $action: block) => { let mut $pos = container_of!((*$head).next, $container, $field); let mut tmp = container_of!((*$pos).$field.next, $container, $field); while &mut (*$pos).$field as *mut _ != $head { $action; $pos = tmp; tmp = container_of!((*$pos).$field.next, $container, $field); } } ); pub unsafe fn wl_signal_init(signal: *mut wl_signal) { ffi_dispatch!(WSH, wl_list_init, &mut (*signal).listener_list); } pub unsafe fn wl_signal_add(signal: *mut wl_signal, listener: *mut wl_listener) { ffi_dispatch!( WSH, wl_list_insert, (*signal).listener_list.prev, &mut (*listener).link ) } pub unsafe fn wl_signal_get(signal: *mut wl_signal, notify: wl_notify_func_t) -> *mut wl_listener { list_for_each!( l, &mut (*signal).listener_list as *mut wl_list, wl_listener, link, { if (*l).notify == notify { return l; } } ); ptr::null_mut() } pub unsafe fn wl_signal_emit(signal: *mut wl_signal, data: *mut c_void) { list_for_each_safe!( l, &mut (*signal).listener_list as *mut wl_list, wl_listener, link, { ((*l).notify)(l, data); } ); } #[repr(C)] struct ListenerWithUserData { listener: wl_listener, user_data: *mut c_void } pub fn rust_listener_create(notify: wl_notify_func_t) -> *mut wl_listener { let data = Box::into_raw(Box::new(ListenerWithUserData { listener: wl_listener { link: wl_list { prev: ptr::null_mut(), next: ptr::null_mut() }, notify }, user_data: ptr::null_mut() })); unsafe { &mut (*data).listener as *mut wl_listener } } pub unsafe fn rust_listener_get_user_data(listener: *mut wl_listener) -> *mut c_void { let data = container_of!(listener, ListenerWithUserData, listener); (*data).user_data } pub unsafe fn rust_listener_set_user_data(listener: *mut wl_listener, user_data: *mut c_void) { let data = container_of!(listener, ListenerWithUserData, listener); (*data).user_data = user_data } pub unsafe fn rust_listener_destroy(listener: *mut wl_listener) { let data = container_of!(listener, ListenerWithUserData, listener); let _ = Box::from_raw(data); } } )))))))))))))