GNU bug report logs - #79164
[PATCH] Fix macOS frame position update after resize/move in nsterm.m

Previous Next

Package: emacs;

Reported by: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) <kawamoto.takuji <at> gmail.com>

Date: Sun, 3 Aug 2025 06:46:02 UTC

Severity: normal

Tags: patch

Done: Alan Third <alan <at> idiocy.org>

To reply to this bug, email your comments to 79164 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Sun, 03 Aug 2025 06:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) <kawamoto.takuji <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 03 Aug 2025 06:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)
 <kawamoto.takuji <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Fix macOS frame position update after resize/move in nsterm.m
Date: Sun, 3 Aug 2025 15:45:25 +0900
Hello,

This patch addresses a bug in the macOS build of Emacs, where frame
position was not correctly updated after resizing from the left edge.

In particular, it fixes the issue reported in bug#74074, where
the move-frame-functions hook does not reliably reflect the final
frame location after resizing. This patch introduces the
updateFramePosition method, which is called from windowDidMove
and windowDidEndLiveResize to ensure the frame geometry stays
in sync with the actual macOS window position.

Tested on macOS 15.5.

Best regards,
Dr.Sc.KAWAMOTO, Takuji

---
 src/nsterm.m | 63 ++++++++++++++++++++++++++++++----------------------
 1 file changed, 37 insertions(+), 26 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index 003aadb9782..3db002d9678 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6736,6 +6736,11 @@ - (BOOL)fulfillService: (NSString *)name withArg: 
(NSString *)arg

 @implementation EmacsView

+- (void)windowDidEndLiveResize:(NSNotification *)notification
+{
+  [self updateFramePosition];
+}
+
 /* Needed to inform when window closed from lisp.  */
 - (void) setWindowClosing: (BOOL)closing
 {
@@ -7871,6 +7876,37 @@ - (BOOL)windowShouldClose: (id)sender
 }


+- (void)updateFramePosition
+{
+  NSWindow *win = [self window];
+  NSRect r = [win frame];
+  NSArray *screens = [NSScreen screens];
+  NSScreen *screen = [screens objectAtIndex: 0];
+
+  if (!emacsframe->output_data.ns)
+    return;
+
+  if (screen != nil)
+    {
+      emacsframe->left_pos = (NSMinX (r)
+                              - NS_PARENT_WINDOW_LEFT_POS (emacsframe));
+      emacsframe->top_pos = (NS_PARENT_WINDOW_TOP_POS (emacsframe)
+                             - NSMaxY (r));
+
+      if (emacs_event)
+        {
+          struct input_event ie;
+          EVENT_INIT (ie);
+          ie.kind = MOVE_FRAME_EVENT;
+          XSETFRAME (ie.frame_or_window, emacsframe);
+          XSETINT (ie.x, emacsframe->left_pos);
+          XSETINT (ie.y, emacsframe->top_pos);
+          kbd_buffer_store_event (&ie);
+        }
+    }
+}
+
+
 - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
 /* Normalize frame to gridded text size.  */
 {
@@ -8205,34 +8241,9 @@ - (instancetype) initFrameFromEmacs: (struct 
frame *)f

 - (void)windowDidMove: sender
 {
-  NSWindow *win = [self window];
-  NSRect r = [win frame];
-  NSArray *screens = [NSScreen screens];
-  NSScreen *screen = [screens objectAtIndex: 0];
-
   NSTRACE ("[EmacsView windowDidMove:]");

-  if (!emacsframe->output_data.ns)
-    return;
-
-  if (screen != nil)
-    {
-      emacsframe->left_pos = (NSMinX (r)
-                  - NS_PARENT_WINDOW_LEFT_POS (emacsframe));
-      emacsframe->top_pos = (NS_PARENT_WINDOW_TOP_POS (emacsframe)
-                 - NSMaxY (r));
-
-      if (emacs_event)
-    {
-      struct input_event ie;
-      EVENT_INIT (ie);
-      ie.kind = MOVE_FRAME_EVENT;
-      XSETFRAME (ie.frame_or_window, emacsframe);
-      XSETINT (ie.x, emacsframe->left_pos);
-      XSETINT (ie.y, emacsframe->top_pos);
-      kbd_buffer_store_event (&ie);
-    }
-    }
+  [self updateFramePosition];
 }


-- 
2.49.0






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Sun, 03 Aug 2025 07:08:02 GMT) Full text and rfc822 format available.

