Egui persistence test#20
Conversation
Skip the hardcoded with_inner_size and first-frame DPI resize when eframe has persisted window state from a previous session. Both paths now check for app.ron existence so the default 1280x720 only applies on first launch.
|
I tested it and window size was indeed not restoring. Two things were overriding eframe's restore:
The fix I pushed should now restore window size as well as positions, and I verified it working on macOS and Ubuntu. Can you verify it works on your Windows? |
|
Windows was already working as "intended" (It restore size and position correctly in window mode, but doesn't have the features we implemented for the iced version) before your commit, it seems Windows wasn't affect by your forced I think my requirements are edge cases. I'll see what I can do after completing the compressed file support and slider preview with possible additional PR if you want to merge this one. |
|
I was also trying the window persistence, but it has some annoying bugs, at least on Windows. The first one is that when restoring a maximized window, it briefly flashes white. I'm pretty sure that's an issue in winit, I made a PR here - rust-windowing/winit#4575. Basically, when the app is launched initially with the hidden and maximized state, winit first calls winapi's maximize API, which briefly shows the window, and then immediately hides it. The second one is that the normal window size is not persisted when maximized in egui. So when you unmaximize the window, it doesn't get restored to the previous size. Winit doesn't have an API that would return the normal window size, so I could only fix it by calling winapi in egui, and even that has some potentially sketchy cross-coordinate stuff, so I ignored it. Right now, the maximized window persistence on Windows is really annoying. |
|
Does the iced version work for you? |
The iced version is a bit less broken, but also acts weird when restoring the window. See video. Recording.2026-05-24.122318_1.mp4.mp4But I am using the egui version, since it feels a bit better to me. |
|
I'd say it's not perfect, but it gets the job done. The reason I'm asking is that, at worst, I can port the code made for the Iced version, but I'm not sure the added code complexity is worth it. Even then, the outcome might not satisfy your expectations. |
|
Oh, I don't have a strong opinion. Of course, ideally, the egui persistence would work perfectly, but that isn't the case. I already tried doing it directly in viewskater, and it was mostly passable, including getting rid of the white flash (iirc I created the window hidden, and maximized it a bit later, but that showed the maximizing animation), but it was a bit too.. I wasn't comfortable with that being the final implementation. I only got it working well with the winit and egui patches, but I have no idea if those will get merged. Well, except for the unmaximized size. I imagine it's possible without using the winapi by persisting the last window size when not maximized/minimized. |
|
Check my new implementation and see if that works for you, I think this PR might not be needed if there's no upstream changes. |
Seems to work fine, except for the white flash and the unmaximize not remembering the size. This PR emilk/egui#8191 was just merged in egui, so in theory, the egui persistence should work almost the same as your implementation, with the only difference being that, in your PR, unmaximize restores a smaller window, and in egui's persistence, it restores the maximized size. If the winit fix gets merged, I think it should fix the white flash in both your implementation and in the egui persistence. |
|
Thanks! I found another problem: when you set the scaling to anything other than 100% for a high-resolution monitor on Windows, maximized or full-screen window does not recover properly on the next startup in my implementation, I'll keep digging. |
|
Ok I reproduced these issues on Windows 10 dual monitor setup:
For 1, @YelovSK opened rust-windowing/winit#4575 but winit tends to be slow on PRs so probably not getting merged soon. For 3, @YelovSK's emilk/egui#8191 was merged, but we're pinned to egui 0.31 and it's not available yet. Given these, I think implementing custom persistence (PR #29's direction) is the right approach. |
|
I think updating to egui 0.35 is a chore and a lot of works to even get it to compile. This needs a separate PR to do if that's the direction we're heading. Incomplete summariesReplace improved-popups-tooltips-and-menus Some deprecations are easy, but others need additional testing. |
This feature will create
data\app.ronfile in storage_dir.2: 1920x1080
It doesn't retain the previous window size when exiting in fullscreen mode, and when you exit application while in fullscreen on monitor 1, it restores to 2 at next startup on Windows, if there's other issues on other platform, I'll port the code from iced version.