Skip to content

Commit c759d50

Browse files
committed
macOS: Wake up run loop immediately when request redraw is received
We allow to have RunLoop running only on the main thread. Which means if we call Window::request_redraw() from other the thread then we have to wait until some other event arrives on the main thread. That situation is even worse when we have ControlFlow set to the `Wait` mode then user will not ever render anything.
1 parent 38fcceb commit c759d50

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- On Windows, change the default window size (1024x768) to match the default on other desktop platforms (800x600).
44
- On Windows, fix bug causing mouse capture to not be released.
55
- On Windows, fix fullscreen not preserving minimized/maximized state.
6+
- macOS: Wake up run loop immediately when request redraw is received.
67

78
# 0.24.0 (2020-12-09)
89

src/platform_impl/macos/app_state.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::{
2525
event_loop::{ControlFlow, EventLoopWindowTarget as RootWindowTarget},
2626
platform_impl::platform::{
2727
event::{EventProxy, EventWrapper},
28-
observer::EventLoopWaker,
28+
observer::{EventLoopWaker, CFRunLoopGetMain, CFRunLoopWakeUp},
2929
util::{IdRef, Never},
3030
window::get_window_id,
3131
},
@@ -302,6 +302,10 @@ impl AppState {
302302
if !pending_redraw.contains(&window_id) {
303303
pending_redraw.push(window_id);
304304
}
305+
unsafe {
306+
let rl = CFRunLoopGetMain();
307+
CFRunLoopWakeUp(rl);
308+
}
305309
}
306310

307311
pub fn queue_event(wrapper: EventWrapper) {

0 commit comments

Comments
 (0)