Window size (and position) gets fractionally scaled incorrectly when persistence
is enabled
#3797
Labels
bug
Something is broken
persistence
is enabled
#3797
Describe the bug
When persistence is enabled in eframe and
zoom_factor
is changed from the default, closing the window causes the saved window size to be scaled incorrectly.This also affects positioning when the application is ran a second time.
To Reproduce
Steps to reproduce the behavior:
1: Enable persistence
2: In the
AppCreator
change thezoom_factor
to something greater than1.0
3: Close window
4: Restart application
Expected behavior
The window should roughly be in the same place and with the same size on repeated starts.
Screenshots
Desktop (please complete the following information):
Additional context
It boils down to this:
In this function
egui/crates/egui-winit/src/window_settings.rs
Line 21 in 12ad9e7
Zoom factor is multiplied by the window factor
egui/crates/egui-winit/src/window_settings.rs
Line 24 in 12ad9e7
But in winit,
to_logical
is defined as:at: https://github.com/rust-windowing/winit/blob/v0.29.4/src/dpi.rs#L273-L278
Assume:
We set the
zoom_factor
to2.0
The window
scale_factor
is1.0
2.0 * 1.0
is2.0
to_logical(2.0)
will divide thewidth
andheight
by2.0
(reducing the window size by half, each time)
The inverse also holds, if the
zoom_factor
is set to0.5
, the window's size grows each run.Removing the multiplication, e.g. changing
egui/crates/egui-winit/src/window_settings.rs
Lines 22 to 24 in 12ad9e7
to
produces the correct behavior. But only when it doesn't persist the memory:
Edit:
The bug still exists when removing the multiplication and
persist_egui_memory
returns true.The text was updated successfully, but these errors were encountered: