Skip to content

Add overlap offset for grid position cycling#1762

Open
MyronKoch wants to merge 9 commits into
rxhanson:mainfrom
MyronKoch:feature/cycling-overlap-offset
Open

Add overlap offset for grid position cycling#1762
MyronKoch wants to merge 9 commits into
rxhanson:mainfrom
MyronKoch:feature/cycling-overlap-offset

Conversation

@MyronKoch
Copy link
Copy Markdown
Contributor

@MyronKoch MyronKoch commented May 17, 2026

Summary

  • When a window is placed at a position already occupied by another window, apply a small offset (default 11pt) so the user can see there is a window underneath
  • Add "Offset cycling position on overlap" checkbox in the Grid Positions section of the extra settings popover
  • Configurable via hidden preferences: cyclingOverlapOffsetSize (default 11), cyclingOverlapMaxCascade (default 1, max 5)
  • Overlap detection uses origin-point matching, so mixed-size windows at the same grid position (e.g. quarter + eighth) also trigger the offset
  • Feature is off by default
Rectangle offset dark Rectangle offset

Motivation

On large displays (4K TVs, ultrawides) with fine-grained grid positions (ninths, twelfths, sixteenths), placing a window at a position occupied by another window completely hides the window underneath with zero visual indication. This is especially common on multi-monitor setups where many windows share grid positions across workflows.

Implementation details

  • WindowManager.applyOverlapOffsetIfNeeded - core overlap detection and offset logic, gated behind positionCycles to avoid unnecessary AX enumeration on non-grid actions
  • Clamping uses AppKit coordinates consistently; overlap detection converts to AX coordinates for comparison against window frames
  • Guards against zero/negative offset, caps cascade at 5
  • Three new defaults added to Defaults.array for config export/import

Test plan

  • 18 unit tests: positionCycles property, screenFlipped math, Defaults.array inclusion, offset clamping with primary and secondary monitor coordinates
  • Manual QA on 4-screen setup (MacBook + three 4K TVs): overlap offset, mixed sizes, checkbox toggle, cycling sequence, multi-monitor
  • 10+ days of daily use on multi-monitor 4K setup

MyronKoch and others added 6 commits May 3, 2026 01:51
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When cycling through grid positions (sixths, eighths, ninths, twelfths,
sixteenths, or quarters with quadrant cycling mode), windows that land
on a position already occupied by another window now receive a small
offset so the user can see there is a window underneath.

The feature is off by default and enabled via hidden preference:
  defaults write com.knollsoft.Rectangle cyclingOverlapOffset -bool true

Configurable options:
- cyclingOverlapOffsetSize (default 11pt) controls the offset distance
- cyclingOverlapMaxCascade (default 1) controls max cascade layers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add "Offset cycling position on overlap" checkbox to the Grid
  Positions section of the extra settings popover
- Apply overlap detection to all window actions, not just cycling
- Match on origin point instead of exact frame, so mixed sizes at
  the same grid position (e.g. quarter + eighth) trigger the offset

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Show a live count badge when the mouse hovers over a grid position
with multiple stacked windows. Uses timer-based polling (200ms) of
NSEvent.mouseLocation for reliable hover detection that survives
sleep/wake cycles. The count is queried live via Accessibility APIs
on each hover, so it always reflects the current window state.

Also updates default offset to 11pt and changes overlap detection
to origin-point matching for mixed-size windows at the same grid
position.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Re-add positionCycles guard to skip AX enumeration on non-grid
  actions (maximize, restore, center, etc.)
- Guard overlapOffset <= 0 to prevent silent no-op or corner-shoving
- Cap maxCascade at 5 to prevent spin loops with extreme values
- Cap stackedRegions at 20 entries to prevent unbounded growth
- Call OverlapCountBadge.clearAll() when feature is toggled off
- Add three new defaults to Defaults.array for config export/import
- Remove imageHugsTitle from checkbox (no-op on standard checkboxes)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
23 tests covering:
- positionCycles property: grid actions return true, non-grid false
- OverlapCountBadge: record, deduplicate, remove, clearAll, max cap
- screenFlipped: self-inverse property, null handling, negative coords
- Defaults.array: all 3 overlap prefs included for config export
- Offset guards: maxCascade clamping, screen boundary clamping on
  primary and secondary monitor coordinate spaces

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MyronKoch MyronKoch marked this pull request as draft May 17, 2026 00:12
The overlap count badge (OverlapCountBadge.swift) has architectural
issues with stale window state tracking that cause incorrect badge
positioning and counts. The core overlap offset feature is solid and
well-tested independently. The badge will be reworked and submitted
as a separate PR.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MyronKoch MyronKoch changed the title Add overlap offset for grid position cycling with hover count badge Add overlap offset for grid position cycling May 17, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MyronKoch MyronKoch marked this pull request as ready for review May 17, 2026 01:36
@rxhanson
Copy link
Copy Markdown
Owner

rxhanson commented May 17, 2026

Looks good, I like it! I'm going to test it out a little bit more and if I don't hit any snags I'll go ahead and merge.

I've been thinking about adding a feature where you can cycle the windows stacked on top of each other, and this would fit nicely with that concept. Looking forward to the hover count badge idea if that one comes in a follow-on.

Invert the logic: instead of listing which actions cycle, exclude
the non-positional actions (maximize, restore, center, move, resize,
display changes). This ensures halves, thirds, fourths, quarters,
and all grid sizes get overlap detection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants