Back to the MonitorMate journey

BrokeStop 2 of 4

Noticing a monitor reconnect when the display list looks unchanged

A quick unplug and replug can end with the same displays as before. MonitorMate now remembers that a reconnect happened, so it still checks whether the layout was moved.

What went wrong

MonitorMate saves display layouts in MonitorMate · The appProfile storeSaves each layout as a small text file. It finds the right one for the current setup by a fixed fingerprint for each display.See it in the MonitorMate build. It puts one back when the displays have been moved MonitorMate · The appAuto-fix rulesChecks what caused the change, the main auto-fix setting and the matching profile. Then it checks that no layout is already being applied, and that the displays really moved.See it in the MonitorMate build. Unplug a monitor and plug it straight back in, and the list of displays ends up the same as before. The reconnect may still have moved a display. But the final list gave MonitorMate no reason to check.

Why it happened

When displays change, macOS sends a quick burst of signals. So MonitorMate waits for a burst to settle before it acts. The part that does this waiting is the MonitorMate · The appSettle timerGathers the display signals from macOS for 1.5 seconds. It remembers if any of them came from a wake or a reconnect.See it in the MonitorMate build. A whole unplug and replug can fit inside one wait. The displays left at the end say nothing about what happened during it.

What I changed

While the timer waits, MonitorMate now notes the signals as they arrive. A connection flag means a display was connected or removed. A wake flag means the Mac woke from sleep. When the burst settles, MonitorMate passes the flags on with a fresh list of the displays.

A flag only makes the change worth checking. The checking is done by the auto-fix rules, the part that decides whether to put a layout back. Auto-fix must be turned on for the whole app and for the matching profile. MonitorMate must not already be moving the displays. And the displays must really be out of place compared with the saved layout.

If you move displays yourself in System Settings, there is no flag. So nothing is changed back.

What still needs checking

The code shows how the flags last through the wait. But reading code cannot copy the timing of every display, dock or wake. Four cases are worth testing on real hardware. The first two are a reconnect during the wait, and a wake that leaves the display list unchanged. The other two are a missing monitor, and a display moved on purpose.