mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-28 07:33:14 -04:00
Refactor macOS to use new objc2 features (#2465)
* Remove UnownedWindow::inner_rect * Refactor custom view to use much less `unsafe` The compiler fence is safe to get rid of now since `interpretKeyEvents` takes `&mut self` * Refactor Window to use much less unsafe * Refactor NSApplication usage to have much less unsafe * Remove cocoa dependency * Enable `deny(unsafe_op_in_unsafe_fn)` on macOS Also re-enable clippy `let_unit_value` lint * Remove #[macro_use] on macOS * Refactor window delegate to use much less unsafe
This commit is contained in:
31
src/platform_impl/macos/appkit/text_input_context.rs
Normal file
31
src/platform_impl/macos/appkit/text_input_context.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use objc2::foundation::{NSObject, NSString};
|
||||
use objc2::rc::{Id, Shared};
|
||||
use objc2::{extern_class, extern_methods, msg_send_id, ClassType};
|
||||
|
||||
type NSTextInputSourceIdentifier = NSString;
|
||||
|
||||
extern_class!(
|
||||
/// Main-Thread-Only!
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub(crate) struct NSTextInputContext;
|
||||
|
||||
unsafe impl ClassType for NSTextInputContext {
|
||||
type Super = NSObject;
|
||||
}
|
||||
);
|
||||
|
||||
extern_methods!(
|
||||
unsafe impl NSTextInputContext {
|
||||
#[sel(invalidateCharacterCoordinates)]
|
||||
pub fn invalidateCharacterCoordinates(&self);
|
||||
|
||||
#[sel(discardMarkedText)]
|
||||
pub fn discardMarkedText(&self);
|
||||
|
||||
pub fn selectedKeyboardInputSource(
|
||||
&self,
|
||||
) -> Option<Id<NSTextInputSourceIdentifier, Shared>> {
|
||||
unsafe { msg_send_id![self, selectedKeyboardInputSource] }
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user