Subject: bug#71912: [Gerd Möllmann] Re: bug#71912: 30.0.50; Inaccurate window-absolute-pixel-position Values on macOS After Sleep and During Fullscreen Mode

From: Gerd Möllmann <[email-masked]>
Date: Sun, 11 Aug 2024 13:25:04 +0200

Jones Stephen <[email-masked]> writes:

> Thank you for the patch. I’ve tested it, and it does help, but I
> noticed there’s still a slight issue.
>
> Here’s what I found: if I leave my Mac idle for a while and it enters
> sleep mode, when I wake up the Mac and click to focus on Emacs, the
> frame position sometimes appears to be incorrect. However, if I put
> the Mac to sleep again and then immediately wake it up, the frame
> position is correct when I return to Emacs.
>
> Interestingly, when I moved the `adjustEmacsFrameRect` call to the
> `windowDidBecomeKey` method, the issue was completely resolved. After
> making this adjustment, the frame position remains correct regardless
> of the sleep duration or how the system is woken up.
>

(Please keep the list in CC, I've added it for this reply.)

Thanks. So an a complete patch would look like the attached patch,
right? Could you please confirm?

>From 44fabe5f1267fc0498e76173987ab4801c732d48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gerd=20M=C3=B6llmann?= <[email-masked]>
Date: Sun, 11 Aug 2024 13:22:45 +0200
Subject: [PATCH] macOS: Wrong frame rectangle after wake (bug#71912)

* src/nsterm.m ([EmacsView windowDidBecomeKey]):
Call adjustEmacsFrameRect.
---
 src/nsterm.m | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/nsterm.m b/src/nsterm.m
index 905707dace4..97b829d0e4c 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7968,6 +7968,7 @@ - (void)windowDidBecomeKey      /* for direct calls */
     dpyinfo->ns_focus_frame = emacsframe;
 
   ns_frame_rehighlight (emacsframe);
+  [self adjustEmacsFrameRect];
 
   event.kind = FOCUS_IN_EVENT;
   XSETFRAME (event.frame_or_window, emacsframe);
-- 
2.46.0