Skip to content

Native indicator renderer for Linux (X11) #28

@poodle64

Description

@poodle64

Overview

Add native rendering support for Linux to match the macOS implementation. Currently Linux uses WebView fallback.

Background

Technical Approach

X11 Implementation:

  • Use x11rb crate (already a dependency for mouse tracking)
  • Create borderless override-redirect window
  • Use XRender extension for compositing/transparency
  • Blit SoftwareRenderer pixmap via XPutImage or XRender

Key Considerations:

  • X11 only (Wayland compositors don't allow arbitrary overlay positioning)
  • Detect X11 vs Wayland at runtime
  • Fall back to WebView on Wayland
  • Reuse existing SoftwareRenderer from Phase 2

Implementation Pattern

Follow the macOS pattern from src-tauri/src/recording_indicator/native.rs:

#[cfg(target_os = "linux")]
mod linux {
    use super::*;
    use x11rb::connection::Connection;
    use x11rb::protocol::xproto::*;
    
    pub struct NativeIndicator {
        conn: /* X11 connection */,
        window: Window,
        renderer: SoftwareRenderer,
        // ...
    }
}

Files to Modify

  • src-tauri/src/recording_indicator/native.rs: Add Linux implementation
  • src-tauri/src/recording_indicator.rs: Update platform checks
  • src-tauri/src/audio/preview.rs: Update platform checks
  • src-tauri/Cargo.toml: Ensure x11rb available (already is)

Acceptance Criteria

  • Native indicator works on X11-based Linux
  • Graceful fallback to WebView on Wayland
  • All three styles render correctly (pill, cursor-dot, fixed-float)
  • <1% CPU usage during recording
  • <50ms show latency

Performance Target

Match macOS metrics:

  • Zero IPC overhead (direct function calls)
  • <1% CPU usage
  • <50ms show latency

Testing

  • Test on X11 (Ubuntu 22.04, Fedora, Arch)
  • Test Wayland fallback (Ubuntu Wayland session)
  • Verify visual quality matches WebView
  • Profile CPU/memory usage

Dependencies

References

Notes

  • Windows implementation not planned (WebView works well enough)
  • Wayland cannot support arbitrary overlay positioning (compositor restriction)
  • Linux users on Wayland will use WebView fallback (expected limitation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions