chore: update to objc2 frameworks v0.3.2

This commit is contained in:
Mads Marquart 2025-08-21 15:58:55 +02:00 committed by Kirill Chibisov
parent d815bc089c
commit b811e9d878
13 changed files with 227 additions and 267 deletions

View file

@ -154,7 +154,7 @@ impl EventLoop {
// this line sets up the main run loop before `UIApplicationMain`
setup_control_flow_observers();
let center = unsafe { NSNotificationCenter::defaultCenter() };
let center = NSNotificationCenter::defaultCenter();
let _did_finish_launching_observer = create_observer(
&center,
@ -181,7 +181,7 @@ impl EventLoop {
// `applicationWillEnterForeground:`
unsafe { UIApplicationWillEnterForegroundNotification },
move |notification| {
let app = unsafe { notification.object() }.expect(
let app = notification.object().expect(
"UIApplicationWillEnterForegroundNotification to have application object",
);
// The `object` in `UIApplicationWillEnterForegroundNotification` is documented to
@ -195,7 +195,7 @@ impl EventLoop {
// `applicationDidEnterBackground:`
unsafe { UIApplicationDidEnterBackgroundNotification },
move |notification| {
let app = unsafe { notification.object() }.expect(
let app = notification.object().expect(
"UIApplicationDidEnterBackgroundNotification to have application object",
);
// The `object` in `UIApplicationDidEnterBackgroundNotification` is documented to be
@ -209,7 +209,8 @@ impl EventLoop {
// `applicationWillTerminate:`
unsafe { UIApplicationWillTerminateNotification },
move |notification| {
let app = unsafe { notification.object() }
let app = notification
.object()
.expect("UIApplicationWillTerminateNotification to have application object");
// The `object` in `UIApplicationWillTerminateNotification` is (somewhat) documented
// to be `UIApplication`.

View file

@ -271,8 +271,8 @@ mod tests {
let main = UIScreen::mainScreen(mtm);
assert!(UIScreen::screens(mtm).iter().any(|screen| ptr::eq(&*screen, &*main)));
assert!(unsafe {
assert!(
NSSet::setWithArray(&UIScreen::screens(mtm)).containsObject(&UIScreen::mainScreen(mtm))
});
);
}
}

View file

@ -161,8 +161,7 @@ impl Inner {
pub fn surface_position(&self) -> PhysicalPosition<i32> {
let view_position = self.view.frame().origin;
let position =
unsafe { self.window.convertPoint_fromView(view_position, Some(&self.view)) };
let position = self.window.convertPoint_fromView(view_position, Some(&self.view));
let position = LogicalPosition::new(position.x, position.y);
position.to_physical(self.scale_factor())
}
@ -393,9 +392,7 @@ impl Inner {
}
*current_caps = Some(capabilities);
unsafe {
self.view.becomeFirstResponder();
}
self.view.becomeFirstResponder();
},
ImeRequest::Update(_) => {
if current_caps.is_none() {
@ -404,9 +401,7 @@ impl Inner {
},
ImeRequest::Disable => {
*current_caps = None;
unsafe {
self.view.resignFirstResponder();
}
self.view.resignFirstResponder();
},
}