Repository navigation
Improve window restoration logic - #8687
Merged
Merged
Conversation
- Create the window normal, move it, then maximize or enter fullscreen (Mac and Windows), so moving no longer resets either state. - Clamp the saved position once and use the clamped settings for the exact move too. - Drop a saved Mac position that is on no connected monitor; zooming an off-screen window gave it zero height and crashed wgpu. - Fall back to defaults for old save files instead of a 64x64 window. - Remember the startup geometry when nothing was saved yet. - Keep X11/Wayland on the builder-only path. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019yMtdim1FPCsviY1FWfdTk
|
Preview available at https://egui-pr-preview.github.io/pr/8687-lucasfix-window-restoration View snapshot changes at kitdiff |
…indows eframe creates its window hidden until the first frame is painted. winit implements maximize with `ShowWindow(SW_MAXIMIZE)`, which shows the hidden window, and then hides it again, so the window flashed on screen before the real show. On Windows, a window created hidden is no longer maximized via its window attributes. `apply_viewport_builder_to_window` maximizes it instead, with the window cloaked (`DWMWA_CLOAK`) so the brief show is never composited. The window is already maximized when first shown, so the first frame is rendered at the right size. Can be removed once winit has rust-windowing/winit#4575 or #4587. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`WindowSettings::initialize_window` maximizes the still-hidden window after moving it, which goes through winit's `ShowWindow(SW_MAXIMIZE)` and briefly shows it. Use the new `egui_winit::set_maximized`, which cloaks a hidden window while maximizing it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lucasmerlin
marked this pull request as ready for review
October 12, 2026 14:17
emilk
approved these changes
Oct 13, 2026
emilk
left a comment
Owner
There was a problem hiding this comment.
Wow this is complicated 😓
Thanks for testing on all the platforms.
Did you also test with multiple monitors with different DPIs?
Comment on lines
+1034
to
+1035
| // The event can be stale: winit buffers events emitted while we create and set up | ||
| // the window (e.g. maximize it), so it can arrive after the window has changed size again. |
Collaborator
Author
Yes! It works perfectly everywhere now for me, on my hdpi laptop screen and my lowdpi monitor (except wayland, where you can't programmatically set window positions, so the restored position is up to the window manager) |
lucasmerlin
enabled auto-merge (squash)
October 13, 2026 08:34
1 task done
dfrnoch
added a commit
to ViceVerse-cz/Serein
that referenced
this pull request
Oct 15, 2026
Picks up window restoration fixes (emilk/egui#8687), including stale Resized handling, Windows system-font CJK fallback (emilk/egui#8688) and premultiplied clipboard image copies (emilk/egui#8715). All apply without code changes; eframe window persistence stays disabled. Sync license provenance with the pinned revision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 task done
lucasmerlin
pushed a commit
that referenced
this pull request
Nov 9, 2026
* Follow-up to #5211 and #8687 #5211 made `egui_winit::screen_size_in_pixels` use `outer_size()` on iOS, so egui lays out over the whole screen, including the area behind the Dynamic Island and home indicator. But eframe's wgpu backend still creates and resizes the surface from `inner_size()`, which on iOS is only the safe area. The OS then stretches the smaller surface over the screen. The UI is drawn taller than its layout, about 11% on an iPhone 16 Pro Max. Bottom panels end up off screen and touches land away from what they hit. This PR adds `egui_wgpu::winit::surface_size(window)`, which returns `outer_size()` on iOS and `inner_size()` everywhere else, and uses it: - in `Painter::set_window` and `Painter::set_window_unsafe`, where the surface is created - in eframe's `WindowEvent::Resized` handler Other platforms are unchanged. Found while running an eframe app (LightCraft) on an iPhone 16 Pro Max. The fix has been in use there since; with it, the layout and the drawn frame match exactly. * [x] I have followed the instructions in the PR template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
eframe now remembers the window's last normal (not maximized, not fullscreen) size and position. After a relaunch, un-maximizing or leaving fullscreen goes back to that size instead of a window that is "maximized but not maximized".
Other fixes:
ShowWindow(SW_MAXIMIZE), which shows the still-hidden window before hiding it again. The newegui_winit::set_maximizedcloaks a hidden window (DWMWA_CLOAK) while maximizing it, so it stays invisible but is already maximized for the first frame. This is a workaround until winit has win32: avoid showing hidden windows when applying window state rust-windowing/winit#4575 or winit-win32: Fix Window focus after showing hidden maximized window rust-windowing/winit#4587._NET_WM_STATEclient messages, which window managers ignore while the window is still hidden (eframe keeps it hidden until the first frame is painted). The newWindowSettings::after_first_showre-applies them right after the window is shown.before_first_showreplaces the macOS-onlyenter_fullscreen_after_first_frame/enter_deferred_fullscreen.The save format changed, so old saved window settings are ignored once (the window opens at its default size).
Known limitations:
org.gnome.mutter auto-maximize).Tested on macOS, wayland, x11 (XWayland on GNOME, including two monitors) and Windows (wgpu and glow).
🤖 Generated with Claude Code
https://claude.ai/code/session_019yMtdim1FPCsviY1FWfdTk