Repository navigation
Description
The problem
I tile windows of different apps next to each other with Rectangle, for example an editor on the left half and a browser on the right half. When I later switch to one of them with Cmd-Tab, AltTab, the Dock or a click, only that window comes forward. Its neighbour stays buried under whatever I used in between, so I switch twice to get the layout back.
The proposal
When a window that Rectangle tiled becomes active, Rectangle also brings forward the windows it tiled next to it on the same display. The window the user picked stays focused and on top. The feature is off by default.
-
Which windows belong together: windows whose current frame still equals the frame Rectangle last gave them (
WindowHistory.lastRectangleActions), on the same screen, connected by shared edges. Rectangle already keeps this record, so the feature needs no new state. -
Leaving a group: moving or resizing a window by hand changes its frame, so it no longer matches its recorded action and drops out of the group on its own.
-
When it runs: on
NSWorkspace.didActivateApplicationNotificationfor app switches (asTitleBarManagerandNewWindowActionManageralready observe), and onkAXFocusedWindowChangedNotificationfor switches between windows of the same app. -
How it raises:
kAXRaiseActionon each group member that is hidden by a window outside the group, then once more on the picked window. A raise lifts a background app's window without taking focus. Members that are already visible are left alone, which avoids flicker. -
Setting: a hidden default in the style of
cooperativeCornerResize, documented inTerminalCommands.md:defaults write com.knollsoft.Rectangle raiseTiledWindowsTogether -bool true
What I learned building it outside Rectangle
I built this as a small standalone helper, Tessera, and use it daily next to Rectangle and AltTab. Outside Rectangle it has to guess groups from window positions, which is where most of its complexity and edge cases come from. Inside Rectangle the snap record answers that question directly. What carried over:
- Switching apps posts only the activation notification, never a focus change.
- Our own raises make the raised app report a focus change about 10 ms later. That echo has to be ignored, or the raises loop.
- Groups have to stay on one display. Otherwise layouts on displays next to each other chain into one big group.
Known limits
WindowHistorylives in memory, so after Rectangle restarts, only windows tiled again count.- Native tabs (Finder, Terminal, Ghostty) are separate windows with the same frame. A tab brought forward is not in the record, so it raises nothing until it is tiled.
Questions
- Would you accept a pull request for this, as a hidden default that is off?
- Is
raiseTiledWindowsTogethera good name, and should it cover only shortcut actions, or drag-to-snap as well?
If this sounds good, I'll open a pull request with the implementation and tests.
Activity
rxhanson commentedon Nov 26, 2026
Thanks for looking to contribute this!
Yes, and it makes sense to me to go ahead and add it to the UI in the Behavior tab if you'd like. My next task for Rectangle is to finish going through the existing pull requests, and it may or may not be worth your time looking to see if there are any adjustments to be made with #1903 or #1906, since I'm planning on merging those in once they pass review.
That name works for me.
As for shortcuts & drag-to-snap, I'm inclined to go with whatever usage you prefer. If you only use it with shortcuts, then let's go with that at a start, as we can always add to it later.
janfabig commentedon Dec 2, 2026
Thanks for providing such an amazing app! :)
That sounds reasonable - will also check if there are adjustments to be made with both of the PRs.
Will probably start with shortcuts then but will check if drag-to-snap adds lots of overhead. If not, I'll implement it as well.