mirror of
https://github.com/project-gauntlet/gauntlet.git
synced 2025-12-23 10:35:53 +00:00
Implement client window closing on unfocus
This commit is contained in:
parent
d386e63543
commit
00da2bbcb6
1 changed files with 12 additions and 0 deletions
|
|
@ -38,6 +38,7 @@ pub struct AppModel {
|
|||
search_results: Vec<NativeUiSearchResult>,
|
||||
request_rx: Arc<TokioRwLock<RequestReceiver<(PluginId, NativeUiRequestData), NativeUiResponseData>>>,
|
||||
search_field_id: text_input::Id,
|
||||
waiting_for_next_unfocus: bool
|
||||
}
|
||||
|
||||
enum NavState {
|
||||
|
|
@ -135,6 +136,7 @@ impl Application for AppModel {
|
|||
state: vec![NavState::SearchView { prompt: None }],
|
||||
search_results: vec![],
|
||||
search_field_id: search_field_id.clone(),
|
||||
waiting_for_next_unfocus: false,
|
||||
},
|
||||
Command::batch([
|
||||
Command::perform(async {}, |_| AppMsg::PromptChanged("".to_owned())),
|
||||
|
|
@ -248,6 +250,16 @@ impl Application for AppModel {
|
|||
_ => Command::none()
|
||||
}
|
||||
}
|
||||
AppMsg::IcedEvent(Event::Window(iced::window::Event::Unfocused)) => {
|
||||
// for some reason Unfocused fires right at the application start
|
||||
// and second time on actual window unfocus
|
||||
if self.waiting_for_next_unfocus {
|
||||
iced::window::close()
|
||||
} else {
|
||||
self.waiting_for_next_unfocus = true;
|
||||
Command::none()
|
||||
}
|
||||
}
|
||||
AppMsg::IcedEvent(_) => Command::none(),
|
||||
AppMsg::WidgetEvent { widget_event: ComponentWidgetEvent::PreviousView, .. } => self.previous_view(),
|
||||
AppMsg::WidgetEvent { widget_event, plugin_id } => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue