Tiny-wlhs, a hybrid haskell and C Wayland compositor

Tiny-wlhs: A Haskell-Driven Wayland Compositor (Seeking Contributors!)

This thread originated in the Haskell Wlroots Bindings discussion.

Introduction

tiny-wlhs began as an experiment to explore Haskell bindings for wlroots. We took the simple tinywl C compositor and turned it into a Haskell-controlled shared library. This approach lets us incrementally port C code to Haskell while keeping a working window manager. The immediate feedback from a functional compositor is invaluable during development and provides something solid to work with. You can find the project on GitHub: https://github.com/l-Shane-l/tiny-wlhs

tiny-wlhs currently creates a Wayland window and serves as a platform for testing future Wayland bindings. A pure Haskell compositor presents some key challenges and is an eventual goal but first we need robust bindings for wlroots and, crucially, a Haskell equivalent of the Wayland scanner (which converts Wayland protocols from XML to C).

Motivation: Towards a Haskell Wayland Daily Driver

While waiting for bindings and a scanner there is interest in a usable, Haskell-based Wayland compositor—a daily driver that we can use and refine every day. While work on bindings and a scanner continues, tiny-wlhs provides a valuable stepping stone with the following benefits:

  1. Hands-on Learning: Building a compositor is the best way to learn Wayland.
  2. Identifying Needs: A Haskell-based compositor clarifies the requirements for a pure Haskell implementation.
  3. Top-Down Approach: Starting with a working example and iteratively improving it is a lot easier than building from scratch.

Our primary goal is to make tiny-wlhs a practical daily driver. We’ll gradually port C components to Haskell, paving the way for a future pure Haskell version. This will require careful API design. tiny-wlhs is also a tool for developing and testing Haskell wlroots bindings and a Haskell-based Wayland scanner.

Why a Hybrid Approach?

Creating complete Haskell wlroots bindings and a Wayland scanner is a monumental task. wlroots is a large and complex C library. Building a Haskell Wayland scanner is equally challenging. Our hybrid approach allows us to make progress now with a functional compositor, learning as we go and using tiny-wlhs as a testbed for future pure Haskell solutions. The project uses nix so it should be quite fast to get started.

Next Steps and Features

tiny-wlhs currently has the same features as tinywl (tinywl documentation). We’re looking to add:

  1. Core Functionality: Start/stop server, server configuration.
  2. Output Management: List outputs, basic configuration.
  3. Window Management: Tiling, resizing, moving, focus, closing, fullscreen.
  4. Input Handling: Keyboard and mouse bindings.
  5. Application Launching: Spawning applications.
  6. Compositor Features: Basic decorations.
  7. Inter-Client Communication (Future): Advanced Wayland protocols.

Get Involved!

  • Feature Development: Build the features you want.
  • Haskell FFI: Improve the Haskell/C interface.
  • Create Wlroots bindings: Create and contribute wayland bindings
  • Wayland/Wlroots: Port C code to Haskell.
  • Build Systems: Enhance the build process.
  • Haskell GUI Libraries: Design the Haskell API.
  • Join the discussion: Contribute to everything from project naming to project managment

Collaboration

This thread is for updates and discussions. We may create a dedicated communication channel (Discord, Matrix, IRC - let us know your preference!). Documentation and project details are open for discussion.

Try building and running tiny-wlhs! Report any issues on GitHub. Create branches for development. We’re excited about this project and invite you to join us!

13 Likes