Skip to content

Page: give Blitz its viewport in device pixels (a Retina window's interface sits in a quarter of it) - #120

Merged
shinyobjectz merged 3 commits into
shinyobjectz:mainfrom
Treamz:app-window-scale
Nov 13, 2026
Merged

shinyobjectz merged 3 commits into
shinyobjectz:mainfrom
Treamz:app-window-scale

Conversation

@Treamz

@Treamz Treamz commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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.rs gives Blitz Viewport { window_size: page.size, hidpi_scale: page.scale }. page.size is in points, but Blitz's window_size is in device pixels (it divides by hidpi_scale for the CSS viewport: vendor/blitz-dom/src/document.rs, scrolling.rs). The page's image and paint_scene already use size * 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. config and resolve give it to Blitz as the viewport, and size_images and paint use it where they computed the same thing inline.
  • runtime/dom/src/host/elements.rs: two readers of window_size took it for CSS px. snapshot sent it to the page's JS as vw/vh with dpr: 1, so with the viewport in device pixels innerWidth and matchMedia would answer twice the width the page is laid out at; elements tested boxes against a window twice the size. Both read viewport().logical_size() now, and dpr is the viewport's scale. (Found in a review of the first commit.)
  • systems/page/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.

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 installed feed/page/app.js), read over its MCP:
    • main at e165d0c: frame_png is 2880×1800 with the interface in its top-left quarter.
    • this branch: 2880×1800, the interface fills the window, glyph edges about 1 px; ui lists 69 visible nodes, none past x = 1440; input down/up on "Library" in the sidebar opens the Library.

What I didn't run

  • The rest of the workspace's tests, and the new test against main to see it fail there (the quarter layout above is what it guards).
  • No test for snapshot's vw/vh/dpr; I read the values' use in sdk/ui/src/dom but didn't query innerWidth in the running window.
  • __ui_viewport in runtime/dom/src/host/frames.rs still starts at dpr: 1 until the first layout snapshot.
  • The player and the composition editor in the patched window, beyond the feed and the Library.
  • Windows and Linux, and a real display at a fractional scale: Page::px rounds up, so there the CSS viewport can be a fraction of a CSS px wider than the window.

@Treamz Treamz changed the title App window: paint the page at the display's scale (soft interface on Retina) Page: give Blitz its viewport in device pixels (a Retina window's interface sits in a quarter of it) Nov 12, 2026
@shinyobjectz

Copy link
Copy Markdown
Owner

Thanks, this is the right fix. Main moved under it: LR1 (7fb2194) moved the layout snapshot out of elements.rs into raea-sys-page (systems/page/src/snapshot.rs, snapshot_by), and a composition's page.layout answers from it too. So I rebased your two commits onto main (you're still the author) and made your vw/vh/dpr change in snapshot_by. elements.rs keeps your logical_size() window and now re-exports the snapshot. Nothing else changed. It merges once CI passes, in time for 0.1.3.

Treamz and others added 3 commits November 12, 2026 16:38
…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
shinyobjectz merged commit ea741f6 into shinyobjectz:main Nov 13, 2026
4 checks passed
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.

Mac app: the whole interface is drawn at 1x and stretched on a Retina display

2 participants