Message #8 received at 79164 <at> debbugs.gnu.org (full text, mbox):

From: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)
 <kawamoto.takuji <at> gmail.com>
To: 79164 <at> debbugs.gnu.org
Subject: Re: bug#79164: frame position not updated correctly when resizing
 from left edge on macOS
Date: Sun, 3 Aug 2025 16:07:41 +0900
As part of the investigation for this bug, I created an external helper 
command called `listemacswindows_cocoa`, which reports window frame 
information from the macOS side. I also added logging in Emacs to 
compare its internal state with the output of this external tool.

Below is the log output before applying the proposed patch, when 
resizing from the left edge of the frame:

#### Resize from left edge (before patch)

2025-08-03 08:16:01.306027 ELisp after resize-hook 1924x975-1920+0 
1924x975-1920+0
2025-08-03 08:16:08.873112 Obj-C windowWillResize called
2025-08-03 08:16:08.875086 Obj-C windowDidMove called
2025-08-03 08:16:08.984022 ELisp after resize-hook 1917x975-1920+0 
1924x975-1920+0
...
2025-08-03 08:16:09.835766 ELisp after move-hook 1902x975-1901+0 
1902x975-1898+0

As you can see, the ELisp hooks (both `window-size-change-functions` and 
`move-frame-functions`) do not reflect the final window position 
correctly during resizing from the left edge.

After applying the patch, the log becomes:

#### Resize from left edge (after patch)

2025-08-03 09:46:54.217436 Obj-C windowWillResize called
2025-08-03 09:46:54.218742 Obj-C windowDidMove called
2025-08-03 09:46:54.218765 Obj-C updateFramePosition called 
1882x910-1882+56
2025-08-03 09:46:54.328541 ELisp after resize-hook 1876x938-1882+31 
1882x938-1882+31
...
2025-08-03 09:46:54.979835 ELisp after move-hook 1871x938-1871+31 
1871x938-1871+31

The logging confirms that with the patch, the position and size 
information reported to Lisp is now correctly updated after the resize 
operation.

This should resolve the issue where `move-frame-functions` failed to 
receive the final frame location during left-edge resizing.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Sun, 03 Aug 2025 07:15:01 GMT) Full text and rfc822 format available.

Message #11 received at 79164 <at> debbugs.gnu.org (full text, mbox):

From: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)
 <kawamoto.takuji <at> gmail.com>
To: 79164 <at> debbugs.gnu.org
Subject: Re: bug#79164: frame position not updated correctly when resizing
 from left edge on macOS
Date: Sun, 3 Aug 2025 16:14:06 +0900
Hello,

Following up on my previous message, here is a more detailed version of 
the logs I captured during frame resizing.

To analyze the issue more precisely, I created an external command 
`listemacswindows_cocoa` which queries the actual window geometry via 
macOS APIs. I also added internal logging to Emacs to compare its 
internal frame state against this external tool during window operations.

Below are full logs from when resizing the frame **by dragging the left 
edge**, before and after applying the patch.

---

### Resize from left edge (before patch)

2025-08-03 08:16:01.306027 ELisp after resize hook 1924x975-1920+0 
1924x975-1920+0
2025-08-03 08:16:08.873112 Obj-C windowWillResize called
2025-08-03 08:16:08.875086 Obj-C windowDidMove called
2025-08-03 08:16:08.984022 ELisp after resize hook 1917x975-1920+0 
1924x975-1920+0
2025-08-03 08:16:09.049381 Obj-C windowWillResize called
2025-08-03 08:16:09.049736 Obj-C windowDidMove called
2025-08-03 08:16:09.057062 Obj-C windowWillResize called
2025-08-03 08:16:09.057092 Obj-C windowDidMove called
2025-08-03 08:16:09.127564 ELisp after resize hook 1908x975-1905+0 
1917x975-1913+0
2025-08-03 08:16:09.187194 Obj-C windowWillResize called
2025-08-03 08:16:09.187235 Obj-C windowDidMove called
2025-08-03 08:16:09.258766 ELisp after resize hook 1905x975-1904+0 
1908x975-1904+0
2025-08-03 08:16:09.317012 Obj-C windowWillResize called
2025-08-03 08:16:09.317461 Obj-C windowDidMove called
2025-08-03 08:16:09.393941 ELisp after resize hook 1902x975-1901+0 
1905x975-1901+0
2025-08-03 08:16:09.587080 ELisp after move hook     1902x975-1901+0 
1902x975-1898+0
2025-08-03 08:16:09.655081 ELisp after move hook     1902x975-1901+0 
1902x975-1898+0
2025-08-03 08:16:09.718153 ELisp after move hook     1902x975-1901+0 
1902x975-1898+0
2025-08-03 08:16:09.777682 ELisp after move hook     1902x975-1901+0 
1902x975-1898+0
2025-08-03 08:16:09.835766 ELisp after move hook     1902x975-1901+0 
1902x975-1898+0

