Skip to content

KarpelesLab/x11anywhere

Repository files navigation

X11Anywhere

A portable X11 server implementation in Rust with modular backend support.

Overview

X11Anywhere is an X11 display server that can run on Linux, macOS, and Windows. It accepts X11 protocol connections from clients and translates them to native display systems through a pluggable backend architecture.

Key Features

  • Portable: Runs on Linux, macOS, and Windows
  • Modular Backends: Choose your display system (X11, Wayland, macOS native, Windows native)
  • Security-Focused: Built-in isolation and security features to protect the host
  • Minimal Dependencies: Lightweight with minimal external dependencies
  • Protocol Compliant: Implements the X11 core protocol

Screenshots

Visual test output showing X11 drawing operations on all supported platforms:

Linux macOS Windows
Linux macOS Windows

Screenshots are automatically updated by CI after each push to master.

Architecture

X11 Clients (TCP/Unix Socket)
    ↓
Connection Layer
    ↓
Protocol Parser/Encoder
    ↓
Core Server (Window Tree, Resources, Events)
    ↓
Security/Isolation Layer
    ↓
Backend Abstraction
    ↓
┌──────┬─────────┬────────┬─────────┐
X11    Wayland   macOS    Windows

See ARCHITECTURE.md for detailed design documentation.

Building

Quick Start

By default, the appropriate backends for your platform are automatically enabled:

# Build with platform defaults (recommended)
cargo build

# On Linux/BSD: builds with X11 + Wayland backends
# On macOS: builds with macOS native backend
# On Windows: builds with Windows native backend

Platform Defaults

The build system automatically enables the right backends:

  • Linux/BSD: X11 + Wayland backends (both useful on modern Linux)
  • macOS: macOS native backend (Cocoa/Quartz)
  • Windows: Windows native backend (Win32)

Custom Builds

Build with specific backends only:

# X11 only (minimal Unix build)
cargo build --no-default-features --features backend-x11

# Wayland only
cargo build --no-default-features --features backend-wayland

# Minimal builds with convenience features
cargo build --no-default-features --features minimal-x11
cargo build --no-default-features --features minimal-wayland

Cross-Platform Development

You can explicitly enable backends for testing:

# Enable X11 on macOS (requires XQuartz installed)
cargo build --features backend-x11

# Test multiple backends during development
cargo build --features backend-x11,backend-wayland

Usage

Basic Usage

# Auto-detect backend
x11anywhere -display 1

# Specify backend explicitly
x11anywhere -display 1 -backend x11

# Enable TCP listening
x11anywhere -display 1 -backend wayland -tcp

Security Levels

# Permissive (for testing)
x11anywhere -display 1 -security permissive

# Default (recommended)
x11anywhere -display 1 -security default

# Strict (maximum security)
x11anywhere -display 1 -security strict

Command Line Options

  • -display <n> - Display number (default: 1)
  • -backend <type> - Backend type (x11, wayland, macos, windows)
  • -tcp - Listen on TCP socket (port 6000 + display)
  • -unix - Listen on Unix socket (default on Unix)
  • -security <level> - Security level (permissive, default, strict)
  • -list-backends - List available backends
  • -h, --help - Show help

Security Features

X11Anywhere includes several security features:

  • Window Isolation: Clients can only see their own windows by default
  • Property Protection: Restrict property access between clients
  • Selection Control: Mediate clipboard/selection access
  • Grab Restrictions: Limit keyboard/pointer grabs
  • Resource Limits: Prevent resource exhaustion

Configure these with the -security flag or via config file.

Use Cases

1. Running X11 Apps on macOS/Windows

Run Linux X11 applications natively on macOS or Windows without a full X11 server like XQuartz:

# On macOS
x11anywhere -display 1 -backend macos

# On Windows
x11anywhere -display 1 -backend windows

# Then set DISPLAY and run your app
export DISPLAY=:1
xterm

2. Nested X Server (Testing/Development)

Run a nested X server on Linux for testing:

x11anywhere -display 2 -backend x11
DISPLAY=:2 xclock

3. Wayland Bridge

Run X11 apps on Wayland with better integration:

x11anywhere -display 1 -backend wayland

4. Security Sandboxing

Run untrusted X11 applications in isolation:

x11anywhere -display 99 -security strict
DISPLAY=:99 untrusted-app

Development Status

This project has completed its core implementation across all major platforms:

Implemented Features ✅

Core Protocol

  • ✅ Connection setup and authentication
  • ✅ Window operations (Create, Map, Unmap, Destroy, Configure, Raise, Lower)
  • ✅ Graphics contexts (Create, Change, Free)
  • ✅ All drawing operations (rectangles, lines, points, arcs, polygons, text)
  • ✅ Image operations (PutImage, GetImage)
  • ✅ Pixmap support (off-screen drawables)
  • ✅ Event handling (Expose, Configure, Key, Button, Motion, Focus, Enter/Leave)

Resources

  • ✅ Properties and atoms (InternAtom, GetAtomName, ChangeProperty, GetProperty)
  • ✅ Selections/clipboard (SetSelectionOwner, GetSelectionOwner, ConvertSelection)
  • ✅ Fonts (OpenFont, CloseFont, QueryFont, ListFonts)
  • ✅ Colors (AllocColor, AllocNamedColor with 70+ named colors)
  • ✅ Cursors (standard system cursors)

Backends

  • X11 Backend (Linux/BSD) - Full passthrough to native X11
  • Windows Backend - Complete Win32/GDI implementation
  • macOS Backend - Full Cocoa/Core Graphics via Swift FFI

Roadmap

Phase 1: Core Window Management ✅ COMPLETED

Phase 2: Basic Drawing ✅ COMPLETED

Phase 3: Advanced Features ✅ COMPLETED

  • Enhanced event handling, arc/polygon drawing, image operations
  • Cursor support, window properties, selections, fonts, colors

Phase 4: Optimization & Testing (Current)

  • Performance profiling
  • Comprehensive testing with various X11 applications
  • Bug fixes and edge cases
  • Documentation improvements

Phase 5: Wayland Support

  • Research and design Wayland backend
  • Implement basic Wayland support

Future: X11 Extensions

  • RENDER (alpha blending)
  • XFIXES
  • DAMAGE
  • COMPOSITE

Contributing

Contributions are welcome! Areas where help is needed:

  • Testing with real X11 applications (xclock, xterm, xeyes, etc.)
  • Wayland backend implementation
  • X11 extension support (RENDER, XFIXES, etc.)
  • Documentation and examples
  • Performance optimization
  • Bug reports and fixes

License

Licensed under either of:

at your option.

References

Acknowledgments

This project is inspired by:

  • XQuartz - X11 for macOS
  • Xwayland - X11 compatibility for Wayland
  • Xephyr - Nested X server
  • TigerVNC - VNC server with X11 support

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •