mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
Merge pull request #238 from GuildMasterInfinite/gui-thread
Use `IsGUIThread` to initialize message queue
This commit is contained in:
commit
28eddb64a9
|
@ -98,16 +98,16 @@ impl EventsLoop {
|
||||||
});
|
});
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut msg = mem::uninitialized();
|
|
||||||
|
|
||||||
// Calling `PostThreadMessageA` on a thread that does not have an events queue yet
|
// Calling `PostThreadMessageA` on a thread that does not have an events queue yet
|
||||||
// will fail. In order to avoid this situation, we call `PeekMessage` to initialize
|
// will fail. In order to avoid this situation, we call `IsGuiThread` to initialize
|
||||||
// it.
|
// it.
|
||||||
user32::PeekMessageA(&mut msg, ptr::null_mut(), 0, 0, 0);
|
user32::IsGUIThread(1);
|
||||||
// Then only we unblock the `new()` function. We are sure that we don't call
|
// Then only we unblock the `new()` function. We are sure that we don't call
|
||||||
// `PostThreadMessageA()` before `new()` returns.
|
// `PostThreadMessageA()` before `new()` returns.
|
||||||
local_block_tx.send(()).unwrap();
|
local_block_tx.send(()).unwrap();
|
||||||
|
|
||||||
|
let mut msg = mem::uninitialized();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if user32::GetMessageW(&mut msg, ptr::null_mut(), 0, 0) == 0 {
|
if user32::GetMessageW(&mut msg, ptr::null_mut(), 0, 0) == 0 {
|
||||||
// Only happens if the message is `WM_QUIT`.
|
// Only happens if the message is `WM_QUIT`.
|
||||||
|
|
Loading…
Reference in a new issue