Revert the commit that broke Zed display capabilities (#7326)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -282,6 +282,8 @@ impl PlatformWindow for TestWindow {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn invalidate(&self) {}
|
||||
|
||||
fn draw(&self, _scene: &crate::Scene) {}
|
||||
|
||||
fn sprite_atlas(&self) -> sync::Arc<dyn crate::PlatformAtlas> {
|
||||
|
||||
Reference in New Issue
Block a user