As you can see, `move-frame-functions` and 
`window-size-change-functions` receive frame positions that are **out of 
sync** with the actual window state during the resize operation.

---

### Resize from left edge (after applying the patch)

2025-08-03 09:46:54.217436 Obj-C windowWillResize called
2025-08-03 09:46:54.218742 Obj-C windowDidMove called
2025-08-03 09:46:54.218765 Obj-C updateFramePosition called 
1882x910-1882+56
2025-08-03 09:46:54.328541 ELisp after resize hook 1876x938-1882+31 
1882x938-1882+31
2025-08-03 09:46:54.390137 Obj-C windowWillResize called
2025-08-03 09:46:54.390463 Obj-C windowDidMove called
2025-08-03 09:46:54.390468 Obj-C updateFramePosition called 
1876x910-1882+56
2025-08-03 09:46:54.462142 ELisp after resize hook 1872x938-1876+31 
1876x938-1876+31
2025-08-03 09:46:54.515893 Obj-C windowWillResize called
2025-08-03 09:46:54.515931 Obj-C windowDidMove called
2025-08-03 09:46:54.515936 Obj-C updateFramePosition called 
1872x910-1876+56
2025-08-03 09:46:54.587742 ELisp after resize hook 1871x938-1872+31 
1872x938-1872+31
2025-08-03 09:46:54.704831 Obj-C windowDidEndLiveResize called
2025-08-03 09:46:54.704848 Obj-C updateFramePosition called 
1871x910-1872+56
2025-08-03 09:46:54.798062 ELisp after move hook  1871x938-1871+31 
1871x938-1871+31
2025-08-03 09:46:54.861957 ELisp after move hook  1871x938-1871+31 
1871x938-1871+31
2025-08-03 09:46:54.921596 ELisp after move hook  1871x938-1871+31 
1871x938-1871+31
2025-08-03 09:46:54.979835 ELisp after move hook  1871x938-1871+31 
1871x938-1871+31

After the patch is applied, the internal frame position becomes 
consistent with what is reported by the system. The final 
`move-frame-functions` call correctly reflects the final position at the 
end of the resizing operation.

This confirms that the proposed patch resolves the original inconsistency.

Best regards,
Dr.Sc.KAWAMOTO, Takuji





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Mon, 04 Aug 2025 12:00:02 GMT) Full text and rfc822 format available.

Message #14 received at 79164 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: 川本 琢二(Dr.Sc.KAWAMOTO, Takuji) <kawamoto.takuji <at> gmail.com>,
 Gerd Möllmann <gerd.moellmann <at> gmail.com>, Alan Third
 <alan <at> idiocy.org>
Cc: 79164 <at> debbugs.gnu.org
Subject: Re: bug#79164: [PATCH] Fix macOS frame position update after
 resize/move in nsterm.m
Date: Mon, 04 Aug 2025 14:58:42 +0300
> Date: Sun, 3 Aug 2025 15:45:25 +0900
> From: 川本 琢二
>  (Dr.Sc.KAWAMOTO, Takuji) <kawamoto.takuji <at> gmail.com>
> 
> This patch addresses a bug in the macOS build of Emacs, where frame
> position was not correctly updated after resizing from the left edge.
> 
> In particular, it fixes the issue reported in bug#74074, where
> the move-frame-functions hook does not reliably reflect the final
> frame location after resizing. This patch introduces the
> updateFramePosition method, which is called from windowDidMove
> and windowDidEndLiveResize to ensure the frame geometry stays
> in sync with the actual macOS window position.
> 
> Tested on macOS 15.5.

