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
This commit is contained in:
VinTarZ 2024-08-26 16:36:30 +03:00 committed by GitHub
parent 0513c05768
commit 9f2f5f7292
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -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::<f32>(egui_zoom_factor as f64 * monitor.scale_factor());