From 9f2f5f729285a24062b58bca37684d4ee3bb1f39 Mon Sep 17 00:00:00 2001 From: VinTarZ Date: Mon, 26 Aug 2024 16:36:30 +0300 Subject: [PATCH] Fix eframe centering on multiple monitor systems (#4919) On multiple-monitor systems, eframe was incorrectly selecting first ones dimensions for centering Would also appretiate releasing 0.28.2 with fix included on crates.io --- crates/eframe/src/native/epi_integration.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index 65b54d65e23..5f9d555e3a5 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -68,7 +68,10 @@ pub fn viewport_builder( #[cfg(not(target_os = "ios"))] if native_options.centered { crate::profile_scope!("center"); - if let Some(monitor) = event_loop.available_monitors().next() { + if let Some(monitor) = event_loop + .primary_monitor() + .or_else(|| event_loop.available_monitors().next()) + { let monitor_size = monitor .size() .to_logical::(egui_zoom_factor as f64 * monitor.scale_factor());