#wayland #client


Bindings to libwayland-cursor

49 releases

0.31.0 Sep 2, 2023
0.30.0 Dec 27, 2022
0.30.0-beta.13 Nov 4, 2022
0.30.0-beta.8 Jul 15, 2022
0.24.0 Sep 14, 2019

#506 in GUI

Download history 42687/week @ 2023-08-13 39763/week @ 2023-08-20 38594/week @ 2023-08-27 43013/week @ 2023-09-03 42343/week @ 2023-09-10 40981/week @ 2023-09-17 42735/week @ 2023-09-24 48935/week @ 2023-10-01 48441/week @ 2023-10-08 69032/week @ 2023-10-15 61098/week @ 2023-10-22 72095/week @ 2023-10-29 64074/week @ 2023-11-05 72311/week @ 2023-11-12 64885/week @ 2023-11-19 66824/week @ 2023-11-26

273,091 downloads per month
Used in 331 crates (4 directly)

MIT license


crates.io docs.rs Continuous Integration codecov


Loading of XCursor images for Wayland client apps. This crate provides helpers to load the system provided cursor images and load them into WlBuffers as well as obtain the necessary metadata to properly display animated cursors.


Wayland cursor utilities

This crate aims to re-implement the functionality of the libwayland-cursor library in Rust.

It allows you to load cursors from the system and display them correctly.

First of all, you need to create a CursorTheme, which represents the full cursor theme.

From this theme, using the get_cursor() method, you can load a specific Cursor, which can contain several images if the cursor is animated. It also provides you with the means of querying which frame of the animation should be displayed at what time, as well as handles to the buffers containing these frames, to attach them to a wayland surface.


use wayland_cursor::CursorTheme;
// Load the default cursor theme.
let mut cursor_theme = CursorTheme::load(&connection, shm, 32)
    .expect("Could not load cursor theme");
let cursor = cursor_theme.get_cursor("wait")
    .expect("Cursor not provided by theme");

let start_time = Instant::now();
loop {
    // Obtain which frame we should show, and for how long.
    let millis = start_time.elapsed().as_millis();
    let fr_info = cursor.frame_and_duration(millis as u32);

    // Here, we obtain the right cursor frame...
    let buffer = &cursor[fr_info.frame_index];
    // and attach it to a wl_surface.
    cursor_surface.attach(Some(&buffer), 0, 0);

    sleep(Duration::from_millis(fr_info.frame_duration as u64));


~128K SLoC