use super::{xcb_change_property, xcb_connection_t, xcb_prop_mode};
use crate::is;
#[inline(always)]
pub(crate) fn change_property_u32(
conn: *mut xcb_connection_t,
win: u32,
property: u32,
type_atom: u32,
data: &[u32],
) {
let bytes =
unsafe { ::core::slice::from_raw_parts(data.as_ptr().cast::<u8>(), data.len() * 4) };
change_property_u8(conn, win, property, type_atom, 32, bytes);
}
#[inline(always)]
pub(crate) fn change_property_str(
conn: *mut xcb_connection_t,
win: u32,
property: u32,
type_atom: u32,
s: &str,
) {
change_property_u8(conn, win, property, type_atom, 8, s.as_bytes());
}
#[inline(always)]
pub(crate) fn change_property_u8(
conn: *mut xcb_connection_t,
win: u32,
property: u32,
type_atom: u32,
format: u8,
data: &[u8],
) {
debug_assert!(format == 8 || format == 16 || format == 32);
let unit = (format as usize) / 8;
let len_units = is![unit == 0, 0, data.len() as u32 / unit as u32];
unsafe {
xcb_change_property(
conn,
xcb_prop_mode::XCB_PROP_MODE_REPLACE as u8,
win,
property,
type_atom,
format,
len_units,
data.as_ptr().cast(),
);
}
}