Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
/// Establish a new connection to an X11 server.
///
/// Returns a `XCBConnection` if `allow-unsafe-code`, otherwise returns a `RustConnection`.
/// This function is meant to test code with both connection types. Production code
/// usually wants to use `x11rb::connect`, `x11rb::rust_connection::RustConnection::connect`
/// or `x11rb::xcb_ffi::XCBConnection::connect`.
pub fn connect(
dpy_name: Option<&str>,
) -> Result<(impl x11rb::connection::Connection + Send + Sync, usize), x11rb::errors::ConnectError>
{
#[cfg(feature = "allow-unsafe-code")]
{
let dpy_name = dpy_name
.map(std::ffi::CString::new)
.transpose()
.map_err(|_| x11rb::errors::DisplayParsingError::Unknown)?;
let dpy_name = dpy_name.as_deref();
x11rb::xcb_ffi::XCBConnection::connect(dpy_name)
}
#[cfg(not(feature = "allow-unsafe-code"))]
{
x11rb::rust_connection::RustConnection::connect(dpy_name)
}
}

View File

@@ -0,0 +1,55 @@
// As far as I can see, I cannot easily share code between different examples. The following code
// is used by several examples to react to the $X11RB_EXAMPLE_TIMEOUT variable. This code is
// include!()d in the examples
mod util {
use std::env;
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use x11rb::connection::Connection;
use x11rb::protocol::xproto::{
ClientMessageEvent, ConnectionExt as _, EventMask, Window,
};
pub fn start_timeout_thread<C>(conn: Arc<C>, window: Window)
where
C: Connection + Send + Sync + 'static,
{
let timeout = match env::var("X11RB_EXAMPLE_TIMEOUT")
.ok()
.and_then(|str| str.parse().ok())
{
None => return,
Some(timeout) => timeout,
};
thread::spawn(move || {
let wm_protocols = conn.intern_atom(false, b"WM_PROTOCOLS").unwrap();
let wm_delete_window = conn.intern_atom(false, b"WM_DELETE_WINDOW").unwrap();
thread::sleep(Duration::from_secs(timeout));
let event = ClientMessageEvent::new(
32,
window,
wm_protocols.reply().unwrap().atom,
[wm_delete_window.reply().unwrap().atom, 0, 0, 0, 0],
);
if let Err(err) = conn.send_event(false, window, EventMask::NO_EVENT, event) {
eprintln!("Error while sending event: {err:?}");
}
if let Err(err) = conn.send_event(
false,
window,
EventMask::SUBSTRUCTURE_REDIRECT,
event,
) {
eprintln!("Error while sending event: {err:?}");
}
conn.flush().unwrap();
});
}
}