packages/minecraft/bossbar-overlay/app/crates/overlay-core is the reusable engine behind
every overlay in bossbar-overlay. It owns the mechanics every
overlay shares and none of the domain: a transparent float window, one
textured-quad wgpu pipeline with the Minecraft bitmap font baked in, gesture
disambiguation, a native context menu, headless snapshotting, and shared
animation primitives. A consumer builds a Vec<Quad> and hands it to Gpu::draw
(live window) or snapshot::render_to_png (headless PNG) (src/lib.rs:16).
window- float-window attributes and surface/adapter plumbing.gpu- the textured-quad pipeline, texture registry, and text layout.bitmap_font- the vanillaascii.pngface and its metrics.gesture- press/drag/click and scroll-drag math.menu- a native right-click context menu.snapshot- headless render-to-PNG.anim- easing curves, a hover stepper, a breathe oscillator.
Re-exports: HoverAnim, BitmapFont, DragClick, scroll_drag_delta, Gpu,
Quad, TexHandle, SHADOW, and the pinned glam/wgpu/winit
(src/lib.rs:29), so consumers name the exact versions this workspace pins.
float_attributes builds a transparent, borderless, non-resizable,
AlwaysOnTop window sized in physical pixels (window.rs:193). The desktop stays
click-through wherever no overlay window sits because there is simply no window
there to intercept the pointer. Surface helpers pick an sRGB format
(window.rs:213), a transparent alpha mode (PostMultiplied/PreMultiplied/Inherit,
warning if only Opaque is available, window.rs:224), and a FIFO config
(window.rs:244). request_adapter_device blocks once on first window
(window.rs:264).
macOS specifics (winit exposes no API for these, so they drop to AppKit through the raw window handle):
build_event_loopusesActivationPolicy::Accessoryso the HUD takes no Dock slot or app-switcher entry (window.rs:285).raise_to_frontcalls-[NSWindow orderFrontRegardless]to raise a hovered overlay above same-level siblings without taking keyboard focus (window.rs:308).enable_background_hoveradds anNSTrackingAreawithNSTrackingActiveAlwaysso a background overlay receives hover while another app is active (window.rs:349).suppress_scroll_momentuminstalls a localNSEventmonitor that drops momentum-phase scroll events, so a two-finger scroll-drag stops on lift instead of coasting (window.rs:148).move_window_with_cursorwarps the pointer withCGWarpMouseCursorPositionanchored to the just-set position, so a fast scroll-drag keeps the pointer glued to the window (window.rs:28).visible_frame_logicalreturns the screen area minus menu bar/Dock for auto-placement (window.rs:409).
Off macOS these are no-ops or defer to the compositor (X11/Wayland deliver hover
and need no non-activating raise). On wlroots Wayland the boss bar uses a separate
layer-shell backend instead of toplevel windows; see
crates/bossbar/src/layer_shell.rs:1 in overview.
One RenderPipeline draws textured quads with alpha blending (gpu.rs:161).
Vertices arrive in physical pixels with a top-left origin; the vertex stage
(src/sprite.wgsl) converts to clip space using the framebuffer size, so all
layout math stays in pixel units on the CPU, matching how Minecraft blits GUI
sprites (gpu.rs:3). The sampler is Nearest to keep pixel art crisp when
scaled (gpu.rs:206).
Quad(gpu.rs:48) is{tex, x, y, w, h, uv, color}in physical pixels;uvis(u0,v0,u1,v1)and passingu0>u1mirrors horizontally (used for the book's right page).coloris a straight-alpha RGBA tint multiplied into the texel, so the 1x1 white texture turns the tint into a flat fill (gpu.white,gpu.rs:271).Gpu::newregisters the white pixel and the embedded font sheet up front (gpu.rs:113).register_png/register_rgba/register_image_scaledadd textures and return aTexHandle(gpu.rs:276);register_image_scaledis fallible and downscales to a max side, for untrusted-ish images like avatars (gpu.rs:294).text/text_shadowemit one glyph quad per character through the same pipeline, so titles and page text are just more sprites;text_shadowdraws a one-pixel greySHADOWoffset first (gpu.rs:324,gpu.rs:339).measuresizes text without drawing (gpu.rs:354).drawexpands quads to 6 vertices each, clears the target toColor::TRANSPARENTso the desktop shows through, and draws in submission order so later quads layer over earlier ones (gpu.rs:360).
The whole text stack: no TTF, no shaper. ascii.png is a 128x128 sheet of 8x8
glyph cells indexed by code value, white-on-transparent so the per-vertex color
tints glyphs directly (bitmap_font.rs:1). BitmapFont::from_ascii_rgba
measures each glyph's inked width as the rightmost inked column + 1, the same
measurement the vanilla client makes; the space glyph's advance is pinned to 4
since it has no ink (bitmap_font.rs:58). shared() decodes the embedded
ASCII_PNG once via LazyLock so window-sizing can measure before any GPU
exists, and the live Gpu shares the same metrics (bitmap_font.rs:24). The
sheet is include_bytes!-d from assets/ascii.png, supplied by
minecraft-assets.
DragClick watches the cursor and left-button events to disambiguate a press
into a drag or a click: a press defers the decision, cursor_moved returns
true exactly once when travel crosses the threshold (hand off to
Window::drag_window), and released returns true only if the pointer never
crossed it (a click) (gesture.rs:47). scroll_drag_delta converts a winit
scroll delta into a logical-point translation; the sign is negated so the window
follows the gesture (grab-and-move), inheriting the user's scroll-direction
preference (gesture.rs:39). Trackpad PixelDelta is divided by the scale
factor; a notched wheel LineDelta steps by LINE_POINTS=16 (gesture.rs:21).
menu::popupbuilds anNSMenu, attaches a tinyNSObjecttarget, and pops it up at the pointer, blocking until the user picks or dismisses; returns the chosen index. A no-op returningNoneoff macOS (menu.rs:17).snapshot::render_to_pngruns the sameGpuagainst an offscreen texture and reads it back (handling wgpu's 256-byte row alignment) into a transparent PNG, so an always-on-top transparent window is verifiable pixel-for-pixel from a file (snapshot.rs:15). This backs every app's--snapshotflag.animholdsease_out_cubic/ease_out_back(anim.rs:17),breathe(a sine oscillator off a continuous clock,anim.rs:35),HoverAnim(a0..=1hover amount eased toward a target each frame,anim.rs:47), andscale_quads_about(scale a laid-out group in place for the hover grow,anim.rs:89). Durations and rationale live in the repoanimationskill.