GNU bug report logs - #61319
30.0.50; 'M-x select-frame-by-name' --with-pgtk does not switch focused frame

Previous Next

Package: emacs;

Reported by: Protesilaos Stavrou <info <at> protesilaos.com>

Date: Mon, 6 Feb 2023 10:53:01 UTC

Severity: normal

Found in version 30.0.50

To reply to this bug, email your comments to 61319 AT debbugs.gnu.org.

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#61319; Package emacs. (Mon, 06 Feb 2023 10:53:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Protesilaos Stavrou <info <at> protesilaos.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 06 Feb 2023 10:53:01 GMT) Full text and rfc822 format available.

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

From: Protesilaos Stavrou <info <at> protesilaos.com>
To: bug-gnu-emacs <at> gnu.org
Cc: Joseph Ferano <joseph <at> ferano.io>
Subject: 30.0.50; 'M-x select-frame-by-name' --with-pgtk does not switch
 focused frame 
Date: Mon, 06 Feb 2023 12:52:35 +0200
[Message part 1 (text/plain, inline)]
Dear maintainers,

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.

I attach a screenshot that shows the mismatch between the focused frame
and current window.  I disabled blink-cursor-mode to capture the cursor
in the screenshot.

I tried this on GNOME Wayland.

This does not happen when I compile Emacs WITHOUT --with-pgtk.

Please let me know if there is something else I could test or modify.

Thank you for your time.

All the best,
Protesilaos (or simply "Prot")

* * *

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.36, cairo version 1.17.6) of 2023-02-06 built on kronos
Repository revision: 013655811aa1c89754372610c8c6ccccec166035
Repository branch: master
System Description: Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
 --with-modules --without-libotf --without-m17n-flt --without-gconf
 --with-native-compilation=yes --with-xinput2 --with-pgtk
 --without-xaw3d --with-sound=no --with-tree-sitter --without-gpm
 --without-compress-install
 '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection'
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK
PNG RSVG SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
WEBP XIM GTK3 ZLIB


-- 
Protesilaos Stavrou
https://protesilaos.com
[Screenshot from 2023-02-06 12-41-23.png (image/png, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61319; Package emacs. (Mon, 06 Feb 2023 13:11:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Protesilaos Stavrou <info <at> protesilaos.com>, Po Lu <luangruo <at> yahoo.com>
Cc: 61319 <at> debbugs.gnu.org, joseph <at> ferano.io
Subject: Re: bug#61319: 30.0.50;
 'M-x select-frame-by-name' --with-pgtk does not switch focused frame
Date: Mon, 06 Feb 2023 15:10:56 +0200
> Cc: Joseph Ferano <joseph <at> ferano.io>
> From: Protesilaos Stavrou <info <at> protesilaos.com>
> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61319; Package emacs. (Mon, 06 Feb 2023 13:44:01 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Protesilaos Stavrou <info <at> protesilaos.com>, 61319 <at> debbugs.gnu.org,
 joseph <at> ferano.io
Subject: Re: bug#61319: 30.0.50; 'M-x select-frame-by-name' --with-pgtk does
 not switch focused frame
Date: Mon, 06 Feb 2023 21:40:59 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Cc: Joseph Ferano <joseph <at> ferano.io>
>> From: Protesilaos Stavrou <info <at> protesilaos.com>
>> 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.

The Wayland protocol itself prevents Emacs from doing this.

GTK 3 uses a private Wayland protocol extension named ``gtk-shell''
which is implemented only by GNOME's Wayland compositor; it does not
support the other extension typically used to activate toplevels.

Unless you're using GNOME Shell, I don't think we will be able to make
this work, sorry.  If you do, however, it should already work.  So
please tell us what Wayland compositor you are using.

Thanks.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61319; Package emacs. (Thu, 09 Feb 2023 08:02:02 GMT) Full text and rfc822 format available.

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

From: Protesilaos Stavrou <info <at> protesilaos.com>
To: Po Lu <luangruo <at> yahoo.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 61319 <at> debbugs.gnu.org, joseph <at> ferano.io
Subject: Re: bug#61319: 30.0.50; 'M-x select-frame-by-name' --with-pgtk does
 not switch focused frame
Date: Thu, 09 Feb 2023 10:01:25 +0200
> From: Po Lu <luangruo <at> yahoo.com>
> Date: Mon,  6 Feb 2023 21:40:59 +0800

> [... 17 lines elided]

>> 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.
>
> The Wayland protocol itself prevents Emacs from doing this.
>
> GTK 3 uses a private Wayland protocol extension named ``gtk-shell''
> which is implemented only by GNOME's Wayland compositor; it does not
> support the other extension typically used to activate toplevels.

Thank you for the explanation!  In that case there is nothing we can do
about it and this bug can be closed.

> Unless you're using GNOME Shell, I don't think we will be able to make
> this work, sorry.  If you do, however, it should already work.  So
> please tell us what Wayland compositor you are using.

The issue occurs on GNOME Wayland.  I normally use X with a tiling
window manager.  There the Emacs frame selection works as intended.

-- 
Protesilaos Stavrou
https://protesilaos.com

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61319; Package emacs. (Thu, 09 Feb 2023 08:23:02 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Protesilaos Stavrou <info <at> protesilaos.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 61319 <at> debbugs.gnu.org, joseph <at> ferano.io
Subject: Re: bug#61319: 30.0.50; 'M-x select-frame-by-name' --with-pgtk does
 not switch focused frame
Date: Thu, 09 Feb 2023 16:19:41 +0800
Protesilaos Stavrou <info <at> protesilaos.com> writes:

> The issue occurs on GNOME Wayland.  I normally use X with a tiling
> window manager.  There the Emacs frame selection works as intended.

When was your PGTK build made?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61319; Package emacs. (Thu, 09 Feb 2023 09:25:01 GMT) Full text and rfc822 format available.

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

From: Protesilaos Stavrou <info <at> protesilaos.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 61319 <at> debbugs.gnu.org, joseph <at> ferano.io
Subject: Re: bug#61319: 30.0.50; 'M-x select-frame-by-name' --with-pgtk does
 not switch focused frame
Date: Thu, 09 Feb 2023 11:24:15 +0200
> From: Po Lu <luangruo <at> yahoo.com>
> Date: Thu,  9 Feb 2023 16:19:41 +0800
>
> Protesilaos Stavrou <info <at> protesilaos.com> writes:
>
>> The issue occurs on GNOME Wayland.  I normally use X with a tiling
>> window manager.  There the Emacs frame selection works as intended.
>
> When was your PGTK build made?

On the day I reported the bug.  I can try again if you wish.  Please let
me know what you want me to test.

-- 
Protesilaos Stavrou
https://protesilaos.com




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

Previous Next


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