GNU bug report logs - #54863
28.1; hook move-frame-functions not working in emacs 28.1

Previous Next

Package: emacs;

Reported by: James Ahlborn <jahlborn <at> getguru.com>

Date: Mon, 11 Apr 2022 20:29:01 UTC

Severity: normal

Tags: patch

Found in version 28.1

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 54863 in the body.
You can then email your comments to 54863 AT debbugs.gnu.org in the normal way.

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#54863; Package emacs. (Mon, 11 Apr 2022 20:29:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to James Ahlborn <jahlborn <at> getguru.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 11 Apr 2022 20:29:02 GMT) Full text and rfc822 format available.

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

From: James Ahlborn <jahlborn <at> getguru.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.1; hook move-frame-functions not working in emacs 28.1
Date: Mon, 11 Apr 2022 16:18:50 -0400
[Message part 1 (text/plain, inline)]
i have a hook function attached to 'move-frame-functions'.  however, in
 emacs 28.1, this hook does not seem to fire at all.


In GNU Emacs 28.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
Version 10.14.6 (Build 18G95))
 of 2022-04-04 built on builder10-14.lan
Windowing system distributor 'Apple', version 10.3.2113
System Description:  macOS 12.2.1

Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Tue, 12 Apr 2022 07:46:02 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: James Ahlborn <jahlborn <at> getguru.com>, 54863 <at> debbugs.gnu.org
Subject: Re: bug#54863: 28.1; hook move-frame-functions not working in emacs
 28.1
Date: Tue, 12 Apr 2022 09:45:02 +0200
> i have a hook function attached to 'move-frame-functions'.  however, in
>   emacs 28.1, this hook does not seem to fire at all.
>
>
> In GNU Emacs 28.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
> Version 10.14.6 (Build 18G95))
>   of 2022-04-04 built on builder10-14.lan
> Windowing system distributor 'Apple', version 10.3.2113
> System Description:  macOS 12.2.1

A couple of days ago John Yates told me that

(add-hook
 'move-frame-functions
 (lambda (frame)
   (message "Frame %s moved to %s" frame (frame-position frame))))

doesn't work for him with a pgtk build either.  So I suspect that this
never worked on macOS.

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Tue, 12 Apr 2022 08:16:01 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: James Ahlborn <jahlborn <at> getguru.com>, 54863 <at> debbugs.gnu.org
Subject: Re: bug#54863: 28.1; hook move-frame-functions not working in emacs
 28.1
Date: Tue, 12 Apr 2022 16:14:52 +0800
martin rudalics <rudalics <at> gmx.at> writes:

>> i have a hook function attached to 'move-frame-functions'.  however, in
>>   emacs 28.1, this hook does not seem to fire at all.
>>
>>
>> In GNU Emacs 28.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
>> Version 10.14.6 (Build 18G95))
>>   of 2022-04-04 built on builder10-14.lan
>> Windowing system distributor 'Apple', version 10.3.2113
>> System Description:  macOS 12.2.1
>
> A couple of days ago John Yates told me that
>
> (add-hook
>  'move-frame-functions
>  (lambda (frame)
>    (message "Frame %s moved to %s" frame (frame-position frame))))
>
> doesn't work for him with a pgtk build either.  So I suspect that this
> never worked on macOS.
>
> martin

It's because the responsible code was commented out, probably sometime
after the release of 27.1.  Please try the following patch (I suspect
the didExitFullScreen bug alluded to in the comment is also related to
using emacs_event somehow):

diff --git a/src/nsterm.m b/src/nsterm.m
index 550f29212e..ed7ee1401b 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7243,6 +7243,7 @@ - (void)windowDidMove: sender
   NSRect r = [win frame];
   NSArray *screens = [NSScreen screens];
   NSScreen *screen = [screens objectAtIndex: 0];
+  struct input_event ie;
 
   NSTRACE ("[EmacsView windowDidMove:]");
 
