diff --git a/src/platform_impl/macos/app_state.rs b/src/platform_impl/macos/app_state.rs index d1d9524c44..c6e93061eb 100644 --- a/src/platform_impl/macos/app_state.rs +++ b/src/platform_impl/macos/app_state.rs @@ -33,7 +33,7 @@ use crate::{ event::{EventProxy, EventWrapper}, event_loop::{post_dummy_event, PanicInfo}, menu, - observer::{CFRunLoopGetMain, CFRunLoopWakeUp, EventLoopWaker}, + observer::EventLoopWaker, util::{IdRef, Never}, window::get_window_id, }, @@ -133,7 +133,6 @@ struct Handler { start_time: Mutex>, callback: Mutex>>, pending_events: Mutex>, - pending_redraw: Mutex>, waker: Mutex, } @@ -145,10 +144,6 @@ impl Handler { self.pending_events.lock().unwrap() } - fn redraw(&self) -> MutexGuard<'_, Vec> { - self.pending_redraw.lock().unwrap() - } - fn waker(&self) -> MutexGuard<'_, EventLoopWaker> { self.waker.lock().unwrap() } @@ -192,10 +187,6 @@ impl Handler { mem::take(&mut *self.events()) } - fn should_redraw(&self) -> Vec { - mem::take(&mut *self.redraw()) - } - fn get_in_callback(&self) -> bool { self.in_callback.load(Ordering::Acquire) } @@ -345,18 +336,6 @@ impl AppState { HANDLER.set_in_callback(false); } - // This is called from multiple threads at present - pub fn queue_redraw(window_id: WindowId) { - let mut pending_redraw = HANDLER.redraw(); - if !pending_redraw.contains(&window_id) { - pending_redraw.push(window_id); - } - unsafe { - let rl = CFRunLoopGetMain(); - CFRunLoopWakeUp(rl); - } - } - pub fn handle_redraw(window_id: WindowId) { HANDLER.handle_nonuser_event(EventWrapper::StaticEvent(Event::RedrawRequested(window_id))); } @@ -393,10 +372,6 @@ impl AppState { HANDLER.handle_nonuser_event(event); } HANDLER.handle_nonuser_event(EventWrapper::StaticEvent(Event::MainEventsCleared)); - for window_id in HANDLER.should_redraw() { - HANDLER - .handle_nonuser_event(EventWrapper::StaticEvent(Event::RedrawRequested(window_id))); - } HANDLER.handle_nonuser_event(EventWrapper::StaticEvent(Event::RedrawEventsCleared)); HANDLER.set_in_callback(false); diff --git a/src/platform_impl/macos/window.rs b/src/platform_impl/macos/window.rs index f7e1e88d20..2fcd4979ef 100644 --- a/src/platform_impl/macos/window.rs +++ b/src/platform_impl/macos/window.rs @@ -19,7 +19,6 @@ use crate::{ monitor::{MonitorHandle as RootMonitorHandle, VideoMode as RootVideoMode}, platform::macos::WindowExtMacOS, platform_impl::platform::{ - app_state::AppState, app_state::INTERRUPT_EVENT_LOOP_EXIT, ffi, monitor::{self, MonitorHandle, VideoMode}, @@ -29,9 +28,7 @@ use crate::{ window_delegate::new_delegate, OsError, }, - window::{ - CursorIcon, Fullscreen, UserAttentionType, WindowAttributes, WindowId as RootWindowId, - }, + window::{CursorIcon, Fullscreen, UserAttentionType, WindowAttributes}, }; use cocoa::{ appkit::{ @@ -44,6 +41,7 @@ use cocoa::{ use core_graphics::display::{CGDisplay, CGDisplayMode}; use objc::{ declare::ClassDecl, + msg_send, rc::autoreleasepool, runtime::{Class, Object, Sel, BOOL, NO, YES}, }; @@ -503,11 +501,9 @@ impl UnownedWindow { } pub fn request_redraw(&self) { - use objc::{msg_send, runtime::{Object, YES}}; - println!("Modified redraw request"); let view = *self.ns_view as *mut _; - unsafe{ - let _: () = objc::msg_send![view, setNeedsDisplay:YES]; + unsafe { + let _: () = objc::msg_send![view, setNeedsDisplay: YES]; } }