mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-01 06:10:07 -04:00
[macOS] implement HiDPIFactorChanged event on relevant events: (#443)
* moving window to another screen * changing resolution of screen
This commit is contained in:
committed by
Francesca Frangipane
parent
e36fd1788d
commit
f08bf44670
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
- Overhauled X11 window geometry calculations. `get_position` and `set_position` are more universally accurate across different window managers, and `get_outer_size` actually works now.
|
- Overhauled X11 window geometry calculations. `get_position` and `set_position` are more universally accurate across different window managers, and `get_outer_size` actually works now.
|
||||||
- Fixed SIGSEGV/SIGILL crashes on macOS caused by stabilization of the `!` (never) type.
|
- Fixed SIGSEGV/SIGILL crashes on macOS caused by stabilization of the `!` (never) type.
|
||||||
|
- Implement `WindowEvent::HiDPIFactorChanged` for macOS
|
||||||
|
|
||||||
# Version 0.12.0 (2018-04-06)
|
# Version 0.12.0 (2018-04-06)
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,17 @@ impl WindowDelegate {
|
|||||||
let state: *mut c_void = *this.get_ivar("winitState");
|
let state: *mut c_void = *this.get_ivar("winitState");
|
||||||
let state = &mut *(state as *mut DelegateState);
|
let state = &mut *(state as *mut DelegateState);
|
||||||
emit_resize_event(state);
|
emit_resize_event(state);
|
||||||
|
let scale_factor = NSWindow::backingScaleFactor(*state.window) as f32;
|
||||||
|
emit_event(state, WindowEvent::HiDPIFactorChanged(scale_factor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern fn window_did_change_backing_properties(this: &Object, _:Sel, _:id) {
|
||||||
|
unsafe {
|
||||||
|
let state: *mut c_void = *this.get_ivar("winitState");
|
||||||
|
let state = &mut *(state as *mut DelegateState);
|
||||||
|
let scale_factor = NSWindow::backingScaleFactor(*state.window) as f32;
|
||||||
|
emit_event(state, WindowEvent::HiDPIFactorChanged(scale_factor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +209,8 @@ impl WindowDelegate {
|
|||||||
window_did_resize as extern fn(&Object, Sel, id));
|
window_did_resize as extern fn(&Object, Sel, id));
|
||||||
decl.add_method(sel!(windowDidChangeScreen:),
|
decl.add_method(sel!(windowDidChangeScreen:),
|
||||||
window_did_change_screen as extern fn(&Object, Sel, id));
|
window_did_change_screen as extern fn(&Object, Sel, id));
|
||||||
|
decl.add_method(sel!(windowDidChangeBackingProperties:),
|
||||||
|
window_did_change_backing_properties as extern fn(&Object, Sel, id));
|
||||||
decl.add_method(sel!(windowDidBecomeKey:),
|
decl.add_method(sel!(windowDidBecomeKey:),
|
||||||
window_did_become_key as extern fn(&Object, Sel, id));
|
window_did_become_key as extern fn(&Object, Sel, id));
|
||||||
decl.add_method(sel!(windowDidResignKey:),
|
decl.add_method(sel!(windowDidResignKey:),
|
||||||
|
|||||||
Reference in New Issue
Block a user