$ show J-x-Z/cocoa-way
Cocoa-Way is a macOS-native Wayland compositor that runs Linux GUI applications inside container runtimes (Apple Container, Docker, OrbStack, or via SSH/Waypipe) and renders them to macOS windows using Metal. The core architecture consists of a Rust binary that serves as both a desktop compositor (single window with tiled layout) and a rootless mode that maps each xdg-toplevel to a native macOS window. It features bidirectional clipboard relay (text and PNG, up to 64 MiB), CoreAudio forwarding, a control API over Unix sockets, and an optional MCP server for AI-assisted diagnostics and onboarding. The project demonstrates high craftsmanship in its Metal renderer with texture caching and damage-coalescing, as well as in its container session management, which handles multiple runtime backends and complex lifecycle orchestration. The codebase is well-structured but contains a few monolithic files (e.g., main.rs, container_mode.rs) that handle a large amount of state and UI logic.
The LLM identified 5 files worth highlighting for reuse:
Self-contained Metal renderer with texture caching, damage-aware uploads, and shader pipeline management. Demonstrates non-obvious skill in GPU programming: coalesces damaged regions, manages a texture atlas for Wayland surfaces, and uses Metal argument buffers. Could be extracted for any Metal-based compositor or screen capture renderer.
Defines a JSON-based control protocol over Unix sockets for querying and commanding the compositor (status, applications, displays, clipboard). Cleanly separated message definition with serde serialization. Reusable pattern for building local IPC control planes in any Rust application.
Manages SSH and local waypipe connections for remote displays, including SSH_ASKPASS handling via a spawned in-memory password provider. Demonstrates careful process spawning, pipe management, and error handling. The pattern of wrapping external CLI tools in a Rust API with async monitoring is reusable for any project that needs to orchestrate external processes.
Python script that tests the bidirectional clipboard relay by simulating copy/paste events and verifying round-trip consistency. Uses AppKit accessibility APIs to manipulate the macOS clipboard. Reusable as a test harness for any clipboard bridge implementation.
Bash script that runs inside a Linux container to relay clipboard contents to and from the host via a Unix socket. Uses wl-paste/wl-copy with deduplication and lock files to prevent loops. Demonstrates a robust pattern for bridging clipboard data between Wayland and a host-side compositor.