Skip to content

fix: clamp Quick Preview panel to its intended size - #8

Merged
green2grey merged 2 commits into
mainfrom
fix/preview-panel-clamp
Jul 6, 2026
Merged

fix: clamp Quick Preview panel to its intended size#8
green2grey merged 2 commits into
mainfrom
fix/preview-panel-clamp

Conversation

@green2grey

Copy link
Copy Markdown
Member

Follow-up to #5, addressing Codex's post-merge finding: set_size_request is only a minimum and gtk::Overlay allocates 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::Clamp widgets (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.

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.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f3daaf4f-6b25-4a32-9c53-c9b0cd890ad9

📥 Commits

Reviewing files that changed from the base of the PR and between fb14785 and ada98fb.

📒 Files selected for processing (1)
  • crates/quickview-ui/src/windows/quick_preview.rs

Walkthrough

The layer-shell preview panel rendering now wraps the viewer widget inside nested adw::Clamp containers to constrain maximum panel width and height, replacing the previous direct widget attachment. Non-layer-shell fallback rendering is unchanged.

Changes

Preview Panel Clamping

Layer / File(s) Summary
Wrap viewer widget in nested clamps
crates/quickview-ui/src/windows/quick_preview.rs
The centered panel now appends a horizontal adw::Clamp wrapping a vertical adw::Clamp around the viewer widget, capping dimensions to PANEL_WIDTH and PANEL_HEIGHT instead of appending the raw widget.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A clamp within a clamp, so neat,
Keeps the preview panel's edges tidy and sweet.
No more oversized pics spilling free,
Just a snug little box, as boxed as can be. 🐇📦

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: clamping the Quick Preview panel to its intended size.
Description check ✅ Passed The description covers the fix, verification, and impact, though it doesn't use the template's exact Summary/Checklist structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/preview-panel-clamp

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@green2grey
green2grey merged commit a42ecad into main Jul 6, 2026
3 checks passed
@green2grey
green2grey deleted the fix/preview-panel-clamp branch July 6, 2026 08:12
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