Thanks, I hope the macOS experts (CC'ed) will be able to review and
test the patch.

For the record: which Emacs version did you patch with this change?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Mon, 04 Aug 2025 12:20:02 GMT) Full text and rfc822 format available.

Message #17 received at 79164 <at> debbugs.gnu.org (full text, mbox):

From: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)
 <kawamoto.takuji <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Gerd Möllmann
 <gerd.moellmann <at> gmail.com>, Alan Third <alan <at> idiocy.org>
Cc: 79164 <at> debbugs.gnu.org
Subject: Re: bug#79164: [PATCH] Fix macOS frame position update after
 resize/move in nsterm.m
Date: Mon, 4 Aug 2025 21:18:58 +0900
Thank you.

For the record, the patch was applied and tested against the latest 
master branch of Emacs as of 2025-07-20.
The base commit was:

    commit e6c1ec71b72  [Define setfunction for 
bibtex-generate-url-list (bug#78798)]

I built and tested on macOS 15.5 (Sonoma) using native compilation 
enabled (`--with-native-compilation`),
 and verified the fix by tracking both Emacs's internal frame state and 
actual macOS-reported window
geometry during left-edge resize operations.

Best regards,
Dr.Sc.KAWAMOTO, Takuji
On 2025/08/04 20:58, Eli Zaretskii wrote:
>> ate: Sun, 3 Aug 2025 15:45:25 +0900
>> From: 川本 琢二
>>   (Dr.Sc.KAWAMOTO, Takuji)<kawamoto.takuji <at> gmail.com>
>>
>> This patch addresses a bug in the macOS build of Emacs, where frame
>> position was not correctly updated after resizing from the left edge.
>>
>> In particular, it fixes the issue reported in bug#74074, where
>> the move-frame-functions hook does not reliably reflect the final
>> frame location after resizing. This patch introduces the
>> updateFramePosition method, which is called from windowDidMove
>> and windowDidEndLiveResize to ensure the frame geometry stays
>> in sync with the actual macOS window position.
>>
>> Tested on macOS 15.5.
> Thanks, I hope the macOS experts (CC'ed) will be able to review and
> test the patch.
>
> For the record: which Emacs version did you patch with this change?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Mon, 04 Aug 2025 13:13:01 GMT) Full text and rfc822 format available.

Message #20 received at 79164 <at> debbugs.gnu.org (full text, mbox):

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) <kawamoto.takuji <at> gmail.com>
Cc: 79164 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Alan Third <alan <at> idiocy.org>
Subject: Re: bug#79164: [PATCH] Fix macOS frame position update after
 resize/move in nsterm.m
Date: Mon, 04 Aug 2025 15:11:52 +0200
"川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)" <kawamoto.takuji <at> gmail.com> writes:

> Thank you.
>
> For the record, the patch was applied and tested against the latest
> master branch of Emacs as of 2025-07-20.
> The base commit was:
>
>     commit e6c1ec71b72  [Define setfunction for
> bibtex-generate-url-list (bug#78798)]
>
> I built and tested on macOS 15.5 (Sonoma) using native compilation
> enabled (`--with-native-compilation`),
>  and verified the fix by tracking both Emacs's internal frame state
> and actual macOS-reported window
> geometry during left-edge resize operations.
>
> Best regards,
> Dr.Sc.KAWAMOTO, Takuji
> On 2025/08/04 20:58, Eli Zaretskii wrote:
>>> ate: Sun, 3 Aug 2025 15:45:25 +0900
>>> From: 川本 琢二
>>>   (Dr.Sc.KAWAMOTO, Takuji)<kawamoto.takuji <at> gmail.com>
>>>
>>> This patch addresses a bug in the macOS build of Emacs, where frame
>>> position was not correctly updated after resizing from the left edge.
>>>
>>> In particular, it fixes the issue reported in bug#74074, where
>>> the move-frame-functions hook does not reliably reflect the final
>>> frame location after resizing. This patch introduces the
>>> updateFramePosition method, which is called from windowDidMove
>>> and windowDidEndLiveResize to ensure the frame geometry stays
>>> in sync with the actual macOS window position.
>>>
>>> Tested on macOS 15.5.
>> Thanks, I hope the macOS experts (CC'ed) will be able to review and
>> test the patch.
>>
>> For the record: which Emacs version did you patch with this change?

I'm afraid that goes beyond my knowledge. But I can say that
Yamamoto-san's mac uses these methods, too:

  https://github.com/jdtsmith/emacs-mac/blob/emacs-mac-30_1_exp/src/macappkit.m

and it does seems to work correctly. 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Mon, 04 Aug 2025 15:46:02 GMT) Full text and rfc822 format available.

Message #23 received at 79164 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Gerd Möllmann <gerd.moellmann <at> gmail.com>,
 79164 <at> debbugs.gnu.org,
 川本 琢二(Dr.Sc.KAWAMOTO, Takuji)
 <kawamoto.takuji <at> gmail.com>
Subject: Re: bug#79164: [PATCH] Fix macOS frame position update after
 resize/move in nsterm.m
Date: Mon, 4 Aug 2025 16:45:27 +0100
On Mon, Aug 04, 2025 at 02:58:42PM +0300, Eli Zaretskii wrote:
> > Date: Sun, 3 Aug 2025 15:45:25 +0900
> > From: 川本 琢二
> >  (Dr.Sc.KAWAMOTO, Takuji) <kawamoto.takuji <at> gmail.com>
> > 
> > This patch addresses a bug in the macOS build of Emacs, where frame
> > position was not correctly updated after resizing from the left edge.
> > 
> > In particular, it fixes the issue reported in bug#74074, where
> > the move-frame-functions hook does not reliably reflect the final
> > frame location after resizing. This patch introduces the
> > updateFramePosition method, which is called from windowDidMove
> > and windowDidEndLiveResize to ensure the frame geometry stays
> > in sync with the actual macOS window position.
> > 
> > Tested on macOS 15.5.
> 
> Thanks, I hope the macOS experts (CC'ed) will be able to review and
> test the patch.

This all looks good to me. The patch looks good and the explanation
and testing too.

Unfortunately I can't apply the patch, I think it's had long-lines
wrapped by the email client. Can you please resend it?

Thanks!
-- 
Alan Third




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Tue, 05 Aug 2025 11:16:02 GMT) Full text and rfc822 format available.

Message #26 received at 79164 <at> debbugs.gnu.org (full text, mbox):

From: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)
 <kawamoto.takuji <at> gmail.com>
To: Alan Third <alan <at> idiocy.org>, Eli Zaretskii <eliz <at> gnu.org>,
 Gerd Möllmann <gerd.moellmann <at> gmail.com>,
 79164 <at> debbugs.gnu.org
Subject: Re: bug#79164: [PATCH] Fix macOS frame position update after
 resize/move in nsterm.m
Date: Tue, 5 Aug 2025 20:15:11 +0900
[Message part 1 (text/plain, inline)]
Hi,

Thank you for the feedback.

I’m resending the patch as an attachment to avoid line wrapping issues.
This patch is generated from the latest master branch of Emacs as of 
2025-07-20.

    commit e6c1ec71b72  [Define setfunction for 
bibtex-generate-url-list (bug#78798)]

Best regards,
TDr.Sc.KAWAMOTO, Takuji

On 2025/08/05 0:45, Alan Third wrote:
>>> Date: Sun, 3 Aug 2025 15:45:25 +0900
>>> From: 川本 琢二
>>>   (Dr.Sc.KAWAMOTO, Takuji)<kawamoto.takuji <at> gmail.com>
>>>
>>> This patch addresses a bug in the macOS build of Emacs, where frame
>>> position was not correctly updated after resizing from the left edge.
>>>
>>> In particular, it fixes the issue reported in bug#74074, where
>>> the move-frame-functions hook does not reliably reflect the final
>>> frame location after resizing. This patch introduces the
>>> updateFramePosition method, which is called from windowDidMove
>>> and windowDidEndLiveResize to ensure the frame geometry stays
>>> in sync with the actual macOS window position.
>>>
>>> Tested on macOS 15.5.
>> Thanks, I hope the macOS experts (CC'ed) will be able to review and
>> test the patch.
> This all looks good to me. The patch looks good and the explanation
> and testing too.
>
> Unfortunately I can't apply the patch, I think it's had long-lines
> wrapped by the email client. Can you please resend it?
>
> Thanks!
[fix.patch (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Tue, 05 Aug 2025 11:21:02 GMT) Full text and rfc822 format available.

Message #29 received at 79164 <at> debbugs.gnu.org (full text, mbox):

From: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)
 <kawamoto.takuji <at> gmail.com>
To: Gerd Möllmann <gerd.moellmann <at> gmail.com>
Cc: 79164 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Alan Third <alan <at> idiocy.org>
Subject: Re: bug#79164: frame position not updated correctly when resizing
 from left edge on macOS
Date: Tue, 5 Aug 2025 20:20:16 +0900
Thank you for the reference.

Yes, I also noticed that Yamamoto-san’s `emacs-mac` port uses similar 
approaches
 to track window movement and resizing accurately on macOS.
 That gave me more confidence that this patch’s use of `windowDidMove` and
 `windowDidEndLiveResize` to update frame geometry is consistent with 
well-tested practice.

My patch aims to integrate such behavior into upstream Emacs so that 
even the standard
Cocoa build reports accurate frame positions during edge-resize 
operations—especially
for use cases relying on `move-frame-functions`.

Best regards,
Dr.Sc.KAWAMOTO, Takuji
On 2025/08/04 22:11, Gerd Möllmann wrote:
> "川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)"<kawamoto.takuji <at> gmail.com> writes:
>
>> Thank you.
>>
>> For the record, the patch was applied and tested against the latest
>> master branch of Emacs as of 2025-07-20.
>> The base commit was:
>>
>>      commit e6c1ec71b72  [Define setfunction for
>> bibtex-generate-url-list (bug#78798)]
>>
>> I built and tested on macOS 15.5 (Sonoma) using native compilation
>> enabled (`--with-native-compilation`),
>>   and verified the fix by tracking both Emacs's internal frame state
>> and actual macOS-reported window
>> geometry during left-edge resize operations.
>>
>> Best regards,
>> Dr.Sc.KAWAMOTO, Takuji
>> On 2025/08/04 20:58, Eli Zaretskii wrote:
>>>> ate: Sun, 3 Aug 2025 15:45:25 +0900
>>>> From: 川本 琢二
>>>>    (Dr.Sc.KAWAMOTO, Takuji)<kawamoto.takuji <at> gmail.com>
>>>>
>>>> This patch addresses a bug in the macOS build of Emacs, where frame
>>>> position was not correctly updated after resizing from the left edge.
>>>>
>>>> In particular, it fixes the issue reported in bug#74074, where
>>>> the move-frame-functions hook does not reliably reflect the final
>>>> frame location after resizing. This patch introduces the
>>>> updateFramePosition method, which is called from windowDidMove
>>>> and windowDidEndLiveResize to ensure the frame geometry stays
>>>> in sync with the actual macOS window position.
>>>>
>>>> Tested on macOS 15.5.
>>> Thanks, I hope the macOS experts (CC'ed) will be able to review and
>>> test the patch.
>>>
>>> For the record: which Emacs version did you patch with this change?
> I'm afraid that goes beyond my knowledge. But I can say that
> Yamamoto-san's mac uses these methods, too:
>
>    https://github.com/jdtsmith/emacs-mac/blob/emacs-mac-30_1_exp/src/macappkit.m
>
> and it does seems to work correctly.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Tue, 05 Aug 2025 20:05:02 GMT) Full text and rfc822 format available.

Message #32 received at 79164 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)
 <kawamoto.takuji <at> gmail.com>
Cc: Gerd Möllmann <gerd.moellmann <at> gmail.com>,
 79164 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#79164: frame position not updated correctly when resizing
 from left edge on macOS
Date: Tue, 5 Aug 2025 21:03:59 +0100
On Tue, Aug 05, 2025 at 08:20:16PM +0900, 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) wrote:
> Thank you for the reference.
> 
> Yes, I also noticed that Yamamoto-san’s `emacs-mac` port uses similar
> approaches
>  to track window movement and resizing accurately on macOS.
>  That gave me more confidence that this patch’s use of `windowDidMove` and
>  `windowDidEndLiveResize` to update frame geometry is consistent with
> well-tested practice.
> 
> My patch aims to integrate such behavior into upstream Emacs so that even
> the standard
> Cocoa build reports accurate frame positions during edge-resize
> operations—especially
> for use cases relying on `move-frame-functions`.

I think I redid the resizing code a few years ago, and I'm guessing
this got missed. Thank you for the patch.

Eli, does this require copyright assignment? I'm guessing not as most
of the code is not new, just moved from A to B.
-- 
Alan Third




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Wed, 06 Aug 2025 02:32:01 GMT) Full text and rfc822 format available.

Message #35 received at 79164 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alan Third <alan <at> idiocy.org>
Cc: gerd.moellmann <at> gmail.com, 79164 <at> debbugs.gnu.org, kawamoto.takuji <at> gmail.com
Subject: Re: bug#79164: frame position not updated correctly when resizing
 from left edge on macOS
Date: Wed, 06 Aug 2025 05:31:11 +0300
> Date: Tue, 5 Aug 2025 21:03:59 +0100
> From: Alan Third <alan <at> idiocy.org>
> Cc: Gerd Möllmann <gerd.moellmann <at> gmail.com>,
> 	Eli Zaretskii <eliz <at> gnu.org>, 79164 <at> debbugs.gnu.org
> 
> On Tue, Aug 05, 2025 at 08:20:16PM +0900, 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) wrote:
> > Thank you for the reference.
> > 
> > Yes, I also noticed that Yamamoto-san’s `emacs-mac` port uses similar
> > approaches
> >  to track window movement and resizing accurately on macOS.
> >  That gave me more confidence that this patch’s use of `windowDidMove` and
> >  `windowDidEndLiveResize` to update frame geometry is consistent with
> > well-tested practice.
> > 
> > My patch aims to integrate such behavior into upstream Emacs so that even
> > the standard
> > Cocoa build reports accurate frame positions during edge-resize
> > operations—especially
> > for use cases relying on `move-frame-functions`.
> 
> I think I redid the resizing code a few years ago, and I'm guessing
> this got missed. Thank you for the patch.
> 
> Eli, does this require copyright assignment? I'm guessing not as most
> of the code is not new, just moved from A to B.

Yes, we can accept this without an assignment.  Just please remember
indicating that in the commit log message, with
Copyright-paperwork-exempt.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79164; Package emacs. (Thu, 07 Aug 2025 11:41:02 GMT) Full text and rfc822 format available.

Message #38 received at 79164 <at> debbugs.gnu.org (full text, mbox):

From: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)
 <kawamoto.takuji <at> gmail.com>
To: Alan Third <alan <at> idiocy.org>
Cc: gerd.moellmann <at> gmail.com, 79164 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#79164: frame position not updated correctly when resizing
 from left edge on macOS
Date: Thu, 7 Aug 2025 20:40:10 +0900
[Message part 1 (text/plain, inline)]
I am attaching the final commit message corresponding to the patch I 
submitted earlier.
It includes the requested Copyright-paperwork-exempt line.

On 2025/08/06 11:31, Eli Zaretskii wrote:
>> Date: Tue, 5 Aug 2025 21:03:59 +0100
>> From: Alan Third <alan <at> idiocy.org>
>> Cc: Gerd Möllmann <gerd.moellmann <at> gmail.com>,
>> 	Eli Zaretskii <eliz <at> gnu.org>, 79164 <at> debbugs.gnu.org
>>
>> On Tue, Aug 05, 2025 at 08:20:16PM +0900, 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) wrote:
>>> Thank you for the reference.
>>>
>>> Yes, I also noticed that Yamamoto-san’s `emacs-mac` port uses similar
>>> approaches
>>>   to track window movement and resizing accurately on macOS.
>>>   That gave me more confidence that this patch’s use of `windowDidMove` and
>>>   `windowDidEndLiveResize` to update frame geometry is consistent with
>>> well-tested practice.
>>>
>>> My patch aims to integrate such behavior into upstream Emacs so that even
>>> the standard
>>> Cocoa build reports accurate frame positions during edge-resize
>>> operations—especially
>>> for use cases relying on `move-frame-functions`.
>> I think I redid the resizing code a few years ago, and I'm guessing
>> this got missed. Thank you for the patch.
>>
>> Eli, does this require copyright assignment? I'm guessing not as most
>> of the code is not new, just moved from A to B.
> Yes, we can accept this without an assignment.  Just please remember
> indicating that in the commit log message, with
> Copyright-paperwork-exempt.
>
> Thanks.
[commit.message (text/plain, attachment)]

Reply sent to Alan Third <alan <at> idiocy.org>:
You have taken responsibility. (Mon, 11 Aug 2025 21:10:02 GMT) Full text and rfc822 format available.

Notification sent to 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) <kawamoto.takuji <at> gmail.com>:
bug acknowledged by developer. (Mon, 11 Aug 2025 21:10:02 GMT) Full text and rfc822 format available.

Message #43 received at 79164-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji)
 <kawamoto.takuji <at> gmail.com>
Cc: gerd.moellmann <at> gmail.com, 79164-done <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#79164: frame position not updated correctly when resizing
 from left edge on macOS
Date: Mon, 11 Aug 2025 22:09:11 +0100
I've pushed this change to master.

Thank you!

On Thu, Aug 07, 2025 at 08:40:10PM +0900, 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) wrote:
> I am attaching the final commit message corresponding to the patch I
> submitted earlier.
> It includes the requested Copyright-paperwork-exempt line.
> 
> On 2025/08/06 11:31, Eli Zaretskii wrote:
> > > Date: Tue, 5 Aug 2025 21:03:59 +0100
> > > From: Alan Third <alan <at> idiocy.org>
> > > Cc: Gerd Möllmann <gerd.moellmann <at> gmail.com>,
> > > 	Eli Zaretskii <eliz <at> gnu.org>, 79164 <at> debbugs.gnu.org
> > > 
> > > On Tue, Aug 05, 2025 at 08:20:16PM +0900, 川本 琢二 (Dr.Sc.KAWAMOTO,Takuji) wrote:
> > > > Thank you for the reference.
> > > > 
> > > > Yes, I also noticed that Yamamoto-san’s `emacs-mac` port uses similar
> > > > approaches
> > > >   to track window movement and resizing accurately on macOS.
> > > >   That gave me more confidence that this patch’s use of `windowDidMove` and
> > > >   `windowDidEndLiveResize` to update frame geometry is consistent with
> > > > well-tested practice.
> > > > 
> > > > My patch aims to integrate such behavior into upstream Emacs so that even
> > > > the standard
> > > > Cocoa build reports accurate frame positions during edge-resize
> > > > operations—especially
> > > > for use cases relying on `move-frame-functions`.
> > > I think I redid the resizing code a few years ago, and I'm guessing
> > > this got missed. Thank you for the patch.
> > > 
> > > Eli, does this require copyright assignment? I'm guessing not as most
> > > of the code is not new, just moved from A to B.
> > Yes, we can accept this without an assignment.  Just please remember
> > indicating that in the commit log message, with
> > Copyright-paperwork-exempt.
> > 
> > Thanks.

