Skip to content

Settings: themes can blur the sidebar, panel, composer, headers, menus and dialogs; shaders get iMouse (#464) - #472

Open
MopigamesYT wants to merge 2 commits into
devfrom
feat/464-theme-blur
Open

MopigamesYT wants to merge 2 commits into
devfrom
feat/464-theme-blur

Conversation

@MopigamesYT

Copy link
Copy Markdown
Member

Part of #464

Summary

  • Blurred elements in themes: a theme file's [blur] table gives a blur radius (0–64) to sidebar, panel (side/tool panel), composer, headers (split-pane headers), menus and dialogs. What is behind them (the shader or picture background, or the window behind a menu/dialog) shows through really blurred on the GPU. [blur_tint] sets the translucent colour laid over the blur (#rrggbbaa). If you leave it out, the element uses its own colour at 60 % (menus 50 %, dialogs 88 %).
  • The blur follows the corners (roundness), works over dark and light bases, reloads when the file is saved, and bad values show the same red error as other theme keys (blur.sidebar: 65 is outside 0 to 64, unknown element, bad tint).
  • On Mesa's CPU renderer (llvmpipe, the Windows fallback of Windows without OpenGL: Mesa inside 1loop.exe, nothing to download #416) or GL older than 3.0, the blur turns itself off: elements stay opaque, and menus/dialogs keep 1loop's CPU frosted glass.
  • Shader mouse uniforms (extra request): vec4 iMouse works like Shadertoy's, but xy follows the pointer even with no button held. Positions are in gl_FragCoord pixels from the bottom left. zw is the last press, and z turns negative after release. Positions are raw (not eased) and stay where the pointer left the window. float u_mouse_inside is 1 while the pointer is over the window. The shader is redrawn on pointer moves only if it actually uses these uniforms (checked against the compiled program), so other shaders cost nothing extra. aurora.frag now glows around the pointer, and aurora.toml uses blur.
  • Documented in docs/THEMES.md (new ### blur section, uniforms table) and in the New theme template. The agent's settings tool already points to docs/THEMES.md.
  • Follow-up, not in this PR: whole-window blur-behind through the compositor (KDE / Wayland blur protocol). It's listed under "Not there yet".

Screenshots

Real captures from the app (taken in-process on a GPU, Wayland/niri). The same Aurora theme with and without [blur]:

Before After
Before: Aurora theme without [blur] After: Aurora with [blur] sidebar and composer
Before: menu with 1loop's CPU frosted glass After: menu with live GPU blur

These "after" shots use a #0c0c0c80 sidebar tint, which turned out too light for muted text. The committed aurora.toml uses darker tints (b8–c8).

iMouse on the linux-test VM (KDE Wayland, llvmpipe, so blur is off there as intended), with the pointer moved by ydotool: the highlight follows it.

Pointer upper left Pointer lower right
iMouse: pointer at upper left (VM, llvmpipe, blur off) iMouse: pointer at lower right (VM, llvmpipe, blur off)

Technical details

  • third_party/fyne/canvas/blur.go: canvas.Blur, a backdrop-filter object. Fyne paints in tree order, so when the blur is painted, everything behind it is already in the framebuffer.
  • third_party/fyne/internal/painter/gl/blur.go: copies the region (plus 1.5× the radius as padding) with glCopyTexSubImage2D, then runs dual Kawase: 1–6 downsample passes into FBO textures at half size each, then upsample passes. The last upsample is drawn into the frame with a rounded-rect SDF mask (per-corner radii). The painter now remembers its scissor clip and viewport so it can restore them. FBO/GetString calls are only on the desktop GL and GLES contexts (blur_gl_core.go, blur_gl_es.go). wasm/gomobile draw nothing for it. blurUsable rejects llvmpipe/softpipe/swrast/SwiftShader/GDI Generic and GL < 3 (unit test). The first failure calls canvas.SetBlurUnsupported and the UI drops back to opaque.
  • internal/ui/theme_blur.go: blurBehind(element, fill, token) wraps the long-lived backgrounds (sidebar, pane header, tool panel card, composer card). It syncs after every theme apply, after the recolouring pass. Sheets (menus/dialogs) get a live blur: under the panel for a menu, the whole window (then dimmed) for a dialog. When it's on, the one-shot CPU frost capture is skipped.
  • Cost: the blur only runs when Fyne redraws. A still window costs nothing, so there's no separate cache.
  • Mouse: desktop.OnPointer (GLFW cursor pos/button/leave callbacks) and canvas.Shader.Watch/Uses (glGetUniformLocation != -1 after linking).

Frame time

ONELOOP_BENCH=idle (10 s, aurora shader animating at 30 fps, so every frame repaints the blur). GPU machine, paint is the CPU time of the paint call:

paint p50 paint p90 present p50 CPU
without [blur] (2 runs) 0.29 / 0.32 ms 0.50 / 0.61 ms 0.22 / 0.25 ms 6.2 / 5.1 %
with [blur] sidebar+panel+composer (2 runs) 0.51 / 0.63 ms 0.75 / 0.78 ms 0.26 / 1.5 ms 4.9 / 6.5 %

So about +0.25 ms of paint per frame with three blurred elements. Present (where the GPU work shows) moves between runs.

Tests

go build ./..., go vet (ui, palette, fyne gl/canvas/desktop), go test ./internal/palette ./internal/ui (the known flaky worktrees.go crash showed up once and passed on rerun), go test of fyne's internal/painter/gl (new TestBlurUsable), plus GLES and wasm builds of the painter. Settings are untouched.

Not verified

  • Blur with dialogs on a real GPU (menus verified, dialogs only by code path), and the panel/headers elements on screen (they use the same wrapper as the sidebar).
  • Windows (Mesa fallback inferred from the renderer string check, not run), macOS, and the GLES build at runtime.
  • Light base themes with blur (only the dark Aurora was captured).

Assisted-by: Claude Opus 5.5 low

🤖 Generated with Claude Code

…ders, menus and dialogs (#464)

A theme file's [blur] gives these elements a blur radius and [blur_tint]
the translucent colour over it. third_party/fyne gains canvas.Blur: the
GL painter copies what is already drawn under it, blurs it with dual
Kawase passes in framebuffer objects and draws it back clipped to the
element's rounded corners. Off on CPU renderers and GL older than 3.0,
where the elements keep their opaque look.
…side (#464)

iMouse is the pointer in gl_FragCoord's pixels (xy) and the last press
(zw, z negative once released), raw, kept where the pointer left the
window; u_mouse_inside says whether it is over the window. The shader is
drawn again on a move only when it uses them (desktop.OnPointer and
canvas.Shader.Uses in third_party/fyne). aurora.frag glows around it.
@MopigamesYT

Copy link
Copy Markdown
Member Author

Blur measured on this branch for the performance audit, all six elements over the aurora shader on a virgl VM: the idle frame goes from 6.1 to 12.5 ms p50 (+16 % of a core) as soon as a radius is set, and barely changes from 8 to 32. Numbers and targets are in #474 (docs/perf/2026-11-audit.md): the blurred copy should be shared across elements, downsampled, and kept while the background is still.

@MopigamesYT

Copy link
Copy Markdown
Member Author

Heads-up from testing the open PRs merged together: this PR and #478 both change internal/ui/desktop.go, and they conflict there. Each merges cleanly onto dev on its own, so whichever merges second will need a rebase on dev.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Desktop app (Linux, Windows) enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants