mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-01 06:10:07 -04: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:
@@ -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];
|
||||||
|
|||||||
Reference in New Issue
Block a user