Skip to content

feat(desktop): transparent panels sized to their content - #582

Merged
houko merged 2 commits into
mainfrom
feat/transparent-panels
Nov 17, 2026
Merged

houko merged 2 commits into
mainfrom
feat/transparent-panels

Conversation

@houko

@houko houko commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #315.

PanelOptions.Transparent opens a panel with no background, frame or shadow of its own, so a popup card can draw its own rounded corners and BoxShadow. PanelOptions.FitContent sizes the panel to its content, up to Width and Height, and follows the content as it grows and shrinks.

  • Transparent: a borderless clear NSPanel without a shadow on macOS; on Windows and Linux a panel goes through what transparent windows (feat(desktop): transparent, shadowless windows off the taskbar #581) already use: DirectComposition with alpha and DWM's bare frame (square corners, no shadow) on Windows, and the window's nsgo-transparent CSS class on Linux, applied only where GDK's display composites with an RGBA visual. One transparent field per surface on each backend and one SurfaceConfig.Transparent meaning for windows and panels.
  • Env.WindowTransparent, read through desktop.Transparent, reports whether the scope's window or panel draws nothing of its own now: a transparent panel, and a window opened with WindowOptions.Transparent or nsgo.WindowTransparent() or made so by desktop.SetWindowTransparent, where the platform could. desktop.CanMakeWindowsTransparent (feat(desktop): transparent, shadowless windows off the taskbar #581) is the capability, whether a window could be; desktop.Transparent is the state, false once a window is framed again, on Windows without DirectComposition and on Linux while the display does not composite. nsgotest's headless desktop reports it for a window or panel opened Transparent and for a window SetWindowTransparent changes, as a compositing desktop does.
  • FitContent: the core lays the panel's root out as an overlay sizes and sends the size as one driver.WindowFitSize ahead of the commit's other window commands (the last one when a commit lays out more than once), so the panel first shows at its content's size. The platforms keep the top edge, or place a panel shown beside its ShowAt rectangle or tray icon again.
  • Docs (architecture, public en/zh services), roadmap and CHANGELOG updated.

Targets

  • macOS: implemented, compiled and vetted; run by hand with a throwaway example (screenshots below).
  • Windows: implemented, only cross-compiled and vetted; not run (no Windows machine).
  • Linux: implemented, compiled and vetted; the GTK backend tests pass under Xvfb (X11, no compositor), but a transparent panel has not been seen on a compositing desktop.
  • Shared core and nsgotest: tested.

Screenshots

Before: an opaque 380x520 panel with its system frame and shadow, the card sitting in a large white block.

Before: opaque panel with system frame

After: a Transparent + FitContent panel showing only the rounded card and its own shadow on a transparent background; the window measured 380x148.

After: transparent panel fitted to the card

Verification

Remote runs; all exit 0 unless noted.

  • ubuild mise exec [email protected] -- go tool nsgo test -run 'Panel|TestWindow|TestTray|Environment' ./core: 21 passed, including TestPanelFitsContent and TestTransparentPanel.
  • ubuild ... go tool nsgo test ./core: 664 passed. ./desktop: 1 passed. ./internal/driver: 133 passed. ./internal/engine: 40 passed. ./internal/moduletest: 9 passed (includes skills_test, which checks the names the skill mentions).
  • ubuild ... go tool nsgo check -target windows_x64, -target linux_x64, -target macos_arm64 and -target web: all exit 0.
  • ubuild ... go tool nsgo check -target all: exit 0, with a warning that it skipped ios, ios_simulator, tvos, tvos_simulator, watchos and watchos_simulator because they need macOS with Xcode.
  • rbuild mise exec [email protected] -- go tool nsgo test -target macos -run 'Material|Mount|Quit' ./internal/platform/macos: 2 passed.
  • rbuild ... go tool nsgo test ./internal/platform/macos: 51 passed, 3 skipped.
  • After rebasing onto origin/main (49f2856): ubuild ... go tool nsgo test ./core (664 passed), the two new tests by name (pass), and check -target windows_x64, linux_x64 and macos_arm64 (all exit 0).
  • macOS by hand: a throwaway example built on the Studio and pulled back (rbuild --pull cardshot -- env CGO_ENABLED=0 mise exec [email protected] -- go build ...), run locally in a before and an after mode, quitting itself after about 10 seconds. The panel windows measured 380x520 (before) and 380x148 (after, the card's size), read from CGWindowList. The example and binary were not committed.
  • gofmt: every file touched is clean. Files on main that gofmt already flags were left alone: core/access.go, core/notifications_test.go, internal/driver/animator.go, internal/driver/svg.go, internal/platform/macos/material_test.go, internal/platform/windows/paint.go, logic_test.go and permissions.go.

After review fixes:

  • ubuild, targeted tests, all pass: go tool nsgo test ./core -- -run 'TestPanelFitsContent|TestTransparentPanel|TestPanelPlacement' and go tool nsgo test ./nsgotest -- -run 'TestTransparentPanelReportsIt|TestStartOpensWindowsWhereRunDoes|TestStepsFollowTheMainWindow'.
  • Both new tests fail without the fixes: TestPanelFitsContent got two fit commands, 150 then 200, and TestTransparentPanelReportsIt got false. Both pass with them.
  • ubuild, full packages, all pass: ./core (664), ./nsgotest (71), ./desktop.
  • go tool nsgo check -target linux_x64 and -target windows_x64 on ubuild, and -target macos_arm64 on rbuild: all pass.

Not run: anything on Windows (Windows code was only compiled and vetted); Linux GTK backend tests and the Linux fitPanel change under GTK (no GUI on the build hosts); a local macOS GUI test run (the disk had only about 1–4 GB free).

Second review (0e9b183):

  • macOS: a visible fitted panel placed by ShowAt or under its tray icon used to take its new size at its old top edge and then move to its placement, two frame changes; fitPanel now computes the placed origin for the new size (panelOrigin, split out of movePanel) and sets the frame once.
  • ubuild mise exec [email protected] -- go tool nsgo check -target all: exit 0, skipping ios, tvos and watchos (they need Xcode). go tool nsgo test ./core (664 passed), ./nsgotest (71 passed), ./desktop (1 passed).
  • rbuild mise exec [email protected] -- go tool nsgo check -target macos_arm64: exit 0. go tool nsgo test ./internal/platform/macos: 51 passed, 3 skipped.
  • The fitted ShowAt panel on macOS was not run again by hand after this change.

Rebased onto main with #581 (transparent windows), #583, #576, #577 and the frontmost-app commits (7ccbe32):

  • Integrated rather than kept twice: macOS and Linux each have one transparent field for windows and panels; macOS's setMaterial uses feat(desktop): transparent, shadowless windows off the taskbar #581's applyBackground, which already keeps a transparent surface clear; Windows panels use composeTransparent and applyBare instead of a second composeClear and corner constant, and CanMakeWindowsTransparent stays false for a panel; Linux drops the panel's own gtk_widget_add_css_class, gdk_display_is_* bindings and CSS provider for feat(desktop): transparent, shadowless windows off the taskbar #581's lookCSS (now also clearing the box and border) and displayComposites, and rereads the display's composited property for panels too. The log lines for a panel the platform could not clear are gone, as feat(desktop): transparent, shadowless windows off the taskbar #581 dropped its own: desktop.Transparent says it.
  • go tool nsgo check -target all on ubuild: exit 0 (iOS, tvOS and watchOS skipped, need Xcode). go tool nsgo test on ubuild: ./core 674 passed, ./desktop 5, ./nsgotest 74, ./internal/driver 134 and ./internal/moduletest 9, all passing. Linux xvfb-run -a env GDK_BACKEND=x11 go tool nsgo test ./internal/platform/linux: 137 passed, 1 skipped, including TestTransparentWindowLook, which now checks WindowTransparent.
  • rbuild ... go tool nsgo check -target macos_arm64,ios: exit 0. go tool nsgo test ./internal/platform/macos: 57 passed, 3 skipped, including TestTransparentWindow, which now checks WindowTransparent as the window turns transparent and framed again.
  • New tests: core TestTransparentWindowReportsIt (a window opened Transparent and the main window opened so read it from their first frame and follow the platform), and nsgotest TestTransparentSurfacesReportIt (a transparent window and panel report it, the main window follows SetWindowTransparent, a panel keeps what it opened with).
  • The first commit alone was vetted for macos_arm64, windows_x64 and linux_x64.

Checklist

  • Conventional Commit title.
  • Changelog, public documentation, architecture docs, skill reference and roadmap updated.
  • No new dependencies or third-party assets.

@github-actions github-actions Bot added enhancement New feature or request size/M documentation Improvements or additions to documentation macOS Windows Linux core conflict Conflicts with the base branch; resolve it first labels Nov 17, 2026
@houko
houko force-pushed the feat/transparent-panels branch from 0e9b183 to eb2e5da Compare November 17, 2026 11:47
@github-actions github-actions Bot added size/L and removed size/M conflict Conflicts with the base branch; resolve it first labels Nov 17, 2026
PanelOptions.Transparent opens a panel with no background, frame or shadow of its own, so a popup card draws its own corners and BoxShadow. It goes through what transparent windows already use, one transparent field per surface and SurfaceConfig.Transparent meaning the same for windows and panels: a borderless clear NSPanel without a shadow on macOS, whose material leaves it clear (applyBackground); on Windows the transparent window's DirectComposition with alpha and DWM's bare frame, square corners and no shadow; on Linux the window's CSS class, extended to its box and border, applied where GDK's display composites with an RGBA visual and left off elsewhere.

Env.WindowTransparent, read through desktop.Transparent, reports whether the scope's window or panel draws nothing of its own now: a transparent panel, and a window opened with WindowOptions.Transparent or nsgo.WindowTransparent or made so by desktop.SetWindowTransparent, where the platform could. desktop.CanMakeWindowsTransparent stays the capability; this is the state, false once a window is framed again, on Windows without DirectComposition and on Linux while the display does not composite, which the backend rereads for panels as for windows. nsgotest's headless desktop reports it for a window or panel opened Transparent and for a window SetWindowTransparent changes, as a compositing desktop does.

PanelOptions.FitContent has the core lay the panel's root out as an overlay sizes, up to Width and Height, and send the size as one driver.WindowFitSize ahead of the commit's other window commands, the last one when the commit lays out more than once, so the panel first shows at its content's size and follows it as it grows and shrinks. The platforms keep the top edge, or place a panel that shows beside its ShowAt rectangle or tray icon again.

Refs #315
@houko
houko force-pushed the feat/transparent-panels branch from eb2e5da to c1cb418 Compare November 17, 2026 11:55
@houko
houko merged commit 09ec9a9 into main Nov 17, 2026
9 checks passed
@houko
houko deleted the feat/transparent-panels branch November 17, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core documentation Improvements or additions to documentation enhancement New feature or request Linux macOS size/L Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panels: no transparent background and no size from the content, so a popup card shows an opaque window around it

1 participant