@@ -7253,12 +7254,10 @@ - (void)windowDidMove: sender
       emacsframe->left_pos = NSMinX (r) - NS_PARENT_WINDOW_LEFT_POS (emacsframe);
       emacsframe->top_pos = NS_PARENT_WINDOW_TOP_POS (emacsframe) - NSMaxY (r);
 
-      // FIXME: after event part below didExitFullScreen is not received
-      // if (emacs_event)
-      //   {
-      //     emacs_event->kind = MOVE_FRAME_EVENT;
-      //     EV_TRAILER ((id)nil);
-      //   }
+      ie.kind = MOVE_FRAME_EVENT;
+      XSETFRAME (ie.frame_or_window, emacsframe);
+      XSETINT (ie.x, emacsframe->left_pos);
+      XSETINT (ie.y, emacsframe->top_pos);
     }
 }




Added tag(s) patch. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 12 Apr 2022 10:25:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Tue, 12 Apr 2022 21:26:01 GMT) Full text and rfc822 format available.

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

From: James Ahlborn <jahlborn <at> getguru.com>
To: rudalics <at> gmx.at, bug-gnu-emacs <at> gnu.org
Subject: bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
Date: Tue, 12 Apr 2022 17:25:03 -0400
[Message part 1 (text/plain, inline)]
>
> > i have a hook function attached to 'move-frame-functions'.  however, in
> >   emacs 28.1, this hook does not seem to fire at all.
> >
> >
> > In GNU Emacs 28.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
> > Version 10.14.6 (Build 18G95))
> >   of 2022-04-04 built on builder10-14.lan
> > Windowing system distributor 'Apple', version 10.3.2113
> > System Description:  macOS 12.2.1
>
> A couple of days ago John Yates told me that
>
> (add-hook
>  'move-frame-functions
>  (lambda (frame)
>    (message "Frame %s moved to %s" frame (frame-position frame))))
>
> doesn't work for him with a pgtk build either.  So I suspect that this
> never worked on macOS.
>
> martin
>
>
fo reference this did previuosuly work in macos in emacs 27.2.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Wed, 13 Apr 2022 08:46:01 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: James Ahlborn <jahlborn <at> getguru.com>, bug-gnu-emacs <at> gnu.org
Subject: Re: bug#54863: 28.1; hook move-frame-functions not working in emacs
 28.1
Date: Wed, 13 Apr 2022 10:45:15 +0200
> fo reference this did previuosuly work in macos in emacs 27.2.

I vaguely recall testing it in GNUstep builds so you're probably right.
Did you try Po Lu's patch?

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Wed, 13 Apr 2022 13:09:01 GMT) Full text and rfc822 format available.

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

From: James Ahlborn <jahlborn <at> getguru.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#54863: 28.1;
 hook move-frame-functions not working in emacs 28.1
Date: Wed, 13 Apr 2022 09:07:59 -0400
[Message part 1 (text/plain, inline)]
i don't have emacs installed from source, so i have not.

On Wed, Apr 13, 2022 at 4:45 AM martin rudalics <rudalics <at> gmx.at> wrote:

>  > fo reference this did previuosuly work in macos in emacs 27.2.
>
> I vaguely recall testing it in GNUstep builds so you're probably right.
> Did you try Po Lu's patch?
>
> martin
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Tue, 06 Sep 2022 11:21:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: James Ahlborn <jahlborn <at> getguru.com>, martin rudalics <rudalics <at> gmx.at>,
 54863 <at> debbugs.gnu.org
Subject: Re: bug#54863: 28.1; hook move-frame-functions not working in emacs
 28.1
Date: Tue, 06 Sep 2022 13:20:39 +0200
Po Lu <luangruo <at> yahoo.com> writes:

> It's because the responsible code was commented out, probably sometime
> after the release of 27.1.  Please try the following patch (I suspect
> the didExitFullScreen bug alluded to in the comment is also related to
> using emacs_event somehow):

[...]

