RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process
Dock implementation notes
Read when changing src/Dock.zig (its methods are in src/dock/: reveal,
items, paint, pointer, pins), src/dock_drag.zig, or their output,
taskbar, OSD and input integration. General rules remain in
AGENTS.md; integration coverage is in tests/dock.py.
The dock repaints cells, not itself (
dock/paint.zig). It keeps its last raster and, when only some items' looks changed (hover zoom, pills), clears and repaints just theiritemCells (each item at the largest hover zoom, across the dock's thickness) under a clip, publishing that damage alone. Dock-wide state (theme, scale, count, drop slot, hover zoom, active-app highlight, the backgroundDock.backgroundmakes ofdock_opacity) isbase_keyand repaints all. Draw nothing outside an item's cell without keying it inbase_key, or it goes stale.tests/dock.pycompares an animated dock with a whole repaint. The icon tooltip waitstooltip_delay_mson its own one-shot timer, re-armed only when the hovered icon changes. Icons usedrawImageSmooth(area average):drawImageCoversamples the nearest pixel and shows stair-steps at the dock's fractional downscale.Apps with multiple dock-eligible windows show a circular count in the icon's upper-right corner (including minimized windows, capped at
99+). The count is part of the item key and stays inside the icon's bounds during hover zoom. Clicking opens the compact window picker intaskbar/window_menu.zig, sharing the context menu's input routing, inward placement and auto-hide hold. It owns window IDs and title copies; detaching any listed window dismisses it throughMenu.references. Each row has a shared chrome close button; close dismisses the picker before requesting the window close, without activating the window. Keyboard and wheel navigation reach rows beyond the output. A shortcut opens it during its press: the menu input path must still balance that press'sactive_buttonson release (pins open after their release).Hover zoom keeps the screen-edge side fixed and grows toward the desktop. Its spring (
dock_hover) is underdamped:zoomRangegives the overshoot headroom that rasters, icon size and cells are sized for, so never clamp a look todock_hover_zoomitself.rasterBoxpads the painted buffer for overflow;glass_anchorkeeps the background's extent. Input uses tree-local coordinates andinput_rootcovers the expanded icons. Item cells span the expanded raster's thickness.The dock reserves space only when it doesn't auto-hide.
Output.usableBoxisdockAreaBox(output less the taskbar) lessDock.reservedStrip, a pure function of config and that box (Dock.fits), so it never flips with a lock or fullscreen window. The dock is flush with its edge ofdockAreaBoxand reserves exactly its thickness, with no extra gap before windows. The dock and the taskbar's popups/menus are placed indockAreaBox, neverusableBox. A setting that changes the strip callsapplyTaskbarPosition(Dock.reservesbefore/after). The OSD keeps clear ofDock.footprint(the resting dock, auto-hiding or not) on the bottom edge. Auto-hide fades and slides the node (reveal, opacity + position, no repaint; the glass opacity follows it too) and parks it (no rebuilds, no frames) once away; reveal/hide wait on onewltimer (Dock.pointerAtfromInput.processCursorMotion,retime).Compositor-internal drags (
dock_drag.zig: start menu app -> dock pin, and a pinned dock icon -> another place among the pins) are not wl_data_device ones: a press arms, motion past a threshold starts, and starting rebuilds the menu so its release is no click. A pinned icon acts on release (Dock.clickPin) so a drag can start from it. Closing the menu or Escape (cancelDrag; for a dock iconkeyboard/process.zigtakes it ahead of every shell panel, for a menu app before the menu's own Escape) abandons it. A dock holds resolved pins as copies (pin_arena);config_indexmaps a slot back intodock_pinned_apps, which also lists apps no longer installed.Files dropped on the dock's Trash item (
trash_drop.zig, fieldInput.trash_drop) are trashed with no question, as the desktop Trash icon does. It is adesktop_drop.Targettoo, so only a text/uri-list source that allows move can drop (a copy-only drag is refused: nothing the user meant to copy is deleted).Dock.trashAtpicks the item; the motion.dockbranch must use the grab-awarepointerNotifyClearFocuswhileseat.dragis set, or the drag stays focused on the last client and a release drops there. The URI list is read on the event loop (nonblocking fd, 5 s deadline timer, 256 KiB cap), thengio trash -- <paths>runs and the drag is finished (dnd_finish) when it exits; a failure cancels the drag and posts a notification. An auto-hiding dock reveals for a file drag (draggingFilesininput/motion.zig). Covered bytests/dock_trash_drop.py.Themed tiles (
dock_item_bg,_border,_hover_border,_bevel) replace the ghost hover button with a resting tile per item, outlined while hovered, pressed or the highlighted active app;dock_bevelcuts the dock's own corners (the glass rounds deep enough to stay inside the cut).dock_icon_greydraws icons from a desaturated copy except while lit. All of it is theme state (base_key); lit-ness comes from the button state already in each item's key.