Skip to content

eframe: restore the window's size whatever the zoom factor was - #8656

Open
crmne wants to merge 1 commit into
emilk:mainfrom
crmne:eframe-zoom-independent-window-size
Open

crmne wants to merge 1 commit into
emilk:mainfrom
crmne:eframe-zoom-independent-window-size

Conversation

@crmne

@crmne crmne commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

WindowGeometry::from_window stores the inner size in points at the context's zoom factor. eframe restores it while building the next window, into a context whose zoom factor is usually still 1, since apps call Context::set_zoom_factor after the window exists. A window saved at zoom 1.25 therefore comes back 20% smaller on every start.

WindowGeometry now also stores the zoom factor its size was measured at, and eframe converts the size to the zoom factor the window is built with (WindowSettings::convert_to_zoom_factor). Because the zoom factor sits next to the size, the normal geometry kept while a window is maximized converts too. Settings saved without a zoom factor keep their size, and nothing changes at zoom factor 1.

Tests cover saving at 1.25 and 2.0 and restoring at 1, a RON round trip, and loading settings without a zoom factor.

  • I have followed the instructions in the PR template

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Preview available at https://egui-pr-preview.github.io/pr/8656-eframe-zoom-independent-window-size
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

crmne added a commit to crmne/zapfast that referenced this pull request Oct 3, 2026
The shared forks now carry four fixes every app on them wanted:

- winit orders a dropped macOS window out before closing it. On Touch Bar
  Macs AppKit threw while tearing the window down, and the closed window
  stayed on screen, looking frozen (#260, rust-windowing/winit#4728).
- egui moves the accessibility focus to the root when the focused widget
  has no node yet, which crashed renaming a group on Windows (#313,
  emilk/egui#8621).
- eframe falls back to a compatibility-profile OpenGL context, so drivers
  without OpenGL 3.3 or ES through WGL can still start the app (#349,
  emilk/egui#8655).
- eframe saves the zoom factor with the window size, so a window no longer
  shrinks each time it reopens at a zoom other than 100% (#293,
  emilk/egui#8656). ZapFast's own window_builder hook for that is removed:
  with the fixed eframe it would scale the size twice.
intellq pushed a commit to intellq/zapfast that referenced this pull request Oct 3, 2026
The shared forks now carry four fixes every app on them wanted:

- winit orders a dropped macOS window out before closing it. On Touch Bar
  Macs AppKit threw while tearing the window down, and the closed window
  stayed on screen, looking frozen (crmne#260, rust-windowing/winit#4728).
- egui moves the accessibility focus to the root when the focused widget
  has no node yet, which crashed renaming a group on Windows (crmne#313,
  emilk/egui#8621).
- eframe falls back to a compatibility-profile OpenGL context, so drivers
  without OpenGL 3.3 or ES through WGL can still start the app (crmne#349,
  emilk/egui#8655).
- eframe saves the zoom factor with the window size, so a window no longer
  shrinks each time it reopens at a zoom other than 100% (crmne#293,
  emilk/egui#8656). ZapFast's own window_builder hook for that is removed:
  with the fixed eframe it would scale the size twice.

(cherry picked from commit 4b0f79b)

Fork: vendor/winit recebe o diff fb8b24c..ed7caa9 do crmne/winit, mantendo
o patch de posição do arrasto; fica o size_within_monitor do fork.
`WindowSettings::from_window` stores the inner size in points at the
context's zoom factor, and eframe restores it into the context that
builds the next window. Apps usually call `Context::set_zoom_factor`
after that window exists, so the zoom factor there is still 1, and a
window saved at a zoom factor of 1.25 came back 20% smaller on every
start.

Save the zoom factor next to the size, and have eframe express the size
at the zoom factor the window is built with. Settings saved without it
keep their size, as before; nothing changes at a zoom factor of 1.
@crmne
crmne force-pushed the eframe-zoom-independent-window-size branch from b0b0717 to 7bd9491 Compare October 14, 2026 21:17
@crmne

crmne commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto #8687: the zoom factor now sits next to the size in WindowGeometry.

caue-r pushed a commit to caue-r/zapfast that referenced this pull request Nov 8, 2026
The shared forks now carry four fixes every app on them wanted:

- winit orders a dropped macOS window out before closing it. On Touch Bar
  Macs AppKit threw while tearing the window down, and the closed window
  stayed on screen, looking frozen (crmne#260, rust-windowing/winit#4728).
- egui moves the accessibility focus to the root when the focused widget
  has no node yet, which crashed renaming a group on Windows (crmne#313,
  emilk/egui#8621).
- eframe falls back to a compatibility-profile OpenGL context, so drivers
  without OpenGL 3.3 or ES through WGL can still start the app (crmne#349,
  emilk/egui#8655).
- eframe saves the zoom factor with the window size, so a window no longer
  shrinks each time it reopens at a zoom other than 100% (crmne#293,
  emilk/egui#8656). ZapFast's own window_builder hook for that is removed:
  with the fixed eframe it would scale the size twice.
aleliras added a commit to aleliras/zapfast that referenced this pull request Nov 23, 2026
The shared forks now carry four fixes every app on them wanted:

- winit orders a dropped macOS window out before closing it. On Touch Bar
  Macs AppKit threw while tearing the window down, and the closed window
  stayed on screen, looking frozen (crmne#260, rust-windowing/winit#4728).
- egui moves the accessibility focus to the root when the focused widget
  has no node yet, which crashed renaming a group on Windows (crmne#313,
  emilk/egui#8621).
- eframe falls back to a compatibility-profile OpenGL context, so drivers
  without OpenGL 3.3 or ES through WGL can still start the app (crmne#349,
  emilk/egui#8655).
- eframe saves the zoom factor with the window size, so a window no longer
  shrinks each time it reopens at a zoom other than 100% (crmne#293,
  emilk/egui#8656). ZapFast's own window_builder hook for that is removed:
  with the fixed eframe it would scale the size twice.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant