Skip to content

Commit

Permalink
Refresh UI on window focus
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX committed Jun 29, 2024
1 parent 11c8c11 commit 1451f48
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions egui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ struct UiState {

query: String,
search_results: Vec<UiEntry>,

was_focused: bool,
skipped_first_focus: bool,
}

#[derive(Debug)]
Expand Down Expand Up @@ -587,6 +590,16 @@ fn main_ui(
.and_then(|()| requests.send(Command::LoadFirstPage));
};

ui.input(|i| {
if !state.was_focused && i.focused && state.skipped_first_focus {
refresh();
}
if i.focused {
state.skipped_first_focus = true;
}
state.was_focused = i.focused;
});

if let Some(ref e) = state.fatal_error {
ui.label(format!("Fatal error: {e:?}"));
return;
Expand Down

0 comments on commit 1451f48

Please sign in to comment.