From 6f49f4a9cff6cf0fe5fef8a3db72cf64c1d609df Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 4 Jul 2022 15:14:08 -0700 Subject: [PATCH] Recalculate Metal layer's drawable size when window's scale factor changes --- crates/gpui/src/platform/mac/window.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 14b9cf7ea8..c845693ba9 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -758,7 +758,15 @@ extern "C" fn view_did_change_backing_properties(this: &Object, _: Sel) { let mut window_state_borrow = window_state.as_ref().borrow_mut(); unsafe { - let _: () = msg_send![window_state_borrow.layer, setContentsScale: window_state_borrow.scale_factor() as f64]; + let scale_factor = window_state_borrow.scale_factor() as f64; + let size = window_state_borrow.size(); + let drawable_size: NSSize = NSSize { + width: size.x() as f64 * scale_factor, + height: size.y() as f64 * scale_factor, + }; + + let _: () = msg_send![window_state_borrow.layer, setContentsScale: scale_factor]; + let _: () = msg_send![window_state_borrow.layer, setDrawableSize: drawable_size]; } if let Some(mut callback) = window_state_borrow.resize_callback.take() {