From 9f6e80f94a8144f04698caeda93ab6a1bbf0c9e1 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 7 Nov 2022 12:19:46 +0100 Subject: [PATCH 1/2] eframe: make sure to update native_pixels_per_point when dpi changes --- crates/eframe/src/native/epi_integration.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index 66c9ab4f6e9..9d9d51e0311 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -231,11 +231,13 @@ impl EpiIntegration { *egui_ctx.memory() = load_egui_memory(storage.as_deref()).unwrap_or_default(); + let native_pixels_per_point = window.scale_factor() as f32; + let frame = epi::Frame { info: epi::IntegrationInfo { system_theme, cpu_usage: None, - native_pixels_per_point: Some(native_pixels_per_point(window)), + native_pixels_per_point: Some(native_pixels_per_point), window_info: read_window_info(window, egui_ctx.pixels_per_point()), }, output: Default::default(), @@ -248,8 +250,7 @@ impl EpiIntegration { let mut egui_winit = egui_winit::State::new(event_loop); egui_winit.set_max_texture_side(max_texture_side); - let pixels_per_point = window.scale_factor() as f32; - egui_winit.set_pixels_per_point(pixels_per_point); + egui_winit.set_pixels_per_point(native_pixels_per_point); Self { frame, @@ -292,6 +293,9 @@ impl EpiIntegration { state: ElementState::Pressed, .. } => self.can_drag_window = true, + WindowEvent::ScaleFactorChanged { scale_factor, .. } => { + self.frame.info.native_pixels_per_point = Some(*scale_factor as _); + } _ => {} } From 5a1e62f928493a1cfbc65d2a9c04ed7963d7392c Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 7 Nov 2022 12:21:02 +0100 Subject: [PATCH 2/2] Update changelog --- crates/eframe/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/eframe/CHANGELOG.md b/crates/eframe/CHANGELOG.md index 6c4932985e0..31f81715dc1 100644 --- a/crates/eframe/CHANGELOG.md +++ b/crates/eframe/CHANGELOG.md @@ -15,7 +15,8 @@ NOTE: [`egui-winit`](../egui-winit/CHANGELOG.md), [`egui_glium`](../egui_glium/C * Web: you can access your application from JS using `AppRunner::app_mut`. See `crates/egui_demo_app/src/lib.rs`. * Web: You can now use WebGL on top of `wgpu` by enabling the `wgpu` feature (and disabling `glow` via disabling default features) ([#2107](https://github.com/emilk/egui/pull/2107)). * Web: Add `WebInfo::user_agent` ([#2202](https://github.com/emilk/egui/pull/2202)). -* * Wgpu device/adapter/surface creation has now various configuration options exposed via `NativeOptions/WebOptions::wgpu_options` ([#2207](https://github.com/emilk/egui/pull/2207)). +* Wgpu device/adapter/surface creation has now various configuration options exposed via `NativeOptions/WebOptions::wgpu_options` ([#2207](https://github.com/emilk/egui/pull/2207)). +* Fix: Make sure that `native_pixels_per_point` is updated ([#2256](https://github.com/emilk/egui/pull/2256)). ## 0.19.0 - 2022-08-20