diff --git a/crates/gpui/src/platform/mac/renderer.rs b/crates/gpui/src/platform/mac/renderer.rs index dc2d8a9d50..ea094e998c 100644 --- a/crates/gpui/src/platform/mac/renderer.rs +++ b/crates/gpui/src/platform/mac/renderer.rs @@ -10,14 +10,14 @@ use crate::{ }; use cocoa::{ base::{NO, YES}, - foundation::{NSRect, NSUInteger}, + foundation::NSUInteger, quartzcore::AutoresizingMask, }; use core_foundation::base::TCFType; use foreign_types::ForeignTypeRef; use log::warn; use media::core_video::{self, CVMetalTextureCache}; -use metal::{CGFloat, CommandQueue, MTLPixelFormat, MTLResourceOptions, NSRange}; +use metal::{CommandQueue, MTLPixelFormat, MTLResourceOptions, NSRange}; use objc::{self, msg_send, sel, sel_impl}; use shaders::ToFloat2 as _; use std::{collections::HashMap, ffi::c_void, iter::Peekable, mem, ptr, sync::Arc, vec}; @@ -55,7 +55,7 @@ pub struct Surface { } impl Renderer { - pub fn new(fonts: Arc) -> Self { + pub fn new(is_opaque: bool, fonts: Arc) -> Self { const PIXEL_FORMAT: MTLPixelFormat = MTLPixelFormat::BGRA8Unorm; let device: metal::Device = if let Some(device) = metal::Device::system_default() { @@ -69,6 +69,7 @@ impl Renderer { layer.set_device(&device); layer.set_pixel_format(PIXEL_FORMAT); layer.set_presents_with_transaction(true); + layer.set_opaque(is_opaque); unsafe { let _: () = msg_send![&*layer, setAllowsNextDrawableTimeout: NO]; let _: () = msg_send![&*layer, setNeedsDisplayOnBoundsChange: YES]; @@ -363,7 +364,8 @@ impl Renderer { color_attachment.set_texture(Some(output)); color_attachment.set_load_action(metal::MTLLoadAction::Clear); color_attachment.set_store_action(metal::MTLStoreAction::Store); - color_attachment.set_clear_color(metal::MTLClearColor::new(0., 0., 0., 1.)); + let alpha = if self.layer.is_opaque() { 1. } else { 0. }; + color_attachment.set_clear_color(metal::MTLClearColor::new(0., 0., 0., alpha)); let command_encoder = command_buffer.new_render_command_encoder(render_pass_descriptor); command_encoder.set_viewport(metal::MTLViewport { diff --git a/crates/gpui/src/platform/mac/status_item.rs b/crates/gpui/src/platform/mac/status_item.rs index bd8c83154b..9d98c4a1f7 100644 --- a/crates/gpui/src/platform/mac/status_item.rs +++ b/crates/gpui/src/platform/mac/status_item.rs @@ -65,7 +65,7 @@ struct StatusItemState { impl StatusItem { pub fn add(fonts: Arc) -> Self { unsafe { - let renderer = Renderer::new(fonts); + let renderer = Renderer::new(false, fonts); let status_bar = NSStatusBar::systemStatusBar(nil); let native_item = StrongPtr::retain(status_bar.statusItemWithLength_(NSSquareStatusItemLength)); diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 822e1700f1..4abee8b961 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -382,7 +382,7 @@ impl Window { synthetic_drag_counter: 0, executor, scene_to_render: Default::default(), - renderer: Renderer::new(fonts), + renderer: Renderer::new(true, fonts), last_fresh_keydown: None, traffic_light_position: options .titlebar