> +      ie.kind = MOVE_FRAME_EVENT;
> +      XSETFRAME (ie.frame_or_window, emacsframe);
> +      XSETINT (ie.x, emacsframe->left_pos);
> +      XSETINT (ie.y, emacsframe->top_pos);

I tried the patch on Macos now, and it did not fix the problem.  I.e.,
the move-frame-functions hook was not called when I moved the frame.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Tue, 06 Sep 2022 12:14:02 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: James Ahlborn <jahlborn <at> getguru.com>, martin rudalics <rudalics <at> gmx.at>,
 54863 <at> debbugs.gnu.org
Subject: Re: bug#54863: 28.1; hook move-frame-functions not working in emacs
 28.1
Date: Tue, 06 Sep 2022 20:13:06 +0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

>> +      ie.kind = MOVE_FRAME_EVENT;
>> +      XSETFRAME (ie.frame_or_window, emacsframe);
>> +      XSETINT (ie.x, emacsframe->left_pos);
>> +      XSETINT (ie.y, emacsframe->top_pos);
>
> I tried the patch on Macos now, and it did not fix the problem.  I.e.,
> the move-frame-functions hook was not called when I moved the frame.

I missed a call to kbd_buffer_store_event after the last XSETINT.
What happens if you add:

  kbd_buffer_store_event (&ie);

after that?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Tue, 06 Sep 2022 13:25:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: James Ahlborn <jahlborn <at> getguru.com>, martin rudalics <rudalics <at> gmx.at>,
 54863 <at> debbugs.gnu.org
Subject: Re: bug#54863: 28.1; hook move-frame-functions not working in emacs
 28.1
Date: Tue, 06 Sep 2022 15:24:22 +0200
Po Lu <luangruo <at> yahoo.com> writes:

> I missed a call to kbd_buffer_store_event after the last XSETINT.
> What happens if you add:
>
>   kbd_buffer_store_event (&ie);

With the following patch, the hook fires when I move the frame on Macos.

diff --git a/src/nsterm.m b/src/nsterm.m
index 6c6151701b..bc4e072ea0 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7912,6 +7912,7 @@ - (void)windowDidMove: sender
   NSRect r = [win frame];
   NSArray *screens = [NSScreen screens];
   NSScreen *screen = [screens objectAtIndex: 0];
+  struct input_event ie;
 
   NSTRACE ("[EmacsView windowDidMove:]");
 
@@ -7922,12 +7923,14 @@ - (void)windowDidMove: sender
       emacsframe->left_pos = NSMinX (r) - NS_PARENT_WINDOW_LEFT_POS (emacsframe);
       emacsframe->top_pos = NS_PARENT_WINDOW_TOP_POS (emacsframe) - NSMaxY (r);
 
-      // FIXME: after event part below didExitFullScreen is not received
-      // if (emacs_event)
-      //   {
-      //     emacs_event->kind = MOVE_FRAME_EVENT;
-      //     EV_TRAILER ((id)nil);
-      //   }
+      if (emacs_event)
+	{
+	 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);
+	}
     }
 }
 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Tue, 06 Sep 2022 13:36:02 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: James Ahlborn <jahlborn <at> getguru.com>, martin rudalics <rudalics <at> gmx.at>,
 54863 <at> debbugs.gnu.org
Subject: Re: bug#54863: 28.1; hook move-frame-functions not working in emacs
 28.1
Date: Tue, 06 Sep 2022 21:35:29 +0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> With the following patch, the hook fires when I move the frame on Macos.

Nice!  Are the values of the parameters `left' and `top' correct too
once the hook fires?  Converting between the cartesian NS screen
coordinate system and the X one is sometimes tricky, and I don't
completely understand the NS_PARENT_WINDOW_XXX_POS macros.

Thanks.

