Beta

gartk

UI Toolkit Library

Shared UI toolkit providing X11 window management, Cairo/Pango rendering, theming, and input handling for gardesk GUI components.

Features

  • X11 window management with x11rb
  • Cairo/Pango rendering for graphics and text
  • Type-safe color and geometry primitives
  • Event loop with input handling
  • Monitor detection via RandR
  • Keyboard and cursor management
  • Clipboard manager with X11 selection protocol
  • Dialog window support with transient/modal
  • Window activation API (EWMH _NET_ACTIVE_WINDOW)
  • Motion event coalescing and idle events
  • Theme system for consistent styling
  • Transparency and compositing support
  • XDND drag-and-drop with file path extraction
  • Modular crate architecture
  • Double-buffering for flicker-free rendering

Quick Start

What is gartk?

gartk is a modular UI toolkit library that provides X11 window management, Cairo/Pango rendering, and input handling primitives for gardesk components. It's designed as a foundation for building X11 GUI applications with Rust, offering a clean, type-safe API over x11rb, Cairo, and Pango.

The toolkit is split into three crates for modularity: gartk-core (platform-independent types), gartk-x11 (X11 integration), and gartk-render (Cairo/Pango rendering).

Installation

Add gartk crates to your Cargo.toml:

Cargo.toml
[dependencies]
gartk-core = { path = "path/to/gartk/gartk-core" }
gartk-x11 = { path = "path/to/gartk/gartk-x11" }
gartk-render = { path = "path/to/gartk/gartk-render" }

System Dependencies

gartk requires X11 development libraries and Cairo/Pango:

Install system dependencies
$ sudo pacman -S libx11 cairo pango # Arch
$ sudo apt install libx11-dev libcairo2-dev libpango1.0-dev # Ubuntu/Debian
$ sudo dnf install libX11-devel cairo-devel pango-devel # Fedora

Hello World Example

A minimal example showing window creation, rendering, and event handling:

main.rs
use gartk_core::{Color, InputEvent, Key, Rect, Theme};
use gartk_render::{Renderer, TextStyle};
use gartk_x11::{Connection, EventLoop, EventLoopConfig, Window, WindowConfig};

fn main() -> anyhow::Result<()> {
    // Connect to X11
    let conn = Connection::connect(None)?;

    // Create a window
    let window = Window::create(
        conn.clone(),
        WindowConfig::new()
            .title("Hello gartk")
            .class("hello")
            .size(400, 300)
            .centered(),
    )?;

    // Create renderer with theme
    let theme = Theme::dark();
    let mut renderer = Renderer::with_theme(400, 300, theme.clone())?;

    // Create event loop
    let config = EventLoopConfig::default();
    let mut event_loop = EventLoop::new(&window, config)?;

    // Main loop
    event_loop.run(|el, event| {
        match event {
            InputEvent::Expose => {
                // Clear and render
                renderer.clear()?;

                renderer.text_centered(
                    "Hello, gartk!",
                    Rect::new(0, 0, 400, 300).center(),
                    &TextStyle::new()
                        .font_size(24.0)
                        .color(theme.foreground),
                )?;

                // Copy to window (simplified - see docs for GC creation)
                renderer.flush();
            }

            InputEvent::Key(key_event) if key_event.key == Key::Escape => {
                el.quit();
                return Ok(false);
            }

            InputEvent::CloseRequested => {
                el.quit();
                return Ok(false);
            }

            _ => {}
        }

        Ok(true)
    })?;

    Ok(())
}

Key Features

Type-Safe X11

Built on x11rb for zero-copy event parsing and type-safe protocol handling

High-Quality Rendering

Cairo/Pango integration for antialiased graphics and advanced text layout

Built-in Theming

Dark, light, and high-contrast themes with full customization support

Modular Design

Three-crate structure allows using only what you need

ARGB Transparency

Automatic ARGB visual selection for composited transparency

RandR Support

Multi-monitor detection with DPI calculation and positioning

🚀 Who Should Use gartk?

  • • Developers building X11 GUI applications in Rust
  • • Projects needing lightweight window management without full GUI frameworks
  • • Tools requiring custom launchers, popups, or overlay UIs
  • • Applications targeting Linux desktop environments with X11
Releases
v0.3.0 Latest

gartk is a library crate - no binary RPMs available. Install via cargo or build from source.