Bug 435415 - On NixOS, notifications, OSDs, and KRunner appear in task manager and steal focus
Summary: On NixOS, notifications, OSDs, and KRunner appear in task manager and steal f...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.22.4
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-06 10:14 UTC by Peter Hoeg
Modified: 2021-11-20 16:47 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Logs from `WAYLAND_DEBUG=1 krunner --replace` (50.71 KB, text/plain)
2021-06-12 15:26 UTC, iam
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Hoeg 2021-04-06 10:14:29 UTC
SUMMARY

This is most probably not a kwin bug per se, but rather a consequence of how things on NixOS are quite different from other distributions.

The problem we are seeing with wayland is that notifications and krunner are treated as first-class windows and therefore appear in the task manager (not a big issue) and also take focus (very annoying with notifications). There are not errors in the journal that to shed any light on this.

It's probably because nixos is different, so any pointers to where to look would be much appreciated.

STEPS TO REPRODUCE
1. Install latest nixos unstable
2. Run plasma wayland
3. Trigger krunner (or wait for a notification to appear)

OBSERVED RESULT

Notice an icon in the task manager or the focus being on a notification.

EXPECTED RESULT

Notifications should not have focus and not appear in the task manager.


SOFTWARE/OS VERSIONS
Linux: 5.11.10
KDE Plasma Version: 5.21.3
KDE Frameworks Version: 5.79 (5.80 will be arriving shortly and then tested as well - I will update this ticket then)
Qt Version: 5.15.2

ADDITIONAL INFORMATION

https://github.com/NixOS/nixpkgs/issues/118650
Comment 1 David Edmundson 2021-04-06 10:40:51 UTC
Are they in the wrong position too?
Comment 2 Peter Hoeg 2021-04-06 11:01:21 UTC
I have set my notifications to appear in the bottom right of the left screen with a vertical panel on the left. The notifications appear as expected.

The krunner pop-down also appears correctly from the top (haven't tried with the floating krunner).

But now that you mention it, I do remember seeing a few other popups (like the volume) control showing in the top left, where they definitely didn't belong. When I mention notifications, I mean the ones you can send with `notify-send` - they are the biggest issue due to the focus steal.
Comment 3 Peter Hoeg 2021-04-14 06:31:19 UTC
Any suggestions as to where to start digging to find out what is causing this?
Comment 4 Peter Hoeg 2021-05-06 00:43:37 UTC
I am not at all asking for anyone to do the actual work - it would just be super helpful with some pointers regarding where to start looking considering I'm not at all familiar with the plasma code.

Also found this which sounds like it could be related:

https://community.kde.org/Plasma/Notifications#DesktopEntry_in_notifyrc
Comment 5 Bharadwaj Raju 2021-05-06 04:32:55 UTC
(In reply to Peter Hoeg from comment #4)
> Also found this which sounds like it could be related:
> 
> https://community.kde.org/Plasma/Notifications#DesktopEntry_in_notifyrc

I don't think it is. The desktop entry stuff is only used to provide per-app notification settings, proper icon, etc. It shouldn't have any bearing on how notification popups are treated by the WM.

For debugging, try:

1. Set notification popup timeout to some long value
2. Get a notification (eg using notify-send)
3. Open System Settings > Window Management > Window Rules
4. Click Add New, then click Detect Window Properties
5. Now click on the notification popup

This way you can see the various hints and flags set on the window (like Skip Taskbar, etc). This should be helpful.

As for the code, I believe it is in https://invent.kde.org/plasma/plasma-workspace/-/blob/master/applets/notifications/package/contents/ui/NotificationPopup.qml, and other files in the vicinity.
Comment 6 Peter Hoeg 2021-05-28 03:59:03 UTC
Thanks for the details. Work continues on the mentioned github issue - it has to do with the window class and how we wrap things on NixOS.
Comment 7 David Redondo 2021-06-01 11:15:03 UTC
Can you provide the output of 

WALYAND_DEBUG=1 krunner --replace 

in the case where it appears in the taskmanager?
Comment 8 iam 2021-06-12 15:26:29 UTC
Created attachment 139257 [details]
Logs from `WAYLAND_DEBUG=1 krunner --replace`
Comment 9 iam 2021-06-12 15:31:18 UTC
OSDs (IME, volume) is in wrong position (top left, but not overlapping taskbar) and stealing focus too
Comment 10 p3dimaria 2021-09-04 09:31:00 UTC
I've made further progress investigating it in https://github.com/NixOS/nixpkgs/issues/118650#issuecomment-895582456

In particular, I've found that notifications and OSD have window type "Normal window" and their name is "org.kde.plasmashell", while their entire class is ".plasmashell-wrapped.org.kde.plasmashell".

Note that ".plasmashell-wrapped" is the name of the actual plasmashell executable on NixOS."plasmashell" is merely a shell wrapper setting a few env vars correctly before execing it.

However we already patched service_utils.h to account for it https://github.com/NixOS/nixpkgs/blob/7db379d016a9bad7b7da9b81103ab7454faa3344/pkgs/desktops/plasma-5/kwin/0001-NixOS-Unwrap-executable-name-for-.desktop-search.patch
Comment 11 p3dimaria 2021-09-04 09:36:16 UTC
I've also found that window type on X11 (where everything work as expected) is empty for notifications.
Comment 12 André M 2021-09-13 18:14:47 UTC
I can confirm this bug on NixOS, latest plasma5 5.22.5 & kf5.86. Interesting is that, even adding a very broad KWin rule for any type of window with Window class containing a substring of "org.kde.plasmashell" (detected properties) and forcing it to Skip taskbar and Extreme Window focus stealing prevention doesn't work, notifications still show up in taskbar and focus is stolen. Only on Wayland.