Bug 467999 - Focus stealing prevention is not working properly.
Summary: Focus stealing prevention is not working properly.
Status: RESOLVED DOWNSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 5.27.3
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-31 12:21 UTC by Yauheni Zviazdou
Modified: 2023-12-05 11:40 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Kwinrc config (1.57 KB, text/plain)
2023-03-31 12:21 UTC, Yauheni Zviazdou
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yauheni Zviazdou 2023-03-31 12:21:25 UTC
Created attachment 157738 [details]
Kwinrc config

SUMMARY
I had a kwin crash, after what all kwin setting was resetted to default. I don't know because of what all crashed, but now isn't working FocusStealingPreventionLevel even if I disable all plugins and set to default (except FocusStealingPreventionLevel). Panel highlight that something was opened in Browser/Dolphin/etc, but focus isn't changing. Before crash all works fine.


STEPS TO REPRODUCE
1. Set Window management -> Window behavior -> Focus -> Focus stealing prevention: None
2. Click on any link in Kate/Konsole/Telegram etc
3. Focus was not changed

OBSERVED RESULT
Hilighting in panel

EXPECTED RESULT
Focus change

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.3
KDE Frameworks Version: 5.104.0
Qt Version: 5.15.8
Kernel Version: 6.2.8-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-8550U CPU @ 1.80GHz
Memory: 15.5 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620
Manufacturer: TIMI
Product Name: TM1707
System Version: Mi Laptop Pro 15.6

ADDITIONAL
I tried to rename ~/.config/kwinrc to generage new kwinrc config, but this doesn't work. I've attached my kwinrc file.
Comment 1 Yauheni Zviazdou 2023-03-31 12:24:12 UTC
Comment on attachment 157738 [details]
Kwinrc config

In this file FocusStealingPreventionLevel=1, but when FocusStealingPreventionLevel=0 focus isn't  changing too.
Comment 2 Yauheni Zviazdou 2023-03-31 12:26:13 UTC
Comment on attachment 157738 [details]
Kwinrc config

In this file FocusStealingPreventionLevel=1, but when FocusStealingPreventionLevel=0 focus isn't changing too.
Comment 3 Nate Graham 2023-04-04 18:42:33 UTC
In step 3, what exactly were you expecting to happen? Which app should have come to the front?
Comment 4 Yauheni Zviazdou 2023-04-04 23:02:47 UTC
(In reply to Nate Graham from comment #3)
> In step 3, what exactly were you expecting to happen? Which app should have
> come to the front?

I expect, that focus will be moved to the browser (and browser comes to the front), If I clicked on "https://kde.org" (on Konsole  for example).
Comment 5 Nate Graham 2023-04-04 23:03:21 UTC
Which browser is it? And which version of the browser?
Comment 6 Yauheni Zviazdou 2023-04-04 23:10:48 UTC
(In reply to Nate Graham from comment #5)
> Which browser is it? And which version of the browser?

It's Google Chrome, version 112.0.5615.49-1 (with --ozone-platform=wayland)

But focus moving doesn't work with dolphin too (when I'm clicking on the file link)(In reply to Nate Graham from comment #5)
> Which browser is it? And which version of the browser?

It's Google Chrome, version 112.0.5615.49-1 (with --ozone-platform=wayland)

But focus moving doesn't work with dolphin too (when I'm clicking on the file url)
Comment 7 Nate Graham 2023-04-05 14:46:16 UTC
So the way focus-passing works on Wayland is that both the source and destination app need to have implemented the xdg_activation_v1 protocol. All KDE apps have, and Firefox has, but to my knowledge, Chromium has not done so yet. So that's the source of the problem. Focus stealing isn't actually involved at all here; focus isn't being handed off at all due to a lack of support for the activation protocol. So I'm afraid this is a Chromium bug.
Comment 8 Yauheni Zviazdou 2023-04-19 18:59:34 UTC
(In reply to Nate Graham from comment #7)
> So the way focus-passing works on Wayland is that both the source and
> destination app need to have implemented the xdg_activation_v1 protocol. All
> KDE apps have, and Firefox has, but to my knowledge, Chromium has not done
> so yet. So that's the source of the problem. Focus stealing isn't actually
> involved at all here; focus isn't being handed off at all due to a lack of
> support for the activation protocol. So I'm afraid this is a Chromium bug.

Sorry, I missed your message. 
You wrote that all KDE apps have implementation of this protocol, but when I type `xdg-open .` command in konsole, focus isn't changing to dolphin.
Comment 9 Nate Graham 2023-04-19 19:07:28 UTC
Dolphin does, but `xdg-open` doesn't. Both the sending and receiving apps need to support it.
Comment 10 Yauheni Zviazdou 2023-04-19 19:08:37 UTC
(In reply to Nate Graham from comment #9)
> Dolphin does, but `xdg-open` doesn't. Both the sending and receiving apps
> need to support it.

Understood, thank you for answer!
Comment 11 Yevhen Popok 2023-12-02 10:22:08 UTC
(In reply to Nate Graham from comment #9)
> Dolphin does, but `xdg-open` doesn't. Both the sending and receiving apps
> need to support it.

I have a similar issue on Wayland (Fedora Kinoite Nightly).  
"FocusStealingPreventionLevel" is set for KWin and I have a Kate window opened. When I'm opening some text file from Dolphin, Kate window is not raised automatically. Task manager doesn't even notify me that Kate window requires attention.
If Kate is closed and I open some file associated with Kate, focus appropriately migrates to the Kate window.
Not sure if this issue is on the KWin/Wayland or Kate side.
Comment 12 Nate Graham 2023-12-04 21:09:54 UTC
Could be KWin, could be Kate, and it could even be Dolphin. If you turn focus stealing prevention off entirely and it still happens, that rules out KWin, at least.
Comment 13 Yevhen Popok 2023-12-05 11:40:32 UTC
(In reply to Yevhen from comment #11)
> (In reply to Nate Graham from comment #9)
> > Dolphin does, but `xdg-open` doesn't. Both the sending and receiving apps
> > need to support it.
> 
> I have a similar issue on Wayland (Fedora Kinoite Nightly).  
> "FocusStealingPreventionLevel" is set for KWin and I have a Kate window
> opened. When I'm opening some text file from Dolphin, Kate window is not
> raised automatically. Task manager doesn't even notify me that Kate window
> requires attention.
> If Kate is closed and I open some file associated with Kate, focus
> appropriately migrates to the Kate window.
> Not sure if this issue is on the KWin/Wayland or Kate side.

It could be a temporary distribution packaging/migration issue on Fedora 40 Rawhide. Flatpak version of Kate doesn't always "steal focus" on Plasma 6 but informs when its window requires attention.