mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-26 03:36:32 +11:00
[macOS] Register the Cocoa main thread at an earlier point (#456)
Solves the issues caused by calling `EventsLoopProxy::wakeup()` too early from a worker thread.
This commit is contained in:
parent
19cd53193b
commit
10688915eb
1 changed files with 7 additions and 0 deletions
|
@ -179,6 +179,13 @@ impl UserCallback {
|
||||||
impl EventsLoop {
|
impl EventsLoop {
|
||||||
|
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
// Mark this thread as the main thread of the Cocoa event system.
|
||||||
|
//
|
||||||
|
// This must be done before any worker threads get a chance to call it
|
||||||
|
// (e.g., via `EventsLoopProxy::wakeup()`), causing a wrong thread to be
|
||||||
|
// marked as the main thread.
|
||||||
|
unsafe { appkit::NSApp(); }
|
||||||
|
|
||||||
EventsLoop {
|
EventsLoop {
|
||||||
shared: Arc::new(Shared::new()),
|
shared: Arc::new(Shared::new()),
|
||||||
modifiers: Modifiers::new(),
|
modifiers: Modifiers::new(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue