Skip to content

fix(background): Only emit RunningApplicationsChanged on toplevel create/destroy#250

Open
counterapparatus wants to merge 7 commits intopop-os:masterfrom
counterapparatus:background-portal
Open

fix(background): Only emit RunningApplicationsChanged on toplevel create/destroy#250
counterapparatus wants to merge 7 commits intopop-os:masterfrom
counterapparatus:background-portal

Conversation

@counterapparatus
Copy link

Summary

This continues the work from #70, addressing the signal spam issue raised by @ids1024.

The RunningApplicationsChanged signal was being emitted on every update_toplevel event (focus changes, title changes, etc.), causing excessive D-Bus signal spam. This change only emits the signal on new_toplevel and toplevel_closed events, matching GNOME's behavior.

Changes

  • Removed update_output_toplevels() call from update_toplevel handler in src/wayland/toplevel.rs

Testing

  • ✅ Tested with the background portal example app - permission requests work
  • ✅ Tested with the real world app where i noticed this problem, Pika Backup - scheduled backups and autostart work correctly

Related

joshuamegnauth54 and others added 7 commits May 24, 2025 23:59
I based my implementation on the official specs as well as code from
GNOME, KDE, Xapp (Xfce), and Pantheon (elementary). KDE's imminently
readable codebase served as this implementation's primary inspiration.

Autostart is deprecated but seemingly still used, so this implementation
will still support it for compatibility.

The Background portal depends on a working Access portal as
`xdg-desktop-portal` calls it to show the initial warning.

References:
* https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.impl.portal.Background.html
* https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/blob/main/src/background.c
* https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/blob/master/src/background.cpp
* https://github.com/linuxmint/xdg-desktop-portal-xapp/blob/f1c24244f90571209c56b7f45802b70e80da4922/src/background.c
* https://github.com/elementary/portals/blob/d868cfa854c731e0f37615e225d5db07cc3f4604/src/Background/Portal.vala
* flatpak/xdg-desktop-portal#1188
Squashed:
* Rebase on the latest zbus
* Fix types for get_app_state to not return an error nor a nested dict
* Fix get_app_state so that apps default to running in the background
  unless they have open toplevels
`xdg-desktop-portal` expects this. It's easy enough to serialize this
way.
…ate/destroy

Don't emit the signal on update_toplevel events (focus changes, title
changes, etc.) as this causes excessive signal spam. Only emit when
windows are actually created or destroyed, matching GNOME's behavior.
@jacobgkau
Copy link
Member

Thank you for working on this, but #70 has conflicts that need to be resolved, and this PR does too since you based it on #70.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Background Portal unsupported

4 participants