fix: clamp Quick Preview panel to its intended size - #8
Conversation
The canvas measures at the image's natural size and gtk::Overlay allocates centered overlay children at natural size, so any image larger than 900x700 grew the panel over the whole layer surface: no backdrop left to click and the image rendered 1:1 cropped instead of fit. Nested adw::Clamp widgets (horizontal + vertical) cap the maximum while the existing size request keeps the minimum, pinning the panel at exactly 900x700. Found by Codex review on PR #5 post-merge.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 31 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe layer-shell preview panel rendering now wraps the viewer widget inside nested ChangesPreview Panel Clamping
Estimated code review effort: 1 (Trivial) | ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb14785f8e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // the clamps cap the maximum, so the panel is exactly | ||
| // PANEL_WIDTH x PANEL_HEIGHT and the canvas letterboxes inside it. | ||
| let vclamp = adw::Clamp::builder() | ||
| .maximum_size(PANEL_HEIGHT) |
There was a problem hiding this comment.
Set clamp thresholds to keep panel bounded
For large images this still lets the overlay child measure larger than the intended panel: AdwClamp::maximum_size caps the child allocation, but the clamp keeps its default tightening_threshold (400), so its own natural size eases out to about 400 + 3 * (maximum - 400) (1900px wide, 1300px tall here). Because gtk::Overlay allocates centered overlays at their natural size, a 1080p layer-shell surface can still have the preview panel fill the height and leave no clickable backdrop. Set the tightening threshold to the same value as the maximum (for both clamps) or otherwise force the clamp/panel natural size to 900×700.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid — AdwClamp's easing means the clamp's natural size runs past maximum_size when tightening_threshold (default 400) is below it, and the Overlay allocates that natural size. Fixed in ada98fb: both clamps now set tightening_threshold equal to maximum_size, removing the easing margin so the panel's natural size is truly capped at 900×700.
AdwClamp's default tightening_threshold (400) makes the clamp's own natural size ease out well past maximum_size to give the child a run-in, and gtk::Overlay allocates centered children at natural size — so a large image could still push the panel to ~1900x1300. Threshold == maximum removes the easing margin entirely. Found by Codex on PR #8.
Follow-up to #5, addressing Codex's post-merge finding:
set_size_requestis only a minimum andgtk::Overlayallocates centered overlay children at natural size, while the canvas measures at the image's natural dimensions — so any image larger than 900×700 grew the panel over the entire layer surface (no clickable backdrop, image cropped 1:1 instead of fit).Fix: nested
adw::Clampwidgets (horizontal max 900, vertical max 700) cap the maximum; the existing size request keeps the minimum. The panel is now pinned at exactly 900×700 and the canvas letterboxes inside it.Verified: fmt/clippy/tests green; smoke-ran with a generated 3200×2200 image (no errors; panel geometry is defined adw::Clamp behavior). Worth a quick visual check that backdrop clicks still dismiss with a big image.