Fix runloop entry (#2480)

Introduced in https://github.com/rust-windowing/winit/pull/2479; turns out the definitions were not entirely equal, the `kCFRunLoopEntry` that we were using previously was defined as `0` while the correct value is `1` (which meant the `unimplemented!()` branch suddenly started triggering)
This commit is contained in:
Mads Marquart 2022-09-08 21:56:53 +02:00 committed by GitHub
parent d8c0ee733b
commit fec52b028e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View file

@ -10,10 +10,9 @@ use std::{
use core_foundation::base::{CFIndex, CFRelease}; use core_foundation::base::{CFIndex, CFRelease};
use core_foundation::runloop::{ use core_foundation::runloop::{
kCFRunLoopAfterWaiting, kCFRunLoopBeforeWaiting, kCFRunLoopCommonModes, kCFRunLoopDefaultMode, kCFRunLoopAfterWaiting, kCFRunLoopBeforeWaiting, kCFRunLoopCommonModes, kCFRunLoopDefaultMode,
kCFRunLoopEntry, kCFRunLoopExit, CFRunLoopActivity, CFRunLoopAddObserver, CFRunLoopAddSource, kCFRunLoopExit, CFRunLoopActivity, CFRunLoopAddObserver, CFRunLoopAddSource, CFRunLoopGetMain,
CFRunLoopGetMain, CFRunLoopObserverCreate, CFRunLoopObserverRef, CFRunLoopSourceContext, CFRunLoopObserverCreate, CFRunLoopObserverRef, CFRunLoopSourceContext, CFRunLoopSourceCreate,
CFRunLoopSourceCreate, CFRunLoopSourceInvalidate, CFRunLoopSourceRef, CFRunLoopSourceSignal, CFRunLoopSourceInvalidate, CFRunLoopSourceRef, CFRunLoopSourceSignal, CFRunLoopWakeUp,
CFRunLoopWakeUp,
}; };
use objc2::runtime::Object; use objc2::runtime::Object;
use objc2::{class, msg_send, ClassType}; use objc2::{class, msg_send, ClassType};
@ -236,7 +235,6 @@ fn setup_control_flow_observers() {
#[allow(non_upper_case_globals)] #[allow(non_upper_case_globals)]
match activity { match activity {
kCFRunLoopAfterWaiting => app_state::handle_wakeup_transition(), kCFRunLoopAfterWaiting => app_state::handle_wakeup_transition(),
kCFRunLoopEntry => unimplemented!(), // not expected to ever happen
_ => unreachable!(), _ => unreachable!(),
} }
} }
@ -288,7 +286,7 @@ fn setup_control_flow_observers() {
let begin_observer = CFRunLoopObserverCreate( let begin_observer = CFRunLoopObserverCreate(
ptr::null_mut(), ptr::null_mut(),
kCFRunLoopEntry | kCFRunLoopAfterWaiting, kCFRunLoopAfterWaiting,
1, // repeat = true 1, // repeat = true
CFIndex::min_value(), CFIndex::min_value(),
control_flow_begin_handler, control_flow_begin_handler,

View file

@ -15,8 +15,8 @@ use crate::platform_impl::platform::{
use core_foundation::base::{CFIndex, CFOptionFlags, CFRelease}; use core_foundation::base::{CFIndex, CFOptionFlags, CFRelease};
use core_foundation::date::CFAbsoluteTimeGetCurrent; use core_foundation::date::CFAbsoluteTimeGetCurrent;
use core_foundation::runloop::{ use core_foundation::runloop::{
kCFRunLoopAfterWaiting, kCFRunLoopBeforeWaiting, kCFRunLoopCommonModes, kCFRunLoopEntry, kCFRunLoopAfterWaiting, kCFRunLoopBeforeWaiting, kCFRunLoopCommonModes, kCFRunLoopExit,
kCFRunLoopExit, CFRunLoopActivity, CFRunLoopAddObserver, CFRunLoopAddTimer, CFRunLoopGetMain, CFRunLoopActivity, CFRunLoopAddObserver, CFRunLoopAddTimer, CFRunLoopGetMain,
CFRunLoopObserverCallBack, CFRunLoopObserverContext, CFRunLoopObserverCreate, CFRunLoopObserverCallBack, CFRunLoopObserverContext, CFRunLoopObserverCreate,
CFRunLoopObserverRef, CFRunLoopRef, CFRunLoopTimerCreate, CFRunLoopTimerInvalidate, CFRunLoopObserverRef, CFRunLoopRef, CFRunLoopTimerCreate, CFRunLoopTimerInvalidate,
CFRunLoopTimerRef, CFRunLoopTimerSetNextFireDate, CFRunLoopTimerRef, CFRunLoopTimerSetNextFireDate,
@ -57,7 +57,6 @@ extern "C" fn control_flow_begin_handler(
AppState::wakeup(panic_info); AppState::wakeup(panic_info);
//trace!("Completed `CFRunLoopAfterWaiting`"); //trace!("Completed `CFRunLoopAfterWaiting`");
} }
kCFRunLoopEntry => unimplemented!(), // not expected to ever happen
_ => unreachable!(), _ => unreachable!(),
} }
}); });
@ -126,7 +125,7 @@ pub fn setup_control_flow_observers(panic_info: Weak<PanicInfo>) {
}; };
let run_loop = RunLoop::get(); let run_loop = RunLoop::get();
run_loop.add_observer( run_loop.add_observer(
kCFRunLoopEntry | kCFRunLoopAfterWaiting, kCFRunLoopAfterWaiting,
CFIndex::min_value(), CFIndex::min_value(),
control_flow_begin_handler, control_flow_begin_handler,
&mut context as *mut _, &mut context as *mut _,