mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +11:00
Rename old glutin ivar to winit
This commit is contained in:
parent
3ce7904e01
commit
3482c53c89
|
@ -63,7 +63,7 @@ impl WindowDelegate {
|
||||||
|
|
||||||
extern fn window_should_close(this: &Object, _: Sel, _: id) -> BOOL {
|
extern fn window_should_close(this: &Object, _: Sel, _: id) -> BOOL {
|
||||||
unsafe {
|
unsafe {
|
||||||
let state: *mut c_void = *this.get_ivar("glutinState");
|
let state: *mut c_void = *this.get_ivar("winitState");
|
||||||
let state = &mut *(state as *mut DelegateState);
|
let state = &mut *(state as *mut DelegateState);
|
||||||
emit_event(state, Event::Closed);
|
emit_event(state, Event::Closed);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ impl WindowDelegate {
|
||||||
|
|
||||||
extern fn window_did_resize(this: &Object, _: Sel, _: id) {
|
extern fn window_did_resize(this: &Object, _: Sel, _: id) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let state: *mut c_void = *this.get_ivar("glutinState");
|
let state: *mut c_void = *this.get_ivar("winitState");
|
||||||
let state = &mut *(state as *mut DelegateState);
|
let state = &mut *(state as *mut DelegateState);
|
||||||
let rect = NSView::frame(*state.view);
|
let rect = NSView::frame(*state.view);
|
||||||
let scale_factor = NSWindow::backingScaleFactor(*state.window) as f32;
|
let scale_factor = NSWindow::backingScaleFactor(*state.window) as f32;
|
||||||
|
@ -86,7 +86,7 @@ impl WindowDelegate {
|
||||||
unsafe {
|
unsafe {
|
||||||
// TODO: center the cursor if the window had mouse grab when it
|
// TODO: center the cursor if the window had mouse grab when it
|
||||||
// lost focus
|
// lost focus
|
||||||
let state: *mut c_void = *this.get_ivar("glutinState");
|
let state: *mut c_void = *this.get_ivar("winitState");
|
||||||
let state = &mut *(state as *mut DelegateState);
|
let state = &mut *(state as *mut DelegateState);
|
||||||
emit_event(state, Event::Focused(true));
|
emit_event(state, Event::Focused(true));
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ impl WindowDelegate {
|
||||||
|
|
||||||
extern fn window_did_resign_key(this: &Object, _: Sel, _: id) {
|
extern fn window_did_resign_key(this: &Object, _: Sel, _: id) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let state: *mut c_void = *this.get_ivar("glutinState");
|
let state: *mut c_void = *this.get_ivar("winitState");
|
||||||
let state = &mut *(state as *mut DelegateState);
|
let state = &mut *(state as *mut DelegateState);
|
||||||
emit_event(state, Event::Focused(false));
|
emit_event(state, Event::Focused(false));
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ impl WindowDelegate {
|
||||||
INIT.call_once(|| unsafe {
|
INIT.call_once(|| unsafe {
|
||||||
// Create new NSWindowDelegate
|
// Create new NSWindowDelegate
|
||||||
let superclass = Class::get("NSObject").unwrap();
|
let superclass = Class::get("NSObject").unwrap();
|
||||||
let mut decl = ClassDecl::new("GlutinWindowDelegate", superclass).unwrap();
|
let mut decl = ClassDecl::new("WinitWindowDelegate", superclass).unwrap();
|
||||||
|
|
||||||
// Add callback methods
|
// Add callback methods
|
||||||
decl.add_method(sel!(windowShouldClose:),
|
decl.add_method(sel!(windowShouldClose:),
|
||||||
|
@ -120,7 +120,7 @@ impl WindowDelegate {
|
||||||
window_did_resign_key as extern fn(&Object, Sel, id));
|
window_did_resign_key as extern fn(&Object, Sel, id));
|
||||||
|
|
||||||
// Store internal state as user data
|
// Store internal state as user data
|
||||||
decl.add_ivar::<*mut c_void>("glutinState");
|
decl.add_ivar::<*mut c_void>("winitState");
|
||||||
|
|
||||||
DELEGATE_CLASS = decl.register();
|
DELEGATE_CLASS = decl.register();
|
||||||
});
|
});
|
||||||
|
@ -137,7 +137,7 @@ impl WindowDelegate {
|
||||||
unsafe {
|
unsafe {
|
||||||
let delegate = IdRef::new(msg_send![WindowDelegate::class(), new]);
|
let delegate = IdRef::new(msg_send![WindowDelegate::class(), new]);
|
||||||
|
|
||||||
(&mut **delegate).set_ivar("glutinState", state_ptr as *mut ::std::os::raw::c_void);
|
(&mut **delegate).set_ivar("winitState", state_ptr as *mut ::std::os::raw::c_void);
|
||||||
let _: () = msg_send![*state.window, setDelegate:*delegate];
|
let _: () = msg_send![*state.window, setDelegate:*delegate];
|
||||||
|
|
||||||
WindowDelegate { state: state, _this: delegate }
|
WindowDelegate { state: state, _this: delegate }
|
||||||
|
|
Loading…
Reference in a new issue