Skip to content

Reflow Todo mode when the display configuration changes - #1947

Merged
rxhanson merged 2 commits into
rxhanson:mainfrom
AkiyamaKunka:fix/todo-reflow-on-display-change
Nov 3, 2026
Merged

rxhanson merged 2 commits into
rxhanson:mainfrom
AkiyamaKunka:fix/todo-reflow-on-display-change

Conversation

@AkiyamaKunka

Copy link
Copy Markdown
Contributor

Closes #764

When you connect or disconnect a display, or change an arrangement or resolution, the Todo window tends to end up on the wrong display or at the wrong size, and the sidebar stays reserved, until you run Reflow Todo or toggle Todo mode off and on. You wrote on the issue that "it would make sense at the very least to trigger a reflow on display connect/disconnect"; this does that.

What changes

  • TodoDisplayChangeReflow, a small class in TodoManager.swift, observes NSApplication.didChangeScreenParametersNotification. A reconfiguration posts a burst of these, so it waits one second of quiet and then runs TodoManager.moveAllIfNeeded(false), the reflow the Reflow Todo command performs (it also shifts windows on the Todo display out of the sidebar, as that command does), without bringing the Todo window forward.
  • It only reflows if the layout (screen frames and visible frames) differed at some point since the last reflow. Notifications that change nothing do nothing, and a display unplugged and plugged back in before the burst settles still counts, because macOS moved windows while it was away.
  • Nothing happens while Todo mode is off: moveAllIfNeeded keeps its existing guard. A disconnect is treated like any other change: if a display drops out for more than a second, Todo mode is laid out on the remaining display, and again when the display returns.
  • Menu bar or Dock changes that show up in the visible frames reflow too, and the layout is read again when the settle timer fires because AppKit can report stale visible frames at notification time (“Maximize” sometimes (but not always) fails to notice the Dock #467). If the frames are still stale then, nothing is detected until the next real change, and Reflow Todo still covers that. The reflow itself goes through the usual Dock-corrected frames.
  • Started once from the existing Todo initialization; starting it again is a no-op. No new preference (happy to add an opt-out if you would like one), no WindowManager change.

Tests

Six cases in TodoDisplayChangeReflowTests, with the scheduler, layout and reflow injected: one reflow after a burst settles, no reflow for unchanged screen parameters, an unplug-and-replug within the burst still reflows, only a new layout reflows again, a layout that only differs once the burst has settled still reflows, and nothing is scheduled once the observer is released.

The full RectangleTests suite passes: 659 tests, 0 failures, on macOS 27.0.1 / Xcode 27. I have not yet exercised it against a real display hot-plug on this Mac; happy to do so and report before merge if you would like.

AkiyamaKunka and others added 2 commits October 29, 2026 11:25
Connecting or disconnecting a display, or changing an arrangement or a
resolution, left the Todo window on the wrong display or at the wrong
size until the user ran Reflow Todo or toggled Todo mode (rxhanson#764).

TodoDisplayChangeReflow observes the screen-parameter notification,
waits for the burst a reconfiguration posts to settle, and then runs the
same reflow the Reflow Todo command performs, without bringing the Todo
window forward. It does nothing while Todo mode is off and nothing for
notifications that leave the layout as it was at the last reflow, while
a display unplugged and plugged back in before the burst settles still
counts as a change.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Keeps both sets of tests appended at the end of RectangleTests.swift: the
adjacent-display tests from rxhanson#1937 and this branch's Todo reflow tests.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@rxhanson
rxhanson merged commit fa8898a into rxhanson:main Nov 3, 2026
1 check passed
@rxhanson

rxhanson commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Great! The only awkward scenario left is that the empty sidebar space remains when the todo window goes back to a reconnected display, where it feels like the windows should go back to the edge of the screen in absence of the todo window. I'm ok without that being addressed at this time, though, as it would also be making an assumption that might not align with the user's intention.

AkiyamaKunka added a commit to AkiyamaKunka/Rectangle that referenced this pull request Nov 3, 2026
Keeps this branch's two test classes appended after the Todo reflow
tests that rxhanson#1947 added at the end of RectangleTests.swift.

Also restores the two closing braces at the end of
NewWindowActionManagerTests that the merge of rxhanson#1945 into main dropped;
without them the RectangleTests target does not compile on main.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@AkiyamaKunka

Copy link
Copy Markdown
Contributor Author

Thanks! On the leftover sidebar space: I think the assumption problem can be avoided by only undoing Rectangle's own change. When the reflow shifts a window off the sidebar, it would remember the window's original frame. Later, when a reflow moves the Todo window to another display, it would restore those windows on the display it left, but only if the user hasn't moved or resized them since (the frame still matches what Rectangle set). Windows the user placed themselves, or touched afterwards, stay where they are.

Would you be open to that? Two questions:

  1. On by default, or behind a Terminal setting like Add a Terminal option to apply an action to every new window #1945?
  2. Should it apply to any reflow that moves the Todo window (for example, dragging it to another display and then choosing Reflow Todo), or only to display connect and disconnect?

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.

ToDo Mode not friends with changing connected display(s)

2 participants