diff --git a/crates/gpui/src/platform/mac/renderer.rs b/crates/gpui/src/platform/mac/renderer.rs index f9cc6e730d..dc2d8a9d50 100644 --- a/crates/gpui/src/platform/mac/renderer.rs +++ b/crates/gpui/src/platform/mac/renderer.rs @@ -187,15 +187,11 @@ impl Renderer { pub fn render(&mut self, scene: &Scene) { let layer = self.layer.clone(); + let drawable_size = layer.drawable_size(); let drawable = layer.next_drawable().unwrap(); let command_queue = self.command_queue.clone(); let command_buffer = command_queue.new_command_buffer(); - let frame: NSRect = unsafe { msg_send![self.layer(), frame] }; - let scale_factor: CGFloat = unsafe { msg_send![self.layer(), contentsScale] }; - let drawable_size = - vec2f(frame.size.width as f32, frame.size.height as f32) * scale_factor as f32; - self.sprite_cache.set_scale_factor(scene.scale_factor()); self.image_cache.set_scale_factor(scene.scale_factor()); @@ -206,7 +202,7 @@ impl Renderer { scene, path_sprites, &mut offset, - drawable_size, + vec2f(drawable_size.width as f32, drawable_size.height as f32), command_buffer, drawable.texture(), ); diff --git a/crates/gpui/src/platform/mac/status_item.rs b/crates/gpui/src/platform/mac/status_item.rs index 81a8ad036f..bd8c83154b 100644 --- a/crates/gpui/src/platform/mac/status_item.rs +++ b/crates/gpui/src/platform/mac/status_item.rs @@ -1,7 +1,7 @@ use crate::{ geometry::vector::{vec2f, Vector2F}, platform::{self, mac::renderer::Renderer}, - Event, FontSystem, Scene, + Event, FontSystem, Scene, Window, }; use cocoa::{ appkit::{ @@ -75,7 +75,7 @@ impl StatusItem { button.setWantsBestResolutionOpenGLSurface_(YES); button.setLayer(renderer.layer().as_ptr() as id); - Self(Rc::new_cyclic(|state| { + let item = Self(Rc::new_cyclic(|state| { let event_handler = StrongPtr::new(msg_send![HANDLER_CLASS, alloc]); let _: () = msg_send![*event_handler, init]; (**event_handler) @@ -90,7 +90,18 @@ impl StatusItem { event_callback: None, _event_handler: event_handler, }) - })) + })); + + { + let item = item.0.borrow(); + let layer = item.renderer.layer(); + let scale_factor = item.scale_factor(); + let size = item.size() * scale_factor; + layer.set_contents_scale(scale_factor.into()); + layer.set_drawable_size(metal::CGSize::new(size.x().into(), size.y().into())); + } + + item } } }