Subject: bug#78527: 30.1; Mishaving new frame creation in MacOS on new desktop

From: Boris Aronov <[email-masked]>
Date: Wed, 4 Jun 2025 05:52:46 +0200

Hi,

On Thu, May 22, 2025 at 4:44 PM martin rudalics <[email-masked]> wrote:

>  > Gerd and Martin, any suggestions or comments?
>
> I'd like to understand the focus issue.  What does C-x 5 o do when run
> in the old frame?

- Opened "Emacs -Q"
- Clicked the green button (fullscreen)
- C-x 5 2 (new frame opens on another desktop)
- I swipe to original desktop
- C-x 5 o switches to the new one and repeating it takes me back

What does running 'foo' defined as
>
> (defun foo ()
>    (interactive)
>    (let ((frame (make-frame)))
>      (sit-for 3)
>      (message "%s" (frame-focus-state frame))))
>

When I do this in an non-full-screen frame, a new frame pops up with a "t"

When I do it in a full-screen frame, a new frame pops up but a "t' is in
the OLD frame.  And then (I think) with some delay it also appears in the
NEW frame.

>
> report?  Is the message shown in both frames?
>
> Does 'foo' specified as
>
> (defun foo ()
>    (interactive)
>    (let ((frame (make-frame)))
>      (select-frame-set-input-focus frame)))
>
> behave the same way?

I get a "nil" in both frames.  Hard to tell if it's simulataneous (as I
cannot look at them at the same time) and maybe switching desktops triggers
something.

  Does
>
> (add-hook 'after-make-frame-functions 'select-frame-set-input-focus)
>
> change anything?

Not really.  When I make a new frame, a new frame on a new desktop appears,
but typing M-x shows no change on screen.  When I switch back to the
original screen M-x shows on screen AND when I switch again NOW I can see
M-x prompt on the new screen as well.

  Does
>
> (add-hook 'after-make-frame-functions 'redirect-frame-focus)
>
> change anything?
>

No.  Same behavior as after the other add-hook.

Another oddity (or is it expected): when I switch back-and-forth between
desktops having typed M-x, on one screen the focus (selected window?) is on
the M-x line and on the other on *scratch* (where I originally ran the C-x
5 2 command).  Not sure which is which by now...

Actually, after a few switches back and forth, the M-x line is the selected
window in the frame where I typed it (new frame) and it's not selected in
the old frame.

Not sure if this helps in any way.

–Boris

> martin