Skip to content

Commit 04f1ae5

Browse files
committed
On macOS, wake up the run loop immediately when a redraw is requested.
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 04f1ae5

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
@@ -1,5 +1,6 @@
11
# Unreleased
22

3+
- On macOS, wake up the run loop immediately when a redraw is requested.
34
- On Windows, change the default window size (1024x768) to match the default on other desktop platforms (800x600).
45
- On Windows, fix bug causing mouse capture to not be released.
56
- On Windows, fix fullscreen not preserving minimized/maximized state.

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::{CFRunLoopGetMain, CFRunLoopWakeUp, EventLoopWaker},
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)