Repository navigation
Page: give Blitz its viewport in device pixels (a Retina window's interface sits in a quarter of it) - #120
Merged
Conversation
Treamz
force-pushed
the
app-window-scale
branch
from
November 12, 2026 20:45
d0f845d to
65b3f1f
Compare
shinyobjectz
force-pushed
the
app-window-scale
branch
from
November 13, 2026 00:23
cbb0139 to
ec0a93e
Compare
Owner
|
Thanks, this is the right fix. Main moved under it: LR1 (7fb2194) moved the layout snapshot out of |
…s its image (shinyobjectz#119) a78fb95 gives the app window's page the display's scale. With a scale other than 1, raea-sys-page still gave Blitz a viewport whose window_size was the page's size in points. Blitz's window_size is in device pixels (it divides by hidpi_scale for the CSS viewport), as the page's image and paint_scene already are, so on a Retina display the interface was sharp but laid out in the top-left quarter of the window. Page::px is the page's size in device pixels, used for the image, the paint and the viewport. Nothing changes at scale 1.
… and devicePixelRatio is the page's scale With Blitz's viewport in device pixels, two readers of window_size in runtime/dom still took it for CSS px. snapshot sent it as vw and vh with dpr 1, so at scale 2 innerWidth and matchMedia answered twice the width the page is laid out at; elements tested boxes against a window twice the size, so elements up to a window's width off screen were listed as visible. Both read the viewport's logical size now, and dpr is its scale. tests/viewport.rs: a page at scale 2 lays a 100vw x 100vh element out at its size in CSS px; scale 1 is as it was; a fractional scale rounds the image up. Rebased onto main at 6da2995: main's LR1 (7fb2194) moved the layout snapshot into raea-sys-page (systems/page/src/snapshot.rs, snapshot_by, which a composition's page.layout answers too), so the vw, vh and dpr change is made there, and elements.rs re-exports it.
…rt.rs both use, not one copy each (dupes back to 293)
shinyobjectz
force-pushed
the
app-window-scale
branch
from
November 13, 2026 00:38
ec0a93e to
ce9e3af
Compare
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.
Fixes #119 (the half of it that a78fb95 leaves).
a78fb95 ("raea's window: the page is painted at the display's scale") landed while I was building my first version of this, and it fixes the blur the same way I had: the host page takes the window's scale. I've rebased onto it and dropped my change to
engine/page/host. What is left is the second place, which that commit doesn't touch.What is still wrong on main
On main at e165d0c (which has a78fb95), on a Retina display (scale 2), the app's interface is sharp but laid out in the top-left quarter of the window: in a 1440×900 pt window the whole feed, sidebar and footer sit in 720×450 pt and the rest is black.
systems/page/src/lib.rsgives BlitzViewport { window_size: page.size, hidpi_scale: page.scale }.page.sizeis in points, but Blitz'swindow_sizeis in device pixels (it divides byhidpi_scalefor the CSS viewport:vendor/blitz-dom/src/document.rs,scrolling.rs). The page's image andpaint_scenealready usesize * scale, so only the layout was half size. It never showed while every page's scale was 1.What changes
systems/page/src/lib.rs:Page::px()is the page's size in device pixels.configandresolvegive it to Blitz as the viewport, andsize_imagesandpaintuse it where they computed the same thing inline.runtime/dom/src/host/elements.rs: two readers ofwindow_sizetook it for CSS px.snapshotsent it to the page's JS asvw/vhwithdpr: 1, so with the viewport in device pixelsinnerWidthandmatchMediawould answer twice the width the page is laid out at;elementstested boxes against a window twice the size. Both readviewport().logical_size()now, anddpris the viewport's scale. (Found in a review of the first commit.)systems/page/tests/viewport.rs: a page at scale 2 lays a100vw x 100vhelement out at its size in CSS px; scale 1 is as it was; a fractional scale rounds the image up.Nothing changes at scale 1.
What I ran
On an M-series MacBook Pro (built-in Retina display, scale 2):
cargo test --release -p raea-sys-page --test viewport: 3 passed.cargo build --release -p raea-page-host --features window, then that binary in place of the 0.1.1 app's window (the app's own launcher and host, the installedfeed/page/app.js), read over its MCP:frame_pngis 2880×1800 with the interface in its top-left quarter.uilists 69 visible nodes, none past x = 1440;inputdown/up on "Library" in the sidebar opens the Library.What I didn't run
snapshot'svw/vh/dpr; I read the values' use insdk/ui/src/dombut didn't queryinnerWidthin the running window.__ui_viewportinruntime/dom/src/host/frames.rsstill starts atdpr: 1until the first layout snapshot.Page::pxrounds up, so there the CSS viewport can be a fraction of a CSS px wider than the window.