linux-is-awesome / gnome_extension_rocketbar

Taskbar and misc additions for the GNOME Shell.
GNU General Public License v3.0
17 stars 3 forks source link

Notification Badge might appear on an incorrect app (Chromium PWA) #26

Closed xalt7x closed 1 year ago

xalt7x commented 1 year ago

How to reproduce: 1) Using Chromium browser (e.g. Google Chrome) install Google Chat PWA 2) Exit browser (so GNOME would see separate Google Chat launcher) 3) Launch both "Google Chat PWA" and "Google Chrome" (without no opened pages) 4) Switch to "Google Chrome" 5) Write yourself to Google Chat from different account using different device or browser

Expected result: Notification badge appear on a Google Chat icon and disappear if you open it

Current situation: Notification badge will appear on the latest "Google Chrome window" you've opened (if it was browser window - it will appear there, if it was PWA - everything is fine). But when you actually click on notification from the Message Tray then correct PWA window opens (no matter whether it was the last opened window Chrome window or not).

Is there a way to determine exact "application"? I'm experimenting with "Dash to Panel" mod and tried both "get_id()" and "get_name()" functions with no luck.

OS: Ubuntu 22.04 GNOME version: 42.5

ChepKun commented 1 year ago

Thanks for the report! I'll take a look

ChepKun commented 1 year ago

This problem could be related to the dbus interface /org/freedesktop/Notifications or to the FdoNotificationDaemon in Gnome Shell.

I haven't found a way to identify the exact window that sends notifications. In the extension I receive notification sources from the Message Tray and can attach notifications to the app buttons using appId, pid and title fields, but pid and title are the same for all opened Chrome windows, and appId depends on the last opened window. So regarding clicks on notifications in the Message Tray: seems like Chrome does some magic under the hood and focuses the chat application window, even when the notification source points to the Chrome app itself.

As a workaround I can only suggest to create a web app using another browser or use something like that based on electron https://github.com/ankurk91/google-chat-electron.

ChepKun commented 1 year ago

A small update regarding notification clicks: the dbus interface allows clients to set callback functions to handle user interactions. So I think Chrome adds such callbacks to handle notification clicks and focus the chat window when a notification belongs to the window. This will not help me to solve the current issue, but just wanted to mention.

xalt7x commented 1 year ago

Thanks for the explanations! If there's no easy way to determine exact window with native GNOME functions, maybe it's possible to expose D-Bus interface like activate-window-by-title extension does?

ChepKun commented 1 year ago

Not sure how it may help to identify notification senders. Chrome will not be aware about the new dbus interface and will not send any information to it by default. Or maybe I'm not following the idea... could you probably explain it?

xalt7x commented 1 year ago

I've had an assumption that there's could by some other ways to identify application except "get_id()" and "get_name()". Something like WM_CLASS (exact match) or WM_NAME (whole title, not just an application name) For example Google Chrome and Google Chat PWA windows got slightly different WM_CLASS

WM_CLASS(STRING) = "google-chrome", "Google-chrome"
WM_CLASS(STRING) = "crx_mdpkiolbdkhdjpekfbkbmhigcaggjagi", "Google-chrome"

But again I'm not sure what useful data MessageTray receive except id (e.g. "google-chrome") & title (e.g. "Google Chrome")

ChepKun commented 1 year ago

It doesn't receive anything useful for this particular case, that's the problem. After digging into the code I would be more likely to say that the issue is caused by Chrome itself and how it pushes notifications. Probably this can be solved by introducing some extension for the browser, but it's just a thought. If there is a way to isolate chrome processes in the system from each other, this also might help, but I haven't tested it.

xalt7x commented 1 year ago

That's a shame. BTW, since Microsoft deprecates "Teams" Linux client they would promote it's PWA as an "official application". So I guess users would need to use "Edge", "Ferdium" (which luckily supports UnityAPI) or some other Electron-based app. Anyway, thanks for your time & research!

ChepKun commented 1 year ago

Fortunately we also have unofficial client for teams https://github.com/IsmaelMartinez/teams-for-linux, I used it most of the time because the official one didn't work for me. You're welcome!