Added the keep_running builder to prevent the event loop from stopping when no windows are open

This commit is contained in:
Laurent Stéphenne 2025-08-20 00:32:19 -04:00
parent d273aca1c1
commit 0bbb6c0f25
No known key found for this signature in database
GPG key ID: 1F1C47D520393678
7 changed files with 36 additions and 6 deletions

View file

@ -92,6 +92,7 @@ pub(crate) struct LinuxCommon {
pub(crate) text_system: Arc<dyn PlatformTextSystem>,
pub(crate) appearance: WindowAppearance,
pub(crate) auto_hide_scrollbars: bool,
pub(crate) quit_when_last_window_closes: bool,
pub(crate) callbacks: PlatformHandlers,
pub(crate) signal: LoopSignal,
pub(crate) menus: Vec<OwnedMenu>,
@ -118,6 +119,7 @@ impl LinuxCommon {
text_system,
appearance: WindowAppearance::Light,
auto_hide_scrollbars: false,
quit_when_last_window_closes: true,
callbacks,
signal,
menus: Vec::new(),
@ -148,6 +150,10 @@ impl<P: LinuxClient + 'static> Platform for P {
self.with_common(|common| common.callbacks.keyboard_layout_change = Some(callback));
}
fn set_quit_when_last_window_closes(&self, should_quit: bool) {
self.with_common(|common| common.quit_when_last_window_closes = should_quit);
}
fn run(&self, on_finish_launching: Box<dyn FnOnce()>) {
on_finish_launching();