From 35c3af7fd0f64a4212a36819426a179d630db372 Mon Sep 17 00:00:00 2001 From: jansol Date: Mon, 29 Apr 2024 18:04:11 +0300 Subject: [PATCH] gpui/mac: Disable shadows on non-opaque windows (#10896) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The culprit behind ghost images in transparent windows and bad performance with blurred windows turns out to be one and the same: window shadows. The simplest and most popular fix appears to be to simply disable shadows on non-opaque windows so let's just do that. Disabling shadows on a window that is already visible however leaves the shadow on screen, detached from the window, until a full screen effect such as exposé or a virtual desktop switch wipes it clean. There does not seem to be any known solution to this, and it does not affect windows created after switching to a transparent theme so this is a good enough compromise for now. Release Notes: - Fixed ghostly artifacts in transparent window backgrounds. - Fixed sluggishness with blurred window backgrounds. --- crates/gpui/src/platform/mac/window.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 22ee22b50ba8b63f6f657f0d984b3494982e62db..340ef6a45b5f8c4ca046e8623d010b06302fe039 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -996,6 +996,8 @@ impl PlatformWindow for MacWindow { }; unsafe { this.native_window.setOpaque_(opaque); + // Shadows for transparent windows cause artifacts and performance issues + this.native_window.setHasShadow_(opaque); let clear_color = if opaque == YES { NSColor::colorWithSRGBRed_green_blue_alpha_(nil, 0f64, 0f64, 0f64, 1f64) } else {