From 4caa1b9ee937fabf0d59f91138a6f8a68ddd9300 Mon Sep 17 00:00:00 2001 From: xiaopengli89 Date: Mon, 5 Apr 2021 01:09:32 +0800 Subject: [PATCH 1/3] Mac: Redraw immediately to prevent shaking on window resize --- src/platform_impl/macos/app_state.rs | 4 ++++ src/platform_impl/macos/view.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/platform_impl/macos/app_state.rs b/src/platform_impl/macos/app_state.rs index b72cc57b56..b58993cbe6 100644 --- a/src/platform_impl/macos/app_state.rs +++ b/src/platform_impl/macos/app_state.rs @@ -323,6 +323,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) { if !unsafe { msg_send![class!(NSThread), isMainThread] } { panic!("Event queued from different thread: {:#?}", wrapper); diff --git a/src/platform_impl/macos/view.rs b/src/platform_impl/macos/view.rs index 523cb665d5..aa7109f8e1 100644 --- a/src/platform_impl/macos/view.rs +++ b/src/platform_impl/macos/view.rs @@ -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 = &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 () = msg_send![super(this, superclass), drawRect: rect]; From 4360c67a4b63f49924adfaef9ee41ecd914f4131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=8F=E9=B9=8F?= Date: Tue, 6 Apr 2021 11:47:53 +0800 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e972bedb2..d6bfb6ca9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - 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. - On X11, bump `mio` to 0.7. +- On macOS, emit `RedrawRequested` events while the window is being resized. # 0.24.0 (2020-12-09) From 82730537317ecb6a2a5cdf0f161235302bd8bbef Mon Sep 17 00:00:00 2001 From: Xiaopeng Li Date: Tue, 6 Apr 2021 13:15:00 +0800 Subject: [PATCH 3/3] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Markus Røyset --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6bfb6ca9d..de3dc968b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ - 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. - On X11, bump `mio` to 0.7. -- On macOS, emit `RedrawRequested` events while the window is being resized. +- On macOS, emit `RedrawRequested` events immediately while the window is being resized. # 0.24.0 (2020-12-09)