web: fullscreen keeps the display's aspect ratio on any page shell#260
Merged
Conversation
In real element fullscreen the page glue relied on the host page's CSS to letterbox the canvas, and only the hosted /try shell had a :fullscreen rule: any other embedding kept its normal width:100% canvas rule, stretching the picture to the monitor's shape (grotesquely so on ultrawide monitors). Even the hosted rule letterboxed via object-fit at the presentation buffer's own ratio (the PAL capture is 668x540), not the 4:3 TV shape the page layout gives the canvas. The glue now letterboxes with inline styles in both fullscreen paths: the canvas becomes the largest 4:3 box that fits the screen, centred, with object-fit pinned to fill so a shell's own :fullscreen rule cannot re-letterbox the bitmap inside the box. Dynamic viewport units measure the monitor exactly in real fullscreen and track the visible area in the pinned iPhone fallback, where plain vh reaches under Safari's chrome. cssToEmu() loses its fullscreen special case since the bitmap now fills the element in every mode, and docs/guide/browser.md gains the previously undocumented fullscreen behaviour.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes browser fullscreen rendering for Copperline’s web build so the emulator display preserves a consistent 4:3 aspect ratio across any embedding shell (not just the hosted /try page), avoiding visible stretching on wide/ultrawide monitors.
Changes:
- Apply a 4:3 “largest box that fits” fullscreen letterbox via inline canvas styles (
CSS_FS_CANVAS) so it works in all embedding shells. - Apply/remove the fullscreen canvas styling on
fullscreenchange(real element fullscreen), not only in the CSS-pinned fallback path. - Document the fullscreen behavior (including the iPhone pinned fallback) in
docs/guide/browser.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/guide/browser.md | Documents expected fullscreen + iPhone fallback behavior for the browser build. |
| crates/copperline-web/www/try.js | Enforces consistent 4:3 fullscreen sizing via inline styles and updates fullscreen event handling and CSS→emulated scaling logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The presentation buffer is not the canvas element's shape (the PAL capture is 668x540 shown as 4:3), so emulated pixels per CSS pixel differ between the axes; sharing the width ratio skewed vertical pointer speed by ~8% and made the unlocked cursor-follow pointer drift vertically from the host cursor. Long-standing in the page layout, and the fullscreen letterbox now shows the same geometry, so scale each axis by its own ratio in the pointer-lock, cursor-follow and touch trackpad delta paths.
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.
Fullscreen in the browser build stretched the picture to the monitor's aspect ratio on any page shell without its own
:fullscreenCSS - very visibly on ultrawide monitors.Root cause. In real element fullscreen
try.jsrelied entirely on the host page's stylesheet to letterbox the canvas, and only the hosted /try shell carries a:fullscreenrule; any other embedding (the retro32 page, self-hosted shells) keeps its normalwidth: 100%canvas rule, which fills the monitor. The hosted rule was also subtly off:object-fit: containletterboxes at the presentation buffer's own ratio (the PAL capture is 668x540, about 1.24:1), not the 4:3 TV shape every shell gives the canvas in the page layout.Fix, all in the page glue so it holds on every embedding:
CSS_FS_CANVASnow makes the canvas the largest 4:3 box that fits the screen, centred by auto margins, withobject-fitpinned tofillso a shell's own:fullscreenrule cannot re-letterbox the bitmap inside the box. Dynamic viewport units (dvw/dvh) measure the monitor exactly in real fullscreen and track the visible area in the pinned iPhone fallback, where plainvhreaches under Safari's chrome.fullscreenchangefor real fullscreen (previously only the CSS fallback got them) and removed on any exit, Esc included.cssToEmu()loses its fullscreen special case: the bitmap fills the canvas element in every mode now, so the width ratio is the displayed scale.docs/guide/browser.mddocuments the fullscreen behaviour, which had no doc coverage.Verified by serving the real page shell with the modified glue and driving Chrome: in fullscreen the canvas measures exactly 4:3 (ratio 1.3333), centred with equal pillarbox bars on a 1.75:1 viewport, and exiting restores the page layout with all inline styles cleared. Chrome denies
requestFullscreento automation input, so the scripted run exercised the pinned-shell fallback path; it applies the identical style object through the same fullscreenchange listener, but the real-fullscreen entry itself still wants a one-click manual check on a wide monitor.Follow-up for the website repository (not part of this PR): the
.try-shell:fullscreen #screenrule intry/index.htmlis now redundant - the inline styles override it - and can be dropped.