Skip to content

fix: draw a popup's own shadow without an outline around it - #185

Merged
M4n0x merged 1 commit into
mainfrom
fix/popup-shadow-outline
Oct 22, 2026
Merged

M4n0x merged 1 commit into
mainfrom
fix/popup-shadow-outline

Conversation

@M4n0x

@M4n0x M4n0x commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Problem

Popups with a shadowColor show a dark outline floating outside their edge. It sits about 15 pt out with shadowRadius: 14, and gives the bundled themes' 2 pt popup shadows a doubled edge. It's a regression from #170, so far only in betas. Fixes #180.

Changes

Cause, measured on macOS 26.6. For a transparent borderless window with hasShadow, the window server weights the soft shadow by the content's alpha. It also draws a crisp rim wherever the content passes about 13/255 (~5%) alpha. The popup drew its SwiftUI shadow in its own window, so the rim followed that alpha level out in the shadow's fade. #180 said the outline traces every pixel that isn't clear; the threshold corrects that.

WidgetPopup.swift:

  • The popup's window keeps hasShadow and no longer draws the popup's own shadow. The system shadow and rim now follow the popup's edge, as they already did for popups without a shadowColor.
  • When the popup's style has a visible shadowColor, a second borderless window behind the popup draws that shadow (PopupShadowView). The popup's shape is cut out of it, so translucent and glass popups don't show it. This window has no window shadow and ignores clicks. It shares the popup's frame and PopupRevealView, and follows its reveal scale, fade, resizes and close.
  • Popups without a visible shadowColor get no extra window. Tooltips are unchanged: they never had the window shadow.

No README change. The popup section already says "Popups cast the system's window shadow, under the shadowColor shadow if one is set", which is now what happens.

Alternatives ruled out:

  • Turning the window shadow off when a popup draws its own. 11 of the 13 bundled themes give popups a shadow color, so this would undo feat: fade popups in with a shadow and the system material #170 for most people.
  • Dropping the popup's own shadow, which would ignore a documented setting.
  • A nearly clear window behind the popup to cast the system shadow. The window server scales the shadow with alpha, so that window would have to be opaque, and it would show through glass popups.

Testing

  • popupDrawsItsOwnShadowInAWindowBehindIt renders the popup's window and checks that it's clear 4 pt beside the popup. It also checks that the shadow window draws there and is clear inside the popup, that it keeps the popup's frame through a resize, and that closing removes it. Without the change, the clear-beside check fails.
  • swift test: 275 XCTest and 388 Swift Testing tests pass. The animated case of popupResizesWithItsContentAndKeepsItsWidthAndTopEdge failed once locally on both main and this branch, then passed on reruns, as feat: fade popups in with a shadow and the system material #170 also noted.
  • Screenshots below come from the real popup code on main and on this branch:
    • A temporary test, not committed, ordered the windows behind the wallpaper and captured each one with screencapture -l.
    • The captures are composited at 1× on solid backdrops.
    • Rows: shadowRadius: 14 in dark and light, a Built-in-style 2 pt shadow, and no shadowColor.
  • Not checked:
    • in a running bar;
    • with Liquid Glass on;
    • individual frames of the open and close animations.
    • Clicks in the margin around a shadowed popup should now pass through, as they already did around popups without a shadow. I didn't check this.

Merging

One commit, so any merge method keeps it.

Claude Opus 5.5 via Claude Code

Since popups cast the window shadow (#170), macOS outlines a popup's
window wherever what it draws passes about 5% alpha. A popup with a
shadowColor drew that shadow in the same window, so the outline landed
out in the shadow's fade instead of on the popup's edge: about 15 pt
out with a shadowRadius of 14, and a doubled edge with the 2 pt
shadows of the bundled themes.

That shadow now goes in a shadowless window behind the popup, with the
popup's shape cut out. It follows the popup's frame, reveal, fade and
close. The popup's own window keeps the system shadow, which now hugs
its edge. Popups without a shadowColor are unchanged.

Fixes #180
@M4n0x
M4n0x requested a review from Seb-GRAF as a code owner October 22, 2026 08:01
@M4n0x
M4n0x merged commit 9775eb3 into main Oct 22, 2026
6 checks passed
@M4n0x
M4n0x deleted the fix/popup-shadow-outline branch October 22, 2026 08:14
@stablebar-releases

Copy link
Copy Markdown

🎉 This PR is included in version 0.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Popups with a shadow get a dark outline floating outside their edge

1 participant