rust-x-bindings / rust-xcb

Rust bindings and wrapper for XCB.
MIT License
162 stars 64 forks source link

`atoms_struct!` macro #163

Closed rtbo closed 2 years ago

rtbo commented 2 years ago

code is better than speech:

xcb::atoms_struct!(
    struct Atoms {
        wm_protocols    => b"WM_PROTOCOLS",
        wm_del_window   => b"WM_DELETE_WINDOW",
    }
);

fn main() -> xcb::Result<()> {
    // ...

    let atoms = Atoms::intern_all(&conn)?;

    conn.check_request(conn.send_request_checked(&x::ChangeProperty {
        mode: x::PropMode::Replace,
        window,
        property: atoms.wm_protocols,
        r#type: x::ATOM_ATOM,
        data: &[atoms.wm_del_window],
    }))?;

    // ...
}