Giter Site home page Giter Site logo

xcb-wm's Introduction

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.

xcb-wm works with rust-xcb 1.x and later.

Usage

Add this to your Cargo.toml:

[dependencies]
xcb-wm = "0.3.6"

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);

xcb-wm's People

Contributors

arminfriedl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.