mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +11:00
Mac: Redraw immediately to prevent shaking on window resize (#1901)
* Mac: Redraw immediately to prevent shaking on window resize * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: 李小鹏 <lixiaopeng.jetspark@bytedance.com> Co-authored-by: Markus Røyset <maroider@protonmail.com>
This commit is contained in:
parent
0487876826
commit
ba704c4eb4
|
@ -19,6 +19,7 @@
|
||||||
- Added `WindowBuilder::with_position` to allow setting the position of a `Window` on creation. Supported on Windows, macOS and X11.
|
- Added `WindowBuilder::with_position` to allow setting the position of a `Window` on creation. Supported on Windows, macOS and X11.
|
||||||
- Added `Window::drag_window`. Implemented on Windows, macOS, X11 and Wayland.
|
- Added `Window::drag_window`. Implemented on Windows, macOS, X11 and Wayland.
|
||||||
- On X11, bump `mio` to 0.7.
|
- On X11, bump `mio` to 0.7.
|
||||||
|
- On macOS, emit `RedrawRequested` events immediately while the window is being resized.
|
||||||
|
|
||||||
# 0.24.0 (2020-12-09)
|
# 0.24.0 (2020-12-09)
|
||||||
|
|
||||||
|
|
|
@ -327,6 +327,10 @@ impl AppState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn handle_redraw(window_id: WindowId) {
|
||||||
|
HANDLER.handle_nonuser_event(EventWrapper::StaticEvent(Event::RedrawRequested(window_id)));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn queue_event(wrapper: EventWrapper) {
|
pub fn queue_event(wrapper: EventWrapper) {
|
||||||
if !unsafe { msg_send![class!(NSThread), isMainThread] } {
|
if !unsafe { msg_send![class!(NSThread), isMainThread] } {
|
||||||
panic!("Event queued from different thread: {:#?}", wrapper);
|
panic!("Event queued from different thread: {:#?}", wrapper);
|
||||||
|
|
|
@ -346,7 +346,7 @@ extern "C" fn draw_rect(this: &Object, _sel: Sel, rect: NSRect) {
|
||||||
let state_ptr: *mut c_void = *this.get_ivar("winitState");
|
let state_ptr: *mut c_void = *this.get_ivar("winitState");
|
||||||
let state = &mut *(state_ptr as *mut ViewState);
|
let state = &mut *(state_ptr as *mut ViewState);
|
||||||
|
|
||||||
AppState::queue_redraw(WindowId(get_window_id(state.ns_window)));
|
AppState::handle_redraw(WindowId(get_window_id(state.ns_window)));
|
||||||
|
|
||||||
let superclass = util::superclass(this);
|
let superclass = util::superclass(this);
|
||||||
let () = msg_send![super(this, superclass), drawRect: rect];
|
let () = msg_send![super(this, superclass), drawRect: rect];
|
||||||
|
|
Loading…
Reference in a new issue