Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Gnome: New terminal/browser windows not focused
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
yuri_sevatz
n00b
n00b


Joined: 19 Jul 2020
Posts: 8

PostPosted: Fri May 19, 2023 9:29 pm    Post subject: Gnome: New terminal/browser windows not focused Reply with quote

Hi Gnome users! :D

I'm seeing a kind gnome window manager bug, where any new windows are not automatically focused for keyboard input.

This is happening in 7 out of 7 of the Gentoo installations I maintain; all running latest stable versions of gnome, mutter, gtk, wayland, etc. All in pristine condition.

Steps:
1. Launch a new Terminal from Activities.
2. Launch another new Terminal from Activities using Alt+Enter to create a new Instance. The new Instance is never selected, unless I click on it after.

I am wondering if anyone might be able to help identify the package with the bug :?: There seems to be several layers involved in window focus here. I've also read some recent upstream "musings" about windows focus/input bugs in gtk/mutter over the last 2-3 months.

Notes:
- I can repeat the same test with Firefox, Calculator, or any combination of different apps. All never focus the newest opened window (although calculator gives off some false impressions with its blinking cursor in every window)
- I have never made any changes to the default focus behavior under dconf (e.g. org.gnome.desktop.wm.preferences, org.gnome.mutter, etc). All indicate new windows should get focus.
- Current Profile: default/linux/amd64/17.1/desktop/gnome/systemd/merged-usr

The behavior seems to have started after an update within the last 1-2 weeks.

Thoughts :?:


Last edited by yuri_sevatz on Fri May 19, 2023 9:35 pm; edited 3 times in total
Back to top
View user's profile Send private message
yuri_sevatz
n00b
n00b


Joined: 19 Jul 2020
Posts: 8

PostPosted: Fri May 19, 2023 9:31 pm    Post subject: Reply with quote

Just to be super clear:

If no windows are currently open in a workspace: The first window opened in that workspace does get selected. But the 2nd, 3rd, 4th... windows opened on a workspace don't get selected.

This could be a hint about the package that caused this.
Back to top
View user's profile Send private message
CooSee
Veteran
Veteran


Joined: 20 Nov 2004
Posts: 1455
Location: Earth

PostPosted: Fri May 19, 2023 10:12 pm    Post subject: Reply with quote

found this
Code:
gsettings set org.gnome.desktop.wm.preferences focus-new-windows 'smart'

from https://askubuntu.com/questions/1440415/gnome-new-windows-not-focused-automatically

and https://extensions.gnome.org/extension/5612/focus-indicator/

8)
_________________
" Die Realität ist eine Illusion, die durch Mangel an ehrlicher Kommunikation entsteht "
---
" Der Mensch ist von Natur aus neugierig, was am Ende übrig bleibt ist die Gier "
Back to top
View user's profile Send private message
yuri_sevatz
n00b
n00b


Joined: 19 Jul 2020
Posts: 8

PostPosted: Fri May 19, 2023 11:30 pm    Post subject: Reply with quote

Thanks, the extension for debugging doesn't look like it works with gnome-shell-44.1. It seems to only support gnome-shell-43, before it was EOL'd by gnome.

My gsettings for that value on all 7 installations shows this:

Code:

$ gsettings get org.gnome.desktop.wm.preferences focus-new-windows
'smart'


Which is still the default, which means new instances are supposed to get focus, but they aren't.
Back to top
View user's profile Send private message
CooSee
Veteran
Veteran


Joined: 20 Nov 2004
Posts: 1455
Location: Earth

PostPosted: Sat May 20, 2023 12:33 am    Post subject: Reply with quote

it seems to be x11-wm/mutter issue.

which version are you using ? - there's a 44.1-r1 version available !

8)

EDIT:

https://gitlab.gnome.org/GNOME/mutter/-/issues?search=focus%20window&sort=created_date&state=opened&first_page_size=20

i searched for window focus - there are couple of entries regarding your issue, e.g.

https://gitlab.gnome.org/GNOME/mutter/-/issues/2106 - https://gitlab.gnome.org/GNOME/mutter/-/issues/2775
_________________
" Die Realität ist eine Illusion, die durch Mangel an ehrlicher Kommunikation entsteht "
---
" Der Mensch ist von Natur aus neugierig, was am Ende übrig bleibt ist die Gier "
Back to top
View user's profile Send private message
yuri_sevatz
n00b
n00b


Joined: 19 Jul 2020
Posts: 8

PostPosted: Sat May 20, 2023 2:02 am    Post subject: Reply with quote

Same issue occurs with mutter-44.1-r1.

I determined that the problem seems to have started after this upgrade:

qlop -m -u -U -v -d '2023-05-05'
...
2023-05-05T04:48:54 <<< x11-wm/mutter-43.3
2023-05-05T04:47:33 >>> x11-wm/mutter-44.1
2023-05-05T04:49:27 <<< gnome-base/gnome-shell-43.3
2023-05-05T04:48:58 >>> gnome-base/gnome-shell-44.1
...

I did a bit more debugging and there's some very specific quirks about when this bug does / doesn't occur:

Never Working:
- Launching a second instance of any application to any workspace using "Activities" -> New Window or "Activities" -> alt+enter, will not focus that application, unless that application is the first application launched to that specific workspace.

I've also tried launching new instances to a fresh workspace in this order: (1) Terminal, (2) Firefox, (3) Terminal; and oddly Firefox remains focused after doing that.

Always Working:
- Launching two different applications to a completely empty gnome session will always focus the new window.
- Launching new instances of any application to a workspace with any contents using alt-f2, then typing your app, (e.g. "gnome-terminal") will always focus the new window.
- Launching new instances of any application to a workspace with any contents using "File Menu" -> New Instance/Window will always focus the new window.
- Launching new instances of any application to a workspace with any contents using built in application shortcuts (e.g. Terminal: Ctrl + Shift + N, Firefox: Ctrl + N) will always focus the new window.

