From ce694c1eba99be1595dfb53fef0129933dce7634 Mon Sep 17 00:00:00 2001 From: der richter Date: Sat, 10 Jan 2026 16:32:09 +0100 Subject: [PATCH] mac/common: add support for transparent rendering this adds support for possible transparent rendering by setting the window and layer background to transparent. NOTE: atm only possible with libplacebo master. --- video/out/mac/metal_layer.swift | 1 + video/out/mac_common.swift | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/video/out/mac/metal_layer.swift b/video/out/mac/metal_layer.swift index 6156efe781..fbd7b8be2d 100644 --- a/video/out/mac/metal_layer.swift +++ b/video/out/mac/metal_layer.swift @@ -84,6 +84,7 @@ class MetalLayer: CAMetalLayer { let isForced = newValue == wantsAlpha if isOpaque == wantsAlpha || isForced { super.isOpaque = !wantsAlpha + backgroundColor = (wantsAlpha ? NSColor.clear : NSColor.black).cgColor log.verbose("Metal layer is opaque (direct-to-display possible): \(isOpaque)" + (isForced ? " (forced)" : "")) } } diff --git a/video/out/mac_common.swift b/video/out/mac_common.swift index fcfd90edc0..e2e9dd128d 100644 --- a/video/out/mac_common.swift +++ b/video/out/mac_common.swift @@ -117,6 +117,10 @@ class MacCommon: Common { @objc func update(alpha: Bool) { layer?.wantsAlpha = alpha + DispatchQueue.main.sync { + window?.isOpaque = !alpha + window?.backgroundColor = alpha ? NSColor.clear : nil + } } override func displayLinkCallback(_ displayLink: CVDisplayLink,