Skip to content

🐞 Don't let no-op actions clobber the cached base frame (grow-from-zero)#1117

Open
bit-saver wants to merge 1 commit into
mrkai77:developfrom
bit-saver:fix/grow-from-sentinel
Open

🐞 Don't let no-op actions clobber the cached base frame (grow-from-zero)#1117
bit-saver wants to merge 1 commit into
mrkai77:developfrom
bit-saver:fix/grow-from-sentinel

Conversation

@bit-saver

Copy link
Copy Markdown
Contributor

Summary

During a preview-only chord that starts with a no-op action (e.g. trigger + a "do nothing" action bound to a key, then an arrow to grow), the green preview collapses to a tiny zero-size box in the screen center, and the subsequent grow/shrink resizes from that box instead of the window's real frame.

Root cause

ResizeContext is reused across a chord. recomputeTargetFrame unconditionally caches the frame returned by WindowFrameResolver.getFrame. For no-frame actions (.noAction/.noSelection/.cycle/.minimize/.hide and window-focus actions), getFrame returns a zero-size centered sentinel — which then overwrites cachedTargetFrame.raw. When the user next presses grow/shrink/move, WindowFrameResolver.calculateTargetFrame reads context.lastAppliedFrame ?? context.cachedTargetFrame.raw as its base. In a preview-only chord lastAppliedFrame is still nil (it's only set on an actual apply), so it falls through to the polluted cachedTargetFrame.raw = the zero box, and grows from zero.

Pre-refactor (1.4.2) never cached the sentinel: its no-op early-return sat before the lastTargetFrame store, so the grow base stayed the real window frame. The refactor into recomputeTargetFrame lost that invariant.

Fix

Skip caching in recomputeTargetFrame for no-op / no-frame / window-focus actions (mirroring the guard already in WindowFrameResolver.getFrame), preserving the previously-cached real frame. Incremental grow during preview still works because real actions keep updating cachedTargetFrame.raw.

Testing

Built (Release) and verified: trigger + do-nothing + Up now grows from the window's real frame; repeated grow/shrink still steps correctly; normal single actions unaffected.

`recomputeTargetFrame` unconditionally cached the frame returned by
`WindowFrameResolver.getFrame`, including the zero-size centered sentinel that
no-frame actions (.noAction/.noSelection/.cycle/.minimize/.hide, and
window-focus actions) return. In a preview-only chord (e.g. trigger + a
"do nothing" action, then an arrow), `lastAppliedFrame` is still nil, so the
subsequent grow/shrink/move reads that sentinel from `cachedTargetFrame.raw`
as its base and resizes from a zero-size box at screen center instead of the
window's real frame. Skip caching for no-op/no-frame actions, preserving the
real base frame — matching pre-refactor (1.4.2) behavior.
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