There must be some kind of change in the Activities menu after this update, whenever using that to launch "new instance".

Anyway, this is useful. Hopefully I can use this description to get someone's attention at gnomeorg.

Thanks!
Back to top
View user's profile Send private message
CooSee
Veteran
Veteran


Joined: 20 Nov 2004
Posts: 1455
Location: Earth

PostPosted: Sat May 20, 2023 2:34 am    Post subject: Reply with quote

i read somewhere that fedora already fixed it and this only happens with apps in native wayland mode.

be patient, fix will arrive soon :roll: ... i hope !

in the mean time you should try Sway or Hyprland - you can configure almost everything you want to your liking.

emerging / updating just takes 5 min.

8)
_________________
" Die Realität ist eine Illusion, die durch Mangel an ehrlicher Kommunikation entsteht "
---
" Der Mensch ist von Natur aus neugierig, was am Ende übrig bleibt ist die Gier "
Back to top
View user's profile Send private message
yuri_sevatz
n00b
n00b


Joined: 19 Jul 2020
Posts: 8

PostPosted: Sat May 20, 2023 3:53 am    Post subject: Reply with quote

https://gitlab.gnome.org/GNOME/mutter/-/issues/2690


I should have looked more closely, this was behind one of the links you pasted earlier. 100% it.

Thank you! I might try a couple patches/reverts here to see if I can help grow understanding some more.
Back to top
View user's profile Send private message
yuri_sevatz
n00b
n00b


Joined: 19 Jul 2020
Posts: 8

PostPosted: Sat May 20, 2023 4:22 am    Post subject: Reply with quote

The revert seems to work more than acceptably in the meantime:

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2952

It does have the one minor caveat mentioned in the comments, where the Activities screen can lose focus to windows opened behind it, which seems to be the old behavior from x11-wm/mutter-43.
Back to top
View user's profile Send private message
CooSee
Veteran
Veteran


Joined: 20 Nov 2004
Posts: 1455
Location: Earth

PostPosted: Sat May 20, 2023 4:24 am    Post subject: Reply with quote

this is the commit / code which was reverted https://gitlab.gnome.org/GNOME/mutter/-/commit/2601bf0cb856ed56f5f4b940fe983f85ca87ea35

in src/core/window.c
Code:
  /* Do not focus window on map if input is already taken by the
   * compositor.
   */
  if (!meta_display_windows_are_interactable (window->display))
    {
      *takes_focus = FALSE;
      return;
    }


theoretically you could edit the specific file yourself and perform a manual emerge, e.g.
Code:
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild unpack

then go to the file /var/tmp/portage/x11-wm/mutter-44.1/work/mutter-44.1/src/core/window.c and search for !meta_display_windows_are_interactable and remove the part i mentioned above and save.

then
Code:
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild prepare
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild configure
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild compile
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild install
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild qmerge
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild clean <<< to clean up /var/tmp

it's so easy, am i right :D

8)
_________________
" Die Realität ist eine Illusion, die durch Mangel an ehrlicher Kommunikation entsteht "
---
" Der Mensch ist von Natur aus neugierig, was am Ende übrig bleibt ist die Gier "
Back to top
View user's profile Send private message
yuri_sevatz
n00b
n00b


Joined: 19 Jul 2020
Posts: 8

PostPosted: Sat May 20, 2023 4:30 am    Post subject: Reply with quote

Yeah I already went ahead and deployed it to 7 Gentoos, /etc/portage/patches/ FTW :wink:

Code:
su -
mkdir -p /etc/portage/patches/x11-wm/mutter/
cd /etc/portage/patches/x11-wm/mutter/
wget https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2952.patch
emerge -1v mutter


(That folder alone is the single reason why I will never give up Gentoo! It is just too good!)
Back to top
View user's profile Send private message
CooSee
Veteran
Veteran


Joined: 20 Nov 2004
Posts: 1455
Location: Earth

PostPosted: Sat May 20, 2023 4:39 am    Post subject: Reply with quote

ok, you found it - i hope this solves it for you.

have fun with Gentoo :!:

8)
_________________
" Die Realität ist eine Illusion, die durch Mangel an ehrlicher Kommunikation entsteht "
---
" Der Mensch ist von Natur aus neugierig, was am Ende übrig bleibt ist die Gier "
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21822

PostPosted: Sat May 20, 2023 3:16 pm    Post subject: Reply with quote

CooSee wrote:
then
Code:
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild prepare
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild configure
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild compile
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild install
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild qmerge
ebuild /var/db/repos/gentoo/x11-wm/mutter/mutter-44.1.ebuild clean <<< to clean up /var/tmp
This is unnecessary complexity. ebuild will run any missing prerequisite phases unless told not to, so qmerge should imply all of prepare configure compile install. Also, more than one command can be given in a single call to ebuild, so if you did want to call out all of the steps, they could be done in one line.
Back to top
View user's profile Send private message
CooSee
Veteran
Veteran


Joined: 20 Nov 2004
Posts: 1455
Location: Earth

PostPosted: Sat May 20, 2023 8:46 pm    Post subject: Reply with quote

you are right of course @Hu

i want to tease him a little bit and afterwords show him the link to the patch, but he was faster :)

from now on i will refrain do something like that again in the future.

8)
_________________
" Die Realität ist eine Illusion, die durch Mangel an ehrlicher Kommunikation entsteht "
---
" Der Mensch ist von Natur aus neugierig, was am Ende übrig bleibt ist die Gier "
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum