The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.
The protected media toast stays through Why?; the ✕ fills only under the pointer
Victor067a65f392ca
diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swiftindex 44901c7..267bf83 100644--- a/Sources/Cra/UI/Windows/MainWindowController.swift+++ b/Sources/Cra/UI/Windows/MainWindowController.swift@@ -2650,8 +2650,8 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM/// The first time a service plays in a WebKit page (docs/protected-media.md): "Spotify plays/// with Safari's engine", with Why? (the Site Control Center says what that means). It stays- /// until its ✕ or Why? is pressed, so Cra knows it was seen; only then is the service told for- /// good. Shown once a session per service: one that went unanswered shows again next launch.+ /// until its ✕ is pressed, Why? included, so Cra knows it was seen; only then is the service told+ /// for good. Shown once a session per service: one left open shows again next launch.private func tellAboutProtectedMedia(_ service: String) {let key = "protectedMediaToldServices"guard !(UserDefaults.standard.stringArray(forKey: key) ?? []).contains(service), !offeredProtectedMedia.contains(service),diff --git a/Sources/Cra/UI/Windows/ShinyToast.swift b/Sources/Cra/UI/Windows/ShinyToast.swiftindex 454280e..3b41d32 100644--- a/Sources/Cra/UI/Windows/ShinyToast.swift+++ b/Sources/Cra/UI/Windows/ShinyToast.swift@@ -108,6 +108,7 @@ final class ShinyToast {view.layer?.addSublayer(pill)view.onHover = { [weak self] inside in self?.hovered(inside) }view.onClick = { [weak self] point in self?.clicked(at: point) }+ view.onMove = { [weak self] point in self?.moved(to: point) }}var isShown: Bool { panel.parent != nil }@@ -197,7 +198,8 @@ final class ShinyToast {if persistent {let s = Self.closeSizecloseButton.frame = CGRect(x: width - (height - s) / 2 - s, y: (height - s) / 2, width: s, height: s)- closeButton.backgroundColor = colors.text.withAlphaComponent(0.1).cgColor+ // Only the glyph at rest; the round fill shows under the pointer (moved(to:)).+ closeButton.backgroundColor = NSColor.clear.cgColorlet config = NSImage.SymbolConfiguration(pointSize: 11, weight: .semibold).applying(.init(paletteColors: [colors.text]))closeGlyph.contents = NSImage(systemSymbolName: "xmark", accessibilityDescription: "Close")?.withSymbolConfiguration(config)closeGlyph.contentsScale = scale@@ -239,6 +241,7 @@ final class ShinyToast {CATransaction.begin()CATransaction.setDisableActions(true)if action?.symbol == nil { button.backgroundColor = buttonTint.withAlphaComponent(inside ? 0.16 : 0.1).cgColor }+ if !inside { closeButton.backgroundColor = NSColor.clear.cgColor }CATransaction.commit()return}@@ -253,6 +256,17 @@ final class ShinyToast {CATransaction.commit()}+ /// The ✕'s round fill follows the pointer onto it and off it.+ private func moved(to point: NSPoint) {+ guard isShown, persistent else { return }+ let local = NSPoint(x: point.x - Self.margin, y: point.y - Self.margin)+ let over = closeButton.frame.insetBy(dx: -4, dy: -4).contains(local)+ CATransaction.begin()+ CATransaction.setDisableActions(true)+ closeButton.backgroundColor = over ? buttonTint.withAlphaComponent(0.12).cgColor : NSColor.clear.cgColor+ CATransaction.commit()+ }+/// `point` in the content view: the button runs its action and the toast goes.private func clicked(at point: NSPoint) {guard isShown else { return }@@ -272,10 +286,9 @@ final class ShinyToast {scheduleHide()return}- // Pressing the button shows it was seen, as the ✕ does.- let closed = persistent ? onClose : nil+ // A toast that stays keeps standing through its button (Why?): only the ✕ closes it.+ if persistent { return action.run() }dismiss()- closed?()action.run()}@@ -375,6 +388,8 @@ private final class ToastView: NSView {var hitRect: NSRect = .zero { didSet { updateTrackingAreas() } }var onHover: (Bool) -> Void = { _ in }var onClick: (NSPoint) -> Void = { _ in }+ /// The pointer over the pill, in this view (the ✕ fills only under it).+ var onMove: (NSPoint) -> Void = { _ in }override func acceptsFirstMouse(for event: NSEvent?) -> Bool { true }@@ -386,11 +401,12 @@ private final class ToastView: NSView {super.updateTrackingAreas()for t in trackingAreas where t.owner === self { removeTrackingArea(t) }guard !hitRect.isEmpty else { return }- addTrackingArea(NSTrackingArea(rect: hitRect, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil))+ addTrackingArea(NSTrackingArea(rect: hitRect, options: [.mouseEnteredAndExited, .mouseMoved, .activeAlways], owner: self, userInfo: nil))}override func mouseEntered(with event: NSEvent) { onHover(true) }override func mouseExited(with event: NSEvent) { onHover(false) }+ override func mouseMoved(with event: NSEvent) { onMove(convert(event.locationInWindow, from: nil)) }override func mouseDown(with event: NSEvent) {}override func mouseUp(with event: NSEvent) { onClick(convert(event.locationInWindow, from: nil)) }}diff --git a/docs/protected-media.md b/docs/protected-media.mdindex 5fb2ee5..98e797b 100644--- a/docs/protected-media.md+++ b/docs/protected-media.md@@ -78,9 +78,11 @@ services pick their DRM by browser.## How Cra tells the user-- **Once per service, a toast**: the first time a service's page shows, "Spotify plays with- Safari's engine" with a Why? button that opens the Site Control Center. Which services have- been announced is kept in the `protectedMediaToldServices` default.+- **Once per service, a toast that stays**: the first time a service's page shows, "Spotify+ plays with Safari's engine" with a Why? button that opens the Site Control Center. It has no+ timer and stays through Why?. Only its ✕ closes it, so Cra knows it was seen; the ✕ shows its+ round fill only under the pointer. Services whose ✕ was pressed are kept in the+ `protectedMediaToldServices` default. One left open shows again the next session.- **The Site Control Center**: on a WebKit page, a Protected Media card takes the Extensionsgrid's place. It names the service, says why, and lists what that means here: you sign in once,extensions don't run, and Web Inspector opens instead of DevTools. Learn more opens