Revert the commit that broke Zed display capabilities (#7326)

This commit is contained in:
Kirill Bulatov 2024-02-03 18:32:56 +02:00 committed by GitHub
parent 06674a21f9
commit 1ab0af2fa3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 37 additions and 50 deletions

View file

@ -16,8 +16,8 @@ use cocoa::{
},
base::{id, nil},
foundation::{
NSArray, NSAutoreleasePool, NSDefaultRunLoopMode, NSDictionary, NSFastEnumeration,
NSInteger, NSPoint, NSRect, NSSize, NSString, NSUInteger,
NSArray, NSAutoreleasePool, NSDictionary, NSFastEnumeration, NSInteger, NSPoint, NSRect,
NSSize, NSString, NSUInteger,
},
};
use core_graphics::display::CGRect;
@ -321,7 +321,6 @@ struct MacWindowState {
executor: ForegroundExecutor,
native_window: id,
native_view: NonNull<id>,
display_link: id,
renderer: MetalRenderer,
kind: WindowKind,
request_frame_callback: Option<Box<dyn FnMut()>>,
@ -524,10 +523,6 @@ impl MacWindow {
let native_view: id = msg_send![VIEW_CLASS, alloc];
let native_view = NSView::init(native_view);
let display_link: id = msg_send![class!(CADisplayLink), displayLinkWithTarget: native_view selector: sel!(displayLayer:)];
let main_run_loop: id = msg_send![class!(NSRunLoop), mainRunLoop];
let _: () =
msg_send![display_link, addToRunLoop: main_run_loop forMode: NSDefaultRunLoopMode];
assert!(!native_view.is_null());
let window = Self(Arc::new(Mutex::new(MacWindowState {
@ -535,7 +530,6 @@ impl MacWindow {
executor,
native_window,
native_view: NonNull::new_unchecked(native_view as *mut _),
display_link,
renderer: MetalRenderer::new(instance_buffer_pool),
kind: options.kind,
request_frame_callback: None,
@ -694,9 +688,6 @@ impl Drop for MacWindow {
fn drop(&mut self) {
let this = self.0.lock();
let window = this.native_window;
unsafe {
let _: () = msg_send![this.display_link, invalidate];
}
this.executor
.spawn(async move {
unsafe {
@ -1010,6 +1001,13 @@ impl PlatformWindow for MacWindow {
}
}
fn invalidate(&self) {
let this = self.0.lock();
unsafe {
let _: () = msg_send![this.native_window.contentView(), setNeedsDisplay: YES];
}
}
fn draw(&self, scene: &crate::Scene) {
let mut this = self.0.lock();
this.renderer.draw(scene);