> macOS: Ensure frame position is correctly updated after resizing from left edge
> 
> This patch fixes a bug where frame position is not accurately updated
> when resizing an Emacs frame from the left edge in the macOS (Cocoa)
> build. The issue affected consumers of `move-frame-functions`, which
> would receive outdated frame positions.
> 
> To resolve this, the patch applies the same frame-position update
> logic in `windowDidEndLiveResize` that is already present in
> `windowDidMove`. Since the logic is shared, a new helper method
> `updateFramePosition` is introduced.
> 
> Both `windowDidMove` and `windowDidEndLiveResize` are macOS Cocoa
> framework methods defined by the NSWindowDelegate protocol. They are
> now both calling `updateFramePosition` to ensure that the internal
> Emacs frame geometry reflects the actual macOS window state during
> and after edge-resize operations.
> 
> Tested on macOS 15.5 (Sonoma) with native compilation enabled.
> Based on commit e6c1ec71b72 (2025-07-20, master).
> 
> * src/nsterm.m (windowDidEndLiveResize): Implement NSWindowDelegate method.
> (updateFramePosition): Extract common logic from windowDidMove and windowDidEndLiveResize.
> 
> Bug: #74074
> Copyright-paperwork-exempt: yes


-- 
Alan Third




This bug report was last modified today.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.