**GemUI** (`libgemui`) is a lightweight, zero-bloat **C11 immediate-mode UI toolkit** built directly on **X11**, **Cairo**, and **Pango/HarfBuzz**. Designed for the **ANODE** desktop environment and standalone X11 utilities, it delivers crisp fractional-DPI rendering, live `.Xresources` theming, and a compact API through a single public header (`gemui.h`).
- **Double-Buffered Cairo + Pango Rendering** — Flicker-free offscreen rendering with automatic font fallback (`theme.fontFace` + `theme.iconFontFace` via HarfBuzz/Pango) and luminance-aware dark/light text contrast on buttons.
- **Fractional DPI Scaling & Touch Mode** — Automatically scales UI geometry and typography between `0.50x` and `4.00x` using `Xft.dpi`, theme scale settings, environment overrides, or monitor EDID DPI, plus optional `1.18x` touch-friendly row sizing.
- **Live Theming with Standalone Defaults** — Ships built-in **Anodized** dark theme defaults so apps look good on any X11 desktop without configuration, while supporting live reloads from `.Xresources`, `.xth` files, `xrdb` updates, or `SIGUSR1`.
- **Non-Blocking `poll()` Event Loop** — Integrates X11 input, up to 16 custom file descriptors (sockets, pipes, IPC), a repeating millisecond timer, and signal-driven theme reloads in one simple loop.
- **Built-In Modal Open / Save File Dialog** — Embeddable overlay (or standalone one-call runner) with directory navigation, extension filters, dotfile toggle, UTF-8 filename input, overwrite confirmation, and automatic compact layout on small screens (`<= 320x360`).
- **Multi-Monitor & Fullscreen Overlays** — Supports monitor-under-pointer placement, `_NET_WORKAREA` awareness, XRandR primary-monitor geometry, and `override_redirect` fullscreen overlays with keyboard/pointer grabbing for lockscreens or launchers.
---
## Quick Start
Save the following minimal application as `main.c`:
`libgemui` loads colors, fonts, scaling, and touch sizing automatically on startup and whenever reloaded:
1.**Override file**: If `GEMUI_XRESOURCES` or `ANODE_XRESOURCES` is set to a readable file, only that file is loaded.
2.**User & live X11 resources**: Otherwise `~/.Xresources` is merged with the live X11 root resource manager (`xrdb`).
3.**ANODE fallback / built-in defaults**: If no resource database is present, `<ANODE_PREFIX>/share/anode/themes/Anodized.xth` is tried before falling back to the built-in **Anodized** dark palette.
4.**Fractional DPI scaling**: Scale (`0.50`–`4.00`) is resolved from `anode.scale` / `theme.scale`, `Xft.dpi`, `GEMUI_SCALE` / `ANODE_SCALE`, or primary screen EDID DPI. `anode.touchMode` / `theme.touchMode` enables touch-sized rows (`gemui_touch_row_px`).
5.**Live reload**: Running `xrdb -merge` or sending `SIGUSR1` (`kill -USR1 <pid>`) reloads the theme in place, triggers `handlers.on_theme`, and redraws the window.
See [docs/API.md](docs/API.md) for the full list of `.Xresources` / `.xth` theme keys and precedence rules.
---
## Repository Layout
| File | Purpose |
| :--- | :--- |
| [gemui.h](gemui.h) | Public C11 API header (types, macros, widgets, event loop, utilities, file dialog) |