From 44d1ababf0af662bef0995d96db37317b9eb7c87 Mon Sep 17 00:00:00 2001 From: Ryan Hileman Date: Mon, 16 May 2022 09:15:21 -0700 Subject: [PATCH] CALayer: place buffer in top left instead of scaling to window --- src/cg.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cg.rs b/src/cg.rs index a8fecc6..1f6d10c 100644 --- a/src/cg.rs +++ b/src/cg.rs @@ -7,7 +7,7 @@ use core_graphics::geometry::CGSize; use core_graphics::image::CGImage; use cocoa::base::id; -use cocoa::quartzcore::CALayer; +use cocoa::quartzcore::{CALayer, ContentsGravity}; use foreign_types::ForeignType; pub struct CGImpl { @@ -18,6 +18,7 @@ impl CGImpl { pub unsafe fn new(handle: AppKitHandle) -> Result> { let view = handle.ns_view as id; let layer = CALayer::new(); + layer.set_contents_gravity(ContentsGravity::TopLeft); let _: () = msg_send![view, setLayer:layer.clone()]; Ok(Self{layer}) }