Rectangle fails to move Emacs after system sleep
- [ ] This is a new bug that hasn't been documented in a closed issue or in the Readme.
macOS version: Sequoia 15.0.1 on a MacBook Pro M2 Rectangle version: 0.89 (95) Logs if applicable (In Rectangle menu, hold option, "View Logging..."): attached below
Apologies that this is going to be a weak bug report. Hope the log adds enough context.
This problem started a few months ago, possibly after I upgraded either Rectangle or Emacs -- it did not happen previously.
When Emacs first starts, Rectangle works fine on it. However after a while -- very likely after a sleep, Emacs ceases to respond properly to Rectangle. It does get set to the correct size, but its position is not set.
Also, after a sleep, it is always in the wrong position; usually about half a screen too low and a bit to the right.
Other notes that may be relevant.
- This all worked fine until a few months ago.
- I'm running Emacs 29.4
- I have two external screens on my Mac, both to the left of the Macbook, and taller (so you'll see negative coordinates in the log). I usually run Emacs on the left half of my large center screen.
- I do have a fairly complex Emacs init. I don't think it is a direct cause of the problem, since Rectangle+Emacs worked fine previously with the same init. I can't easily test in a bare Emacs, since the problem seems to only develop after a while and I need Emacs and my init most of my day.
Here's a log of several attempts to resize Emacs on both my central screen and also on the Macbook screen.
2025-08-18T13:41:06+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-08-18T13:41:06+03:00: AX position proposed: (-3440.0, -433.0), result: (-3440.0, -433.0) 2025-08-18T13:41:06+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-08-18T13:41:06+03:00: leftHalf, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-3440.0, -433.0, 1720.0, 1415.0), resultRect: (-3440.0, -433.0, 1715.0, 1412.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor 2025-08-18T13:41:13+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-08-18T13:41:13+03:00: AX position proposed: (-3440.0, -433.0), result: (-3440.0, -433.0) 2025-08-18T13:41:13+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-08-18T13:41:13+03:00: leftHalf, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-3440.0, -433.0, 1720.0, 1415.0), resultRect: (-3440.0, -433.0, 1715.0, 1412.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor 2025-08-18T13:41:28+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 182.0) 2025-08-18T13:41:28+03:00: AX position proposed: (-2580.0, -433.0), result: (-2580.0, -433.0) 2025-08-18T13:41:28+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-08-18T13:41:28+03:00: centerHalf, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-2580.0, -433.0, 1720.0, 1415.0), resultRect: (-2580.0, -433.0, 1715.0, 1412.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor 2025-08-18T13:41:34+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-08-18T13:41:34+03:00: AX position proposed: (-3440.0, -433.0), result: (-3440.0, -433.0) 2025-08-18T13:41:34+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-08-18T13:41:34+03:00: leftHalf, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-3440.0, -433.0, 1720.0, 1415.0), resultRect: (-3440.0, -433.0, 1715.0, 1412.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor 2025-08-18T13:41:35+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-08-18T13:41:35+03:00: AX position proposed: (-1720.0, -433.0), result: (-1720.0, -433.0) 2025-08-18T13:41:35+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-08-18T13:41:35+03:00: rightHalf, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-1720.0, -433.0, 1720.0, 1415.0), resultRect: (-1720.0, -433.0, 1715.0, 1412.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor 2025-08-18T13:41:37+03:00: AX sizing proposed: (1146.0, 707.0), result: (1139.0, 707.0) 2025-08-18T13:41:37+03:00: AX position proposed: (-2294.0, -433.0), result: (-2294.0, -433.0) 2025-08-18T13:41:37+03:00: AX sizing proposed: (1146.0, 707.0), result: (1139.0, 707.0) 2025-08-18T13:41:37+03:00: topCenterSixth, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-2294.0, -433.0, 1146.0, 707.0), resultRect: (-2294.0, -433.0, 1139.0, 707.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor 2025-08-18T13:41:42+03:00: AX sizing proposed: (1146.0, 707.0), result: (1139.0, 707.0) 2025-08-18T13:41:42+03:00: AX position proposed: (-1146.0, -433.0), result: (-1146.0, -433.0) 2025-08-18T13:41:42+03:00: AX sizing proposed: (1146.0, 707.0), result: (1139.0, 707.0) 2025-08-18T13:41:42+03:00: topRightSixth, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-1146.0, -433.0, 1146.0, 707.0), resultRect: (-1146.0, -433.0, 1139.0, 707.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor 2025-08-18T13:41:43+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1139.0, 1412.0) 2025-08-18T13:41:43+03:00: AX position proposed: (-1720.0, -433.0), result: (-1720.0, -433.0) 2025-08-18T13:41:43+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-08-18T13:41:43+03:00: rightHalf, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-1720.0, -433.0, 1720.0, 1415.0), resultRect: (-1720.0, -433.0, 1715.0, 1412.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor 2025-08-18T13:41:45+03:00: AX sizing proposed: (1146.0, 707.0), result: (1139.0, 707.0) 2025-08-18T13:41:45+03:00: AX position proposed: (-3440.0, -433.0), result: (-3440.0, -433.0) 2025-08-18T13:41:45+03:00: AX sizing proposed: (1146.0, 707.0), result: (1139.0, 707.0) 2025-08-18T13:41:45+03:00: topLeftSixth, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-3440.0, -433.0, 1146.0, 707.0), resultRect: (-3440.0, -433.0, 1139.0, 707.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor
Sorry for the delayed response on this one. I was a little confused by it, and it took me a while to get back to it.
To confirm, this is only happening with Emacs, right? Windows for all other apps are properly sized & placed?
My confusion arises from the calculated frames being outside of the dimensions of the display, which would point to macOS providing an incorrect visible screen frame for the display. This would have come up as an issue for a lot of people, so I suspect that there's something else going on, and if this is only happening for Emacs then we would likely be looking at something specific to what Emacs is doing. My initial reaction, of course, is that this is an issue on Emacs side, but there can be quirks with the visible screen returned from macOS so I don't rule it out as a possible culprit.
If you don't mind, please provide 2 more logs:
- A normal execution of Left Half for Emacs
- When this problem occurs, an execution of Left Half on something other than Emacs, which has the correct size/position.
I've only seen it happen with Emacs. It started a few months ago and was presumably after an upgrade of something (most likely Mac OS, but I don't remember). I'm not sure how long ago it was, sorry!
The problem is not happening right now, even though my computer has been idle and presumably asleep for the past day. So, I was wrong to say that it always happens after waking from sleep.
Here's a log of Emacs resizing correctly. (same screen layout as before)
025-08-30T21:15:24+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1052.0) 2025-08-30T21:15:24+03:00: AX position proposed: (-3440.0, -433.0), result: (-3440.0, -433.0) 2025-08-30T21:15:24+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-08-30T21:15:24+03:00: leftHalf, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-3440.0, -433.0, 1720.0, 1415.0), resultRect: (-3440.0, -433.0, 1715.0, 1412.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor
Oops, I misread your request that you wanted a log of something other than Emacs. I'll collect all four logs.
First, Emacs working correctly, after restarting Emacs 18Sep2025:
2025-09-18T10:51:54+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-09-18T10:51:54+03:00: AX position proposed: (-3440.0, -433.0), result: (-3440.0, -433.0) 2025-09-18T10:51:54+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-09-18T10:51:54+03:00: leftHalf, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-3440.0, -433.0, 1720.0, 1415.0), resultRect: (-3440.0, -433.0, 1715.0, 1412.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor
Another app (Chrome), just after.
2025-09-18T10:53:01+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1720.0, 1415.0) 2025-09-18T10:53:01+03:00: AX position proposed: (-3440.0, -433.0), result: (-3440.0, -433.0) 2025-09-18T10:53:01+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1720.0, 1415.0) 2025-09-18T10:53:01+03:00: leftHalf, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-3440.0, -433.0, 1720.0, 1415.0), resultRect: (-3440.0, -433.0, 1720.0, 1415.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor
Now, I'll keep this tab open and wait for Emacs to fail again.
Failed now, September 25, so collecting again...
Emacs:
2025-09-25T21:50:54+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1067.0) 2025-09-25T21:50:54+03:00: AX position proposed: (-3440.0, -433.0), result: (-3440.0, -433.0) 2025-09-25T21:50:54+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1715.0, 1412.0) 2025-09-25T21:50:54+03:00: leftHalf, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-3440.0, -433.0, 1720.0, 1415.0), resultRect: (-3440.0, -433.0, 1715.0, 1412.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor
Chrome:
2025-09-25T21:51:38+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1720.0, 1415.0) 2025-09-25T21:51:38+03:00: AX position proposed: (-3440.0, -433.0), result: (-3440.0, -433.0) 2025-09-25T21:51:38+03:00: AX sizing proposed: (1720.0, 1415.0), result: (1720.0, 1415.0) 2025-09-25T21:51:38+03:00: leftHalf, display: (-3440.0, 0.0, 3440.0, 1415.0), calculatedRect: (-3440.0, -433.0, 1720.0, 1415.0), resultRect: (-3440.0, -433.0, 1720.0, 1415.0), srcScreen: Mi Monitor, destScreen: Mi Monitor, resultScreen: Mi Monitor
Hmm... If I'm reading these logs correctly, Rectangle thinks that it is placing Emacs correctly. But, in reality, it sizes it correctly, but places it in a wrong position -- I'm not yet sure what the pattern is of "wrong". I was going to experiment just now, but this time it chose to place Emacs partially above the top of the screen, so I had no ability to drag it back on-screen and had to close it)