Subject: bug#61319: 30.0.50; 'M-x select-frame-by-name' --with-pgtk does not switch focused frame

From: Eli Zaretskii <[email-masked]>
Date: Mon, 06 Feb 2023 15:10:56 +0200

> Cc: Joseph Ferano <[email-masked]>
> From: Protesilaos Stavrou <[email-masked]>
> Date: Mon, 06 Feb 2023 12:52:35 +0200
> 
> When using Emacs PGTK, the command 'select-frame-by-name' does not
> switch focus to the selected frame.  Instead, it selects the buffer on
> the specified frame, but keeps the current frame in focus.
> 
> Steps to reproduce with 'emacs -Q':
> 
> 1. In the scratch buffer, do 'M-x make-frame'
> 2. In one of the two frames, switch to another buffer, such as "*Messages*".
> 3. Do 'M-x select-frame-by-name' and select the other frame.

You are saying that select-frame-set-input-focus doesn't move the
input focus to the newly-selected frame?  But that is only "best
effort":

  select-frame-set-input-focus is a byte-compiled Lisp function in
  ‘frame.el’.

  (select-frame-set-input-focus FRAME &optional NORECORD)

  Select FRAME, raise it, and set input focus, if possible.
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Perhaps Po Lu could try fixing this, but in general Lisp programs and
users should not rely on success in these cases, because the WM can
actively prevent Emacs from giving the frame input focus.