Skip to content

eframe: several windows in series#1919

Merged
emilk merged 5 commits intomasterfrom
serial-windows
Aug 15, 2022
Merged

eframe: several windows in series#1919
emilk merged 5 commits intomasterfrom
serial-windows

Conversation

@emilk
Copy link
Copy Markdown
Owner

@emilk emilk commented Aug 15, 2022

Part of #1918

This attempts to allow opening several eframe windows after each other (one at the time).

Try it out with cargo run -p serial_windows.

This works on Windows (thanks to @zu1k), but on Mac I get winit::event::Event::LoopDestroyed right away for the second window, and then the even loops closes.

@zu1k
Copy link
Copy Markdown
Contributor

zu1k commented Aug 15, 2022

I add the following code to the start of GlowWinitApp.on_event() func, and found the second and third window receive some events which are not belong to them.

 if window_id != self.window().id() {
    println!("{event:?}");
    println!("window_id mismatch !");
    return EventResult::Wait;
}
# Running `target\debug\serial_windows.exe`
ModifiersChanged((empty))
window_id mismatch !
Focused(false)
window_id mismatch !
Destroyed
window_id mismatch !
ModifiersChanged((empty))
window_id mismatch !
Focused(false)
window_id mismatch !

@emilk
Copy link
Copy Markdown
Owner Author

emilk commented Aug 15, 2022

Ignoring events to the wrong window seems like a good idea, so I added that. The extra call to run_return does nothing on my Mac.

Does it now work as expected on Windows?

@zu1k
Copy link
Copy Markdown
Contributor

zu1k commented Aug 15, 2022

Does it now work as expected on Windows?

Yes, it works.

20220815_220324.mp4

@emilk
Copy link
Copy Markdown
Owner Author

emilk commented Aug 15, 2022

Well, that's nice! On Mac I get winit::event::Event::LoopDestroyed right away, and then the event loop closes. Well, perhaps I can merge this as at least a step in the right direction.

@emilk emilk marked this pull request as ready for review August 15, 2022 14:06
@emilk emilk merged commit 9c58f12 into master Aug 15, 2022
@emilk emilk deleted the serial-windows branch August 15, 2022 14:31
emilk added a commit that referenced this pull request Aug 20, 2022
Since #1919 we can continue
the application after closing the native window. It therefore makes
more sense to call `frame.close()` to close the native window,
instead of `frame.quit()`.
emilk added a commit that referenced this pull request Aug 20, 2022
Since #1919 we can continue
the application after closing the native window. It therefore makes
more sense to call `frame.close()` to close the native window,
instead of `frame.quit()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants