Skip to content

Commit

Permalink
update window position periodically
Browse files Browse the repository at this point in the history
  • Loading branch information
TicClick committed Oct 17, 2024
1 parent 70c9166 commit 243617c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/gui/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,16 @@ impl ApplicationWindow {
}

fn refresh_window_geometry_settings(&mut self, ctx: &egui::Context) {
let window = ctx.screen_rect();
self.s.settings.application.window.width = window.width() as i32;
self.s.settings.application.window.height = window.height() as i32;
ctx.input(|i| {
let window = i.screen_rect();
self.s.settings.application.window.width = window.width() as i32;
self.s.settings.application.window.height = window.height() as i32;

if let Some(rect) = i.viewport().inner_rect {
self.s.settings.application.window.x = rect.left_top().x as i32;
self.s.settings.application.window.y = rect.left_top().y as i32;
}
});
}

pub fn process_pending_events(&mut self, ctx: &egui::Context) {
Expand Down

0 comments on commit 243617c

Please sign in to comment.