Skip to content

Commit 1be11a2

Browse files
committed
On macOS, wake up the event 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 ca9c053 commit 1be11a2

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
@@ -6,6 +6,7 @@
66
- Added `is_maximized` method to `Window`.
77
- On Windows, fix bug where clicking the decoration bar would make the cursor blink.
88
- On Windows, fix bug causing newly created windows to erroneously display the "wait" (spinning) cursor.
9+
- On macOS, wake up the event loop immediately when a redraw is requested.
910
- On Windows, change the default window size (1024x768) to match the default on other desktop platforms (800x600).
1011
- On Windows, fix bug causing mouse capture to not be released.
1112
- 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
platform_impl::platform::{
2626
event::{EventProxy, EventWrapper},
2727
event_loop::{post_dummy_event, PanicInfo},
28-
observer::EventLoopWaker,
28+
observer::{CFRunLoopGetMain, CFRunLoopWakeUp, EventLoopWaker},
2929
util::{IdRef, Never},
3030
window::get_window_id,
3131
},
@@ -321,6 +321,10 @@ impl AppState {
321321
if !pending_redraw.contains(&window_id) {
322322
pending_redraw.push(window_id);
323323
}
324+
unsafe {
325+
let rl = CFRunLoopGetMain();
326+
CFRunLoopWakeUp(rl);
327+
}
324328
}
325329

326330
pub fn queue_event(wrapper: EventWrapper) {

0 commit comments

Comments
 (0)