diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fad9364..bfba47c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ - On Windows, fix handling of surrogate pairs when dispatching `ReceivedCharacter`. - On macOS 10.15, fix freeze upon exiting exclusive fullscreen mode. - On iOS, fix null window on initial `HiDpiFactorChanged` event. +- On macOS, fix events not being emitted during modal loops, such as when windows are being resized + by the user. - On Windows, fix hovering the mouse over the active window creating an endless stream of CursorMoved events. # 0.20.0 Alpha 3 (2019-08-14) diff --git a/src/platform_impl/macos/app_state.rs b/src/platform_impl/macos/app_state.rs index 4a18ed83..d063fe84 100644 --- a/src/platform_impl/macos/app_state.rs +++ b/src/platform_impl/macos/app_state.rs @@ -84,7 +84,6 @@ struct Handler { start_time: Mutex>, callback: Mutex>>, pending_events: Mutex>>, - deferred_events: Mutex>>, pending_redraw: Mutex>, waker: Mutex, } @@ -97,10 +96,6 @@ impl Handler { self.pending_events.lock().unwrap() } - fn deferred<'a>(&'a self) -> MutexGuard<'a, VecDeque>> { - self.deferred_events.lock().unwrap() - } - fn redraw<'a>(&'a self) -> MutexGuard<'a, Vec> { self.pending_redraw.lock().unwrap() } @@ -145,10 +140,6 @@ impl Handler { mem::replace(&mut *self.events(), Default::default()) } - fn take_deferred(&self) -> VecDeque> { - mem::replace(&mut *self.deferred(), Default::default()) - } - fn should_redraw(&self) -> Vec { mem::replace(&mut *self.redraw(), Default::default()) } @@ -264,20 +255,6 @@ impl AppState { HANDLER.events().append(&mut events); } - pub fn send_event_immediately(event: Event) { - if !unsafe { msg_send![class!(NSThread), isMainThread] } { - panic!("Event sent from different thread: {:#?}", event); - } - HANDLER.deferred().push_back(event); - if !HANDLER.get_in_callback() { - HANDLER.set_in_callback(true); - for event in HANDLER.take_deferred() { - HANDLER.handle_nonuser_event(event); - } - HANDLER.set_in_callback(false); - } - } - pub fn cleared() { if !HANDLER.is_ready() { return; diff --git a/src/platform_impl/macos/observer.rs b/src/platform_impl/macos/observer.rs index 661ec82e..10e78e0e 100644 --- a/src/platform_impl/macos/observer.rs +++ b/src/platform_impl/macos/observer.rs @@ -4,7 +4,6 @@ use crate::platform_impl::platform::{app_state::AppState, ffi}; #[link(name = "CoreFoundation", kind = "framework")] extern "C" { - pub static kCFRunLoopDefaultMode: CFRunLoopMode; pub static kCFRunLoopCommonModes: CFRunLoopMode; pub fn CFRunLoopGetMain() -> CFRunLoopRef; @@ -162,7 +161,7 @@ impl RunLoop { handler, ptr::null_mut(), ); - CFRunLoopAddObserver(self.0, observer, kCFRunLoopDefaultMode); + CFRunLoopAddObserver(self.0, observer, kCFRunLoopCommonModes); } } diff --git a/src/platform_impl/macos/window_delegate.rs b/src/platform_impl/macos/window_delegate.rs index 9bce9ce7..041edf61 100644 --- a/src/platform_impl/macos/window_delegate.rs +++ b/src/platform_impl/macos/window_delegate.rs @@ -84,11 +84,7 @@ impl WindowDelegateState { pub fn emit_resize_event(&mut self) { let rect = unsafe { NSView::frame(*self.ns_view) }; let size = LogicalSize::new(rect.size.width as f64, rect.size.height as f64); - let event = Event::WindowEvent { - window_id: WindowId(get_window_id(*self.ns_window)), - event: WindowEvent::Resized(size), - }; - AppState::send_event_immediately(event); + self.emit_event(WindowEvent::Resized(size)); } fn emit_move_event(&mut self) {