unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
@ 2022-04-11 20:18 James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-04-12  7:45 ` martin rudalics
  2022-04-12 21:25 ` James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 13+ messages in thread
From: James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-04-11 20:18 UTC (permalink / raw)
  To: 54863

[-- Attachment #1: Type: text/plain, Size: 545 bytes --]

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'

[-- Attachment #2: Type: text/html, Size: 646 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-04-11 20:18 bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1 James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-04-12  7:45 ` martin rudalics
  2022-04-12  8:14   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-04-12 21:25 ` James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 13+ messages in thread
From: martin rudalics @ 2022-04-12  7:45 UTC (permalink / raw)
  To: James Ahlborn, 54863

 > 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





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-04-12  7:45 ` martin rudalics
@ 2022-04-12  8:14   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-09-06 11:20     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-04-12  8:14 UTC (permalink / raw)
  To: martin rudalics; +Cc: James Ahlborn, 54863

martin rudalics <rudalics@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);
     }
 }





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-04-11 20:18 bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1 James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-04-12  7:45 ` martin rudalics
@ 2022-04-12 21:25 ` James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-04-13  8:45   ` martin rudalics
  1 sibling, 1 reply; 13+ messages in thread
From: James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-04-12 21:25 UTC (permalink / raw)
  To: rudalics, 54863

[-- Attachment #1: Type: text/plain, Size: 754 bytes --]

>
> > 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.

[-- Attachment #2: Type: text/html, Size: 1022 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-04-12 21:25 ` James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-04-13  8:45   ` martin rudalics
  2022-04-13 13:07     ` James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 13+ messages in thread
From: martin rudalics @ 2022-04-13  8:45 UTC (permalink / raw)
  To: jahlborn, 54863

 > 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





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-04-13  8:45   ` martin rudalics
@ 2022-04-13 13:07     ` James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 13+ messages in thread
From: James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-04-13 13:07 UTC (permalink / raw)
  To: martin rudalics; +Cc: 54863

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

i don't have emacs installed from source, so i have not.

On Wed, Apr 13, 2022 at 4:45 AM martin rudalics <rudalics@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
>

[-- Attachment #2: Type: text/html, Size: 627 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-04-12  8:14   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-09-06 11:20     ` Lars Ingebrigtsen
  2022-09-06 12:13       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-06 11:20 UTC (permalink / raw)
  To: Po Lu; +Cc: James Ahlborn, martin rudalics, 54863

Po Lu <luangruo@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-09-06 11:20     ` Lars Ingebrigtsen
@ 2022-09-06 12:13       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-09-06 13:24         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-09-06 12:13 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: James Ahlborn, martin rudalics, 54863

Lars Ingebrigtsen <larsi@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-09-06 12:13       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-09-06 13:24         ` Lars Ingebrigtsen
  2022-09-06 13:35           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-06 13:24 UTC (permalink / raw)
  To: Po Lu; +Cc: James Ahlborn, martin rudalics, 54863

Po Lu <luangruo@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);
+	}
     }
 }
 





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-09-06 13:24         ` Lars Ingebrigtsen
@ 2022-09-06 13:35           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-09-06 13:40             ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-09-06 13:35 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: James Ahlborn, martin rudalics, 54863

Lars Ingebrigtsen <larsi@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);
> +	}
>      }
>  }
>  





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-09-06 13:35           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-09-06 13:40             ` Lars Ingebrigtsen
  2022-09-07  1:05               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-06 13:40 UTC (permalink / raw)
  To: Po Lu; +Cc: James Ahlborn, martin rudalics, 54863

Po Lu <luangruo@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-09-06 13:40             ` Lars Ingebrigtsen
@ 2022-09-07  1:05               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-09-07 12:51                 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-09-07  1:05 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: James Ahlborn, martin rudalics, 54863

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Po Lu <luangruo@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1
  2022-09-07  1:05               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-09-07 12:51                 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 13+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-07 12:51 UTC (permalink / raw)
  To: Po Lu; +Cc: James Ahlborn, martin rudalics, 54863

Po Lu <luangruo@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-09-07 12:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11 20:18 bug#54863: 28.1; hook move-frame-functions not working in emacs 28.1 James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-04-12  7:45 ` martin rudalics
2022-04-12  8:14   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-06 11:20     ` Lars Ingebrigtsen
2022-09-06 12:13       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-06 13:24         ` Lars Ingebrigtsen
2022-09-06 13:35           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-06 13:40             ` Lars Ingebrigtsen
2022-09-07  1:05               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-07 12:51                 ` Lars Ingebrigtsen
2022-04-12 21:25 ` James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-04-13  8:45   ` martin rudalics
2022-04-13 13:07     ` James Ahlborn via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).