> diff --git a/src/nsterm.m b/src/nsterm.m
> index 6c6151701b..bc4e072ea0 100644
> --- a/src/nsterm.m
> +++ b/src/nsterm.m
> @@ -7912,6 +7912,7 @@ - (void)windowDidMove: sender
>    NSRect r = [win frame];
>    NSArray *screens = [NSScreen screens];
>    NSScreen *screen = [screens objectAtIndex: 0];
> +  struct input_event ie;
>  
>    NSTRACE ("[EmacsView windowDidMove:]");
>  
> @@ -7922,12 +7923,14 @@ - (void)windowDidMove: sender
>        emacsframe->left_pos = NSMinX (r) - NS_PARENT_WINDOW_LEFT_POS (emacsframe);
>        emacsframe->top_pos = NS_PARENT_WINDOW_TOP_POS (emacsframe) - NSMaxY (r);
>  
> -      // FIXME: after event part below didExitFullScreen is not received
> -      // if (emacs_event)
> -      //   {
> -      //     emacs_event->kind = MOVE_FRAME_EVENT;
> -      //     EV_TRAILER ((id)nil);
> -      //   }
> +      if (emacs_event)
> +	{
> +	 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);
> +	}
>      }
>  }
>  




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Tue, 06 Sep 2022 13:41:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: James Ahlborn <jahlborn <at> getguru.com>, martin rudalics <rudalics <at> gmx.at>,
 54863 <at> debbugs.gnu.org
Subject: Re: bug#54863: 28.1; hook move-frame-functions not working in emacs
 28.1
Date: Tue, 06 Sep 2022 15:40:05 +0200
Po Lu <luangruo <at> yahoo.com> writes:

> Nice!  Are the values of the parameters `left' and `top' correct too
> once the hook fires?  Converting between the cartesian NS screen
> coordinate system and the X one is sometimes tricky, and I don't
> completely understand the NS_PARENT_WINDOW_XXX_POS macros.

Yes, it looks like they're correct.  If I drag the frame as far left and
top as it gets, I get a left value of 0 and a top value of 25 -- but the
Macos menu bar is to the top.  Eyeballing it by dragging it so that it
has a top value of 50, I then have a space of two menu bars above the
frame.

So looks correct to me.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Wed, 07 Sep 2022 01:07:02 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: James Ahlborn <jahlborn <at> getguru.com>, martin rudalics <rudalics <at> gmx.at>,
 54863 <at> debbugs.gnu.org
Subject: Re: bug#54863: 28.1; hook move-frame-functions not working in emacs
 28.1
Date: Wed, 07 Sep 2022 09:05:31 +0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Po Lu <luangruo <at> yahoo.com> writes:
>
>> Nice!  Are the values of the parameters `left' and `top' correct too
>> once the hook fires?  Converting between the cartesian NS screen
>> coordinate system and the X one is sometimes tricky, and I don't
>> completely understand the NS_PARENT_WINDOW_XXX_POS macros.
>
> Yes, it looks like they're correct.  If I drag the frame as far left and
> top as it gets, I get a left value of 0 and a top value of 25 -- but the
> Macos menu bar is to the top.  Eyeballing it by dragging it so that it
> has a top value of 50, I then have a space of two menu bars above the
> frame.
>
> So looks correct to me.

Thanks, I'll install that change now.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54863; Package emacs. (Wed, 07 Sep 2022 12:52:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: James Ahlborn <jahlborn <at> getguru.com>, martin rudalics <rudalics <at> gmx.at>,
 54863 <at> debbugs.gnu.org
Subject: Re: bug#54863: 28.1; hook move-frame-functions not working in emacs
 28.1
Date: Wed, 07 Sep 2022 14:51:30 +0200
Po Lu <luangruo <at> yahoo.com> writes:

> Thanks, I'll install that change now.

Thanks; I can confirm that with these latest patches, the hook works
fine on Macos, so I'm closing this bug report.




bug marked as fixed in version 29.1, send any further explanations to 54863 <at> debbugs.gnu.org and James Ahlborn <jahlborn <at> getguru.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 07 Sep 2022 12:52:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 06 Oct 2022 11:24:14 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 174 days ago.

Previous Next


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