From c97aa2062d7cc82ee855d134614d7d0721d99ee2 Mon Sep 17 00:00:00 2001 From: ardocrat Date: Thu, 20 Jun 2024 13:25:42 +0300 Subject: [PATCH] ui: fix window size detection --- src/gui/views/views.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/gui/views/views.rs b/src/gui/views/views.rs index e1f1e02..57331ba 100644 --- a/src/gui/views/views.rs +++ b/src/gui/views/views.rs @@ -77,18 +77,14 @@ impl View { /// Get width and height of app window. pub fn window_size(ui: &mut egui::Ui) -> (f32, f32) { + ui.ctx().input(|i| { return match i.viewport().inner_rect { None => { - if let Some(size) = i.viewport().monitor_size { - (size.x, size.y) - } else { - (AppConfig::DEFAULT_WIDTH, AppConfig::DEFAULT_HEIGHT) - } - } - Some(rect) => { + let rect = i.screen_rect; (rect.width(), rect.height()) - } + }, + Some(rect) => (rect.width(), rect.height()) }; }) }