Repository navigation
feat(desktop): transparent panels sized to their content - #582
Merged
Merged
Conversation
houko
force-pushed
the
feat/transparent-panels
branch
from
November 17, 2026 11:47
0e9b183 to
eb2e5da
Compare
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
force-pushed
the
feat/transparent-panels
branch
from
November 17, 2026 11:55
eb2e5da to
c1cb418
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #315.
PanelOptions.Transparentopens a panel with no background, frame or shadow of its own, so a popup card can draw its own rounded corners andBoxShadow.PanelOptions.FitContentsizes the panel to its content, up toWidthandHeight, and follows the content as it grows and shrinks.NSPanelwithout 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'snsgo-transparentCSS class on Linux, applied only where GDK's display composites with an RGBA visual. Onetransparentfield per surface on each backend and oneSurfaceConfig.Transparentmeaning for windows and panels.Env.WindowTransparent, read throughdesktop.Transparent, reports whether the scope's window or panel draws nothing of its own now: a transparent panel, and a window opened withWindowOptions.Transparentornsgo.WindowTransparent()or made so bydesktop.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.Transparentis 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 openedTransparentand for a windowSetWindowTransparentchanges, as a compositing desktop does.driver.WindowFitSizeahead 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 itsShowAtrectangle or tray icon again.Targets
Screenshots
Before: an opaque 380x520 panel with its system frame and shadow, the card sitting in a large white block.
After: a
Transparent+FitContentpanel showing only the rounded card and its own shadow on a transparent background; the window measured 380x148.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, includingTestPanelFitsContentandTestTransparentPanel.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_arm64and-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.ubuild ... go tool nsgo test ./core(664 passed), the two new tests by name (pass), andcheck -target windows_x64,linux_x64andmacos_arm64(all exit 0).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.After review fixes:
go tool nsgo test ./core -- -run 'TestPanelFitsContent|TestTransparentPanel|TestPanelPlacement'andgo tool nsgo test ./nsgotest -- -run 'TestTransparentPanelReportsIt|TestStartOpensWindowsWhereRunDoes|TestStepsFollowTheMainWindow'.TestPanelFitsContentgot two fit commands, 150 then 200, andTestTransparentPanelReportsItgot false. Both pass with them../core(664),./nsgotest(71),./desktop.go tool nsgo check -target linux_x64and-target windows_x64on ubuild, and-target macos_arm64on rbuild: all pass.Not run: anything on Windows (Windows code was only compiled and vetted); Linux GTK backend tests and the Linux
fitPanelchange 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):
ShowAtor under its tray icon used to take its new size at its old top edge and then move to its placement, two frame changes;fitPanelnow computes the placed origin for the new size (panelOrigin, split out ofmovePanel) 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.ShowAtpanel 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):
transparentfield for windows and panels; macOS'ssetMaterialuses feat(desktop): transparent, shadowless windows off the taskbar #581'sapplyBackground, which already keeps a transparent surface clear; Windows panels usecomposeTransparentandapplyBareinstead of a secondcomposeClearand corner constant, andCanMakeWindowsTransparentstays false for a panel; Linux drops the panel's owngtk_widget_add_css_class,gdk_display_is_*bindings and CSS provider for feat(desktop): transparent, shadowless windows off the taskbar #581'slookCSS(now also clearing the box and border) anddisplayComposites, and rereads the display'scompositedproperty 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.Transparentsays it.go tool nsgo check -target allon ubuild: exit 0 (iOS, tvOS and watchOS skipped, need Xcode).go tool nsgo teston ubuild:./core674 passed,./desktop5,./nsgotest74,./internal/driver134 and./internal/moduletest9, all passing. Linuxxvfb-run -a env GDK_BACKEND=x11 go tool nsgo test ./internal/platform/linux: 137 passed, 1 skipped, includingTestTransparentWindowLook, which now checksWindowTransparent.rbuild ... go tool nsgo check -target macos_arm64,ios: exit 0.go tool nsgo test ./internal/platform/macos: 57 passed, 3 skipped, includingTestTransparentWindow, which now checksWindowTransparentas the window turns transparent and framed again.coreTestTransparentWindowReportsIt(a window openedTransparentand the main window opened so read it from their first frame and follow the platform), andnsgotestTestTransparentSurfacesReportIt(a transparent window and panel report it, the main window followsSetWindowTransparent, a panel keeps what it opened with).Checklist