macos: Set the layer contentGravity to top-left
By setting the contentGravity to top-left, the resizing of the
window doesn't result in stretching, which combined with newly rendered
frames results in jerky movement.
@@ -108,6 +108,12 @@ type FastHashMap<K, V> = HashMap<K, V, BuildHasherDefault<fxhash::FxHasher>>;
/// A type representing Metal binding's resource index.
type ResourceIndex = u32;
+// For CALayer contentsGravity
+extern "C" {
+ #[allow(non_upper_case_globals)]
+ static kCAGravityTopLeft: cocoa_foundation::base::id;
+}
+
#[repr(C)]
#[derive(Clone, Copy, Debug, Default)]
pub struct CGPoint {
@@ -421,6 +427,8 @@ impl Instance {
layer
};
+ let () = msg_send![render_layer, setContentsGravity:kCAGravityTopLeft];
+
let _: *mut c_void = msg_send![view, retain];
Surface::new(NonNull::new(view), render_layer)
}
