#x11 #events #clipboard #windowing #graphics #dragdrop

nightly aloe-x11

The aloe-x11 crate provides an interface for the X11 windowing system in Rust, managing window creation, events, clipboard, and drag-and-drop operations. This crate is a translation of the c++ juce module serving the same function.

1 unstable release

Uses new Rust 2024

new 0.1.2 Apr 2, 2025

#88 in #windowing

31 downloads per month
Used in 24 crates (2 directly)

GPL-3.0 license

2.5MB
23K SLoC

Aloe X11 Rust Crate

Overview

The aloe-x11 crate is a sophisticated Rust library designed for interfacing with the X11 windowing system. It facilitates interaction with window properties, mouse and keyboard events, and graphical rendering using X11 APIs. Through its support for handling drag and drop operations, clipboard management, and display settings, this crate serves as an essential toolkit for developing GUI applications on X11-based systems.

Features and Functionality

  • Window Management: Create, manage, and destroy X11 windows efficiently. Provides control over window visibility, size, position, and decorations.
  • Input Management: Handle keyboard and mouse events, including motion, clicks, and key presses/releases. Supports sophisticated input scenarios with extended key codes and modifier management.
  • Drag and Drop Support: Implements X11 Drag and Drop (XDND) protocol, making it possible to handle drag and drop events seamlessly within your applications.
  • Clipboard Operations: Advanced clipboard access and management, supporting text data and interactions with the X11 clipboard selection model.
  • Visuals and Rendering: Manage display visuals and depths. Capable of rendering images to windows using both direct and shared memory techniques.
  • Synchronization with X11: Utilizes XLockDisplay and XUnlockDisplay mechanisms for RAII-style synchronization to ensure threadsafe operations with the X server.

Concepts Utilized

A background in systems programming, particularly knowledge of the X11 system, is beneficial. Concepts such as atoms in X11, visual depth management, shared memory (XShm), and device buffering (XRender) are applied throughout the implementation.

Installation

Add the following to your Cargo.toml:

[dependencies]
aloe-x11 = "0.1.0"

Usage

Example code for creating a window and handling basic mouse events:

use aloe_x11::{XWindowSystem, MouseButtons};

fn main() {
    let x11 = XWindowSystem::new();
    let window = x11.create_window(/* params */);

    // Handle mouse events
    x11.handle_button_press_event(|event| {
        match event.button {
            MouseButtons::LeftButton => println!("Left button pressed"),
            _ => println!("Other button pressed"),
        }
    });

    x11.destroy_window(window);
}

Notes

Due to the interactions with low-level system components, it is crucial for users to ensure they have the necessary permissions and configurations to access X11 from Rust. This crate assumes familiarity with Rust's ownership and concurrency models to leverage its full capabilities effectively.

Disclaimer

This README file was generated by an AI model. While it aims to provide accurate and comprehensive information regarding the aloe-x11 crate, users should verify details as necessary by consulting the crate's source code or documentation.

This crate is a translation of the JUCE module.

JUCE is a c++ software framework for developing high performance audio applications.

Usage falls under the GPLv3 as well as the JUCE commercial license.

See github.com/juce-framework/JUCE and the JUCE license page for details.

This crate is in the process of being translated from c++ to rust. For progress updates, please see the workspacer rust project. designed specifically for rust projects.

Dependencies

~29–38MB
~628K SLoC