Browse Source

eframe: make sure to update native_pixels_per_point when dpi changes (#2256)

* eframe: make sure to update native_pixels_per_point when dpi changes

* Update changelog
pull/2261/head
Emil Ernerfeldt 2 years ago
committed by GitHub
parent
commit
eec18290a4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      crates/eframe/CHANGELOG.md
  2. 10
      crates/eframe/src/native/epi_integration.rs

3
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 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: 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)). * 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 ## 0.19.0 - 2022-08-20

10
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(); *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 { let frame = epi::Frame {
info: epi::IntegrationInfo { info: epi::IntegrationInfo {
system_theme, system_theme,
cpu_usage: None, 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()), window_info: read_window_info(window, egui_ctx.pixels_per_point()),
}, },
output: Default::default(), output: Default::default(),
@ -248,8 +250,7 @@ impl EpiIntegration {
let mut egui_winit = egui_winit::State::new(event_loop); let mut egui_winit = egui_winit::State::new(event_loop);
egui_winit.set_max_texture_side(max_texture_side); egui_winit.set_max_texture_side(max_texture_side);
let pixels_per_point = window.scale_factor() as f32; egui_winit.set_pixels_per_point(native_pixels_per_point);
egui_winit.set_pixels_per_point(pixels_per_point);
Self { Self {
frame, frame,
@ -292,6 +293,9 @@ impl EpiIntegration {
state: ElementState::Pressed, state: ElementState::Pressed,
.. ..
} => self.can_drag_window = true, } => self.can_drag_window = true,
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
self.frame.info.native_pixels_per_point = Some(*scale_factor as _);
}
_ => {} _ => {}
} }

Loading…
Cancel
Save