wio: windowed i/o

Lobsters Hottest Tools

Summary

wio is a Zig platform abstraction library that handles window management, events, clipboard, audio, and graphics context creation (OpenGL, Vulkan) across Windows, macOS, Linux, Android, and WebAssembly.

<p><a href="https://lobste.rs/s/ldq5mm/wio_windowed_i_o">Comments</a></p>
Original Article
View Cached Full Text

Cached at: 06/15/26, 09:02 PM

ypsvlq/wio

Source: https://github.com/ypsvlq/wio

wio

wio is a platform abstraction library, providing:

  • window management and events
  • clipboard access
  • alert dialogs
  • joystick input
  • audio
  • software framebuffer
  • OpenGL context creation
  • Vulkan WSI

Minimal example

const std = @import("std");
const wio = @import("wio");

pub fn main(init: std.process.Init) !void {
    try wio.init(init.gpa, init.io, wio.EventQueue.eventFn, .{});
    defer wio.deinit();

    var events: wio.EventQueue = .empty;
    defer events.deinit();

    var window = try wio.Window.create(.{ .event_fn_data = &events });
    defer window.destroy();

    var framebuffer = try window.createFramebuffer(.{ .width = 1, .height = 1 });
    defer framebuffer.destroy();
    framebuffer.setPixel(0, 0, 0xF7A41D);

    while (true) {
        wio.update();
        while (events.pop()) |event| {
            switch (event) {
                .close => return,
                .draw => window.presentFramebuffer(&framebuffer),
                else => {},
            }
        }
    }
}

Getting started

wio supports the latest Zig release, but compatibility with Zig master is maintained when possible.

The public API can be browsed in src/wio.zig.

The demo directory contains a test program which covers most functionality and uses OpenGL.

The examples directory contains small programs using other rendering APIs.

By default, only a subset of the API is available. The following build options enable additional features:

  • enable_drop
  • enable_framebuffer
  • enable_opengl
  • enable_vulkan
  • enable_audio
  • enable_joystick

Platform support

Actively tested:

  • Windows
  • macOS (10.13+)
  • Linux
  • Android
  • WebAssembly

Not actively tested, but most code is shared with Linux:

  • OpenBSD
  • NetBSD
  • FreeBSD
  • DragonFlyBSD
  • illumos

Not actively tested:

  • Haiku

API support

The joystick API is not currently implemented for Android, OpenBSD, NetBSD, FreeBSD, DragonFlyBSD, or illumos.

The audio API is not currently implemented for Android, WebAssembly, NetBSD, FreeBSD, DragonFlyBSD, or illumos.

Platform notes

Windows

wio embeds an application manifest by default. To use a custom manifest, set the win32_manifest build option to false.

If drag-and-drop or audio support is enabled, wio calls OleInitialize.

macOS

An application bundle is provided in demo/wio.app, which can be adapted by changing the CFBundleExecutable and CFBundleName values in Info.plist.

Unix

messageBox is implemented by spawning kdialog or zenity.

openUri is implemented by spawning xdg-open.

Unix-like systems support different backends in the same executable. By default all backends are enabled, the unix_backends build option can be used to limit the choices.

When building a project that uses wio, passing -fsys=wio to zig build will link libraries explicitly (rather than using dlopen).

To assist with packaging your project, it is recommended to expose unix_backends in your build script and document -fsys=wio.

The following libraries are loaded for the X11 backend:

  • libX11.so.6
  • libXcursor.so.1
  • libGL.so.1 (if OpenGL is enabled)
  • libXext.so.6 (if Vulkan is enabled, as a workaround for this issue)

The following libraries are loaded for the Wayland backend:

  • libwayland-client.so.0
  • libxkbcommon.so.0
  • libdecor-0.so.0
  • libwayland-egl.so.1 (if OpenGL is enabled)
  • libEGL.so.1 (if OpenGL is enabled)

The following libraries are loaded under Linux:

  • libudev.so.1 (if joysticks are enabled)
  • libpulse.so.0 (if audio is enabled)

Android

To ensure the entry point is exported from the shared library, the root source file should contain comptime { _ = wio; } at the top level.

demo/build.zig is an example of a build script supporting Android.

WebAssembly

If OpenGL is enabled, wio imports createContext and makeContextCurrent from the gl module. WebGL 1 bindings are provided in demo/wasm.js.

glGetProcAddress always returns null.

Platform-specific API

The following variables and fields may be considered part of the public API for a given platform:

Windows

  • Window.backend.window is the Win32 HWND

macOS

  • Window.backend.window is the AppKit NSWindow

Unix

wio.backend.active is an enum variable specifying the backend in use:

.x11

  • wio.backend.x11.display is the Xlib display
  • Window.backend.x11.window is the Xlib window

.wayland

  • wio.backend.wayland.display is the Wayland wl_display
  • Window.backend.wayland.surface is the Wayland wl_surface

WebAssembly

  • Window.backend.id is the index into the JavaScript window array

Haiku

  • Window.backend.window is the InterfaceKit BWindow

Similar Articles

oioi

Product Hunt

A fast, glassy clipboard manager for macOS, Windows & Linux.

Gooey: A GPU-accelerated UI framework for Zig

Hacker News Top

Gooey is a GPU-accelerated UI framework for Zig, targeting macOS, Linux, and browser via Metal, Vulkan/Wayland, and WebGPU/WASM. It offers declarative UI, animations, theming, accessibility, and zero external dependencies.

Async I/O in Zig 0.16, today

Lobsters Hottest

Zig 0.16 ships a new std.Io interface for cross-platform I/O. The library zio provides a full async implementation using stackful coroutines and OS-level async APIs, enabling efficient concurrent tasks without thread-per-task overhead.

@wsl8297: While browsing GitHub, I stumbled upon a real powerhouse: niri. It directly bypasses the age-old desktop problem of "windows getting squished when there are too many" and completely reimagines window management. niri adopts a scrollable tiling approach: windows are arranged in columns on an "infinitely extending" horizontal strip. When you open a new window, it doesn't forcefully compress existing ones; on multi-monitor setups, each screen has its own independent workspaces and window strips, clean and efficient.

X AI KOLs Timeline

This article introduces the open-source project niri, a new Wayland-based desktop compositor that avoids traditional window crowding issues through a scrollable tiling layout, and supports features such as dynamic workspaces, independent multi-monitor management, and custom shader animations.

WSL 2 is getting faster Windows file system access

Hacker News Top

WSL 2 is receiving a performance improvement where each virtio device gets its own dedicated DMA (SWIOTLB) pool, eliminating contention on the virtiofs path for cross-OS file access between Windows and Linux. This change, merged in May 2026, is the latest in a series of incremental improvements to Windows/Linux file I/O performance in WSL 2.