Rust implementation of xcb-wm - icccm and ewmh extensions for xcb
Find a file
2022-06-03 11:33:34 +02:00
src Add ICCCM WM_HINTS 2022-06-03 11:33:34 +02:00
.gitignore Beginning of rust-xcb-wm 2022-05-08 18:20:07 +02:00
Cargo.toml Add ICCCM WM_NORMAL_HINTS 2022-06-03 06:59:43 +02:00
LICENSE Initial commit 2022-05-08 14:29:54 +00:00
README.md Consistent naming for set and send, readme 2022-05-22 20:03:08 +02:00

xcb-wm

The long lost Rust implementation of the icccm and ewmh extensions for the X Window System protocol.

xcb-wm provides type safe and Rust-native abstractions. It simplifies the usage of window manager extensions to X11.

xcb-wm sits on top of rust-xcb similar to how libxcb-wm sits on top of libxcb. If you are already using rust-xcb you are also familiar with xcb-wm. The public APIs and general usage are intentionally close.

Usage

Add this to your Cargo.toml:

[dependencies]
xcb-wm = "0.2.0"

Each request is either a Get*, a Set* or a Send* struct. Get* structs can be used to get ewmh or iccm properties. Set* structs can be used to set properties. Send* structs can be used to send client messages. You can read up on the protocol definitions for more details but in general every property has a corresponding Get* request. Set* requests are mostly useful before a window is mapped. Send* requests for everything else.

Each request can be sent either checked or unchecked. This is typesafe by special cookies for each of them. You get the request cookie by calling send_request/send_request_unchecked.

You can retrieve a reply and wrap it into a high level and meaningful Rust struct by calling wait_for_reply/wait_for_reply_unchecked on the cookie. For requests that don't have a reply (i.e. Set* and Send* requests) you can use check_request to check for errors.

Examples

Get the names of available desktops:

use xcb;
use xcb_wm::ewmh;

// Create a `rust-xcb` connection
let xcb_con = xcb::Connection::connect(Option::None).unwrap().0;

// Wrap the connection in an `xcb-wm::ewmh` connection for ewmh extensions.
// 
// Note that this does not take ownership of the `rust-xcb` connection
// so you can continue to use other xcb functionality with the same
// connection.
let ewmh_con = ewmh::Connection::connect(&xcb_con);

// Create a request for the _NET_DESKTOP_NAMES property
let request = ewmh::proto::GetDesktopNames;
let cookie = ewmh_con.send_request(&request);

// Get a `GetDesktopNamesReply` reply
//
// Replies are automatically de-serialized into meaningful Rust structs. You
// take full ownership of the reply struct.
let reply = ewmh_con.wait_for_reply(cookie);

// All replies implement `Debug` so you can also print them
println!("{:?}", reply);