Repository navigation
feat(screenshot): support 4-corner resizing while holding Ctrl - #3259
Conversation
- Hit-test selection corners when Ctrl is held to allow resizing. - Set opposite corner as fixed anchor and update dynamic cursor shape (NwseResize/NeswResize). - Draw corner handle indicators when Ctrl is held or during active resize. - Add 'Ctrl resize/move' to overlay HUD and provide complete glyph coverage for HUD labels. - Add comprehensive unit tests covering hit testing, inverted dragging, incremental handle damage, and glyph coverage.
|
/claude review |
Claude reviewOne rendering issue; resize geometry, hit-testing, cursor shapes and the incremental-damage math all check out.
Checked: handle hit-test/anchor-swap math, corner-handle draw + damage/dim-delta invariants, cursor-shape values against the vendored cursor-shape-v1 enum, HUD glyph coverage, |
…fier changes - Track backgroundHandles and backgroundShift in RenderSlot.cacheValid. - Rebuild background slot and HUD when handle or shift modifier states change with an existing selection, preventing incremental re-dimming from punching holes in the HUD. - Fix trailing newline in region_resize_test.go for golangci-lint.
|
/claude review |
| if r.selection.hasSelection { | ||
| for _, os := range r.surfaces { | ||
| r.redrawSurface(os) | ||
| } | ||
| } |
There was a problem hiding this comment.
Adding handles/shift to cacheValid fixes the Ctrl and Shift cases, but this handler redraws on every modifier change — Alt, Super, Caps Lock included — and those change neither handles nor shift, so the cache stays valid and the frame takes the incremental path over a background that still holds the HUD.
overlayDelta then re-dims prev's ring, label and (when Ctrl is held) the four handleRects() via paintRect, which repaints straight from the screencopy buffer. Only the circle quadrants of each handle get redrawn, so HUD pixels under the rest of each (2r+1)² handle box are erased. Repro: selection near the bottom-center HUD, hold Ctrl (handles drawn), tap Alt — chunks of the HUD disappear.
Fix: only redraw when a modifier that affects rendering actually changed, e.g. read shift/ctrl into locals first, compare against r.shiftHeld/r.ctrlHeld before assigning, and gate this loop on changed && r.selection.hasSelection.
Claude reviewThe Ctrl/Shift cache-invalidation fix works; one residual HUD-corruption path remains.
Checked: new cacheValid keys against every render-affecting state, handleRects vs drawCornerHandle pixel coverage, overlayDelta/overlayDamage supersets for prev+cur handles, resize anchor swap and inverted drags, cursor-shape selection, HUD glyph coverage and width math, resizingHandle reset paths. Model: claude-opus-5. |
…anges - Only trigger redrawSurface when Shift or Ctrl modifier states actually change, preventing redundant redraws when tapping Alt, Super, or Locks. - Only re-dim and damage corner handle bounding boxes in overlayDelta and overlayDamage when handles move or their visibility changes, preventing unnecessary re-dimming of stationary handles over the HUD. - Add TestOverlayDeltaIdenticalOverlayNoHandleDimming test.
|
/claude review |
| {captureKey, "capture"}, | ||
| {"Ctrl", "resize/move"}, | ||
| {"P", cursorLabel + " cursor"}, | ||
| {"Esc", "cancel"}, |
There was a problem hiding this comment.
Adding a fourth HUD item pushes the text past the right edge of the HUD pill.
totalW charges +4 for the space between key and desc, but the draw loop advances (1 + len(desc)) * (charW+1) — a full 9px glyph cell. That's 5px of under-measurement per item, and the trailing padding is only 12px, so the error goes visible once there are 4 items.
Walking the draw loop with charW+1 = 9 (default Space/Enter variant): totalW = 574, hudW = 598, so the pill covers columns hudX+0 .. hudX+597. tx reaches 543 at "Esc", " cancel" is drawn there, and the final 'l' cell starts at 543 + 6*9 = 597 with lit columns at 599–601 — entirely outside the pill. Same result for the Drag+Release variant (cell at 606, pill ends at 606). With the old 3 items the 'l' landed at 431–433 inside a pill ending at 434, which is why this only shows up now.
Fix is to measure with the same advance the draw loop uses:
| {"Esc", "cancel"}, | |
| {"Ctrl", "resize/move"}, |
(no change needed on this line — the fix belongs in the totalW loop below:)
totalW += len(item.key)*(charW+1) + (1+len(item.desc))*(charW+1)
Claude reviewThe Ctrl/Alt cache-invalidation fixes hold up; one cosmetic rendering regression left.
Checked: cacheValid keys vs every render-affecting state (incl. the cross-slot |
…overflow - Use (1+len(item.desc))*(charW+1) when calculating totalW in drawHUD, matching the full 9px advance used when drawing space and description. - Add TestHUDDimensionsContainText to verify HUD pill dimensions enclose all text items with correct padding across all variant combinations.
|
/claude review |
Claude reviewPrevious HUD-corruption and pill-width issues are fixed; one incremental-damage gap remains.
Checked: cursor-shape enum values against the v1-bound |
- Use slices.Equal to compare prev and cur handleRects in overlayDelta and overlayDamage instead of interior equality. - Properly re-dim and damage handles when selection corners cross monitor boundaries where clamped interior is unchanged but top/bottom/left/right flags change. - Add TestOverlayDeltaHandlesClampedMonitorEdge test.
|
/claude review |
| } | ||
| } | ||
|
|
||
| if hudW-tx != padding { |
There was a problem hiding this comment.
This assertion can never fail, so it doesn't guard the pill-width fix it was added for.
The test re-declares items, the constants, the totalW formula and the tx advance locally — it never touches drawHUD. tx is built from exactly the same terms as totalW, so tx == padding + totalW and hudW - tx == (totalW + 2*padding) - (padding + totalW) == padding for any input. Change drawHUD back to the old + 4 gap and this test still passes.
To actually cover the regression, drive drawHUD into a buffer and assert no lit pixel falls outside the pill (or export the width/advance calculation and have both drawHUD and the test call it).
Claude reviewRendering correctness looks sound now; only a test-quality issue left.
Checked: handle-rect sets vs |
…l bounds - Extract hudDimensions helper on RegionSelector used by drawHUD. - Update TestHUDDimensionsContainText to drive drawHUD directly into a zeroed buffer and assert no lit pixel falls outside the computed HUD pill boundary across all configuration variants.
|
/claude review |
Claude reviewNo issues found. Re-verified the two fixes from the last round: Checked: Model: claude-opus-5. |
Adds 4-corner resizing support while holding
Ctrlin the screenshot region selector (core/internal/screenshot).recording_20260902_143444.mp4