-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Background portal #70
base: master
Are you sure you want to change the base?
Background portal #70
Conversation
8a4ca82
to
5d6e3f2
Compare
c725ec4
to
57e06f4
Compare
9a93471
to
d2d7b90
Compare
d2d7b90
to
0e5eeb2
Compare
78be554
to
b1026bb
Compare
Looks like it was deprecated in May (flatpak/xdg-desktop-portal@458560c) and the last release was in April. So presumably it's still required on released versions of xdg-desktop-portal, but won't in the next. |
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
3e21b4e
to
c82b8ad
Compare
c82b8ad
to
ff66c14
Compare
Their reasoning makes sense. Every portal backend I checked implements autostart the same way (which, in a way, was really nice because it made it easier to implement here 😂 ). This is finally done and it works too! I learned a lot in the process as well. |
// xxx Is this the correct way to determine if a program is running in the | ||
// background? If a toplevel exists but isn't running, activated, et cetera, | ||
// then it logically must be in the background (?) | ||
AppStatus::Background |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is right. A toplevel is a window, this state seems to describe applications without a window. So the logic should be: If any toplevel exists, then the app is either Running or Active. We currently don't have a protocol to enumerate applications without a window.
I would think the portal would have to track apps launched in the background.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review and help!
I checked how GNOME handles GetAppState. GNOME exposes a D-Bus interface that allows retrieving the list of running applications. It also has a signal for app updates.
Its Background portal uses that interface to check app statuses. An app that is running without windows is in the background. Apps with windows have their toplevel status checked (active, running).
KDE doesn't seem to check if a program is in the background at all. 🤔 I find this confusing.
The code for the GNOME background portal is pretty straightforward, but I'll have to check if there is a way to get running apps easily via COSMIC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't because we don't track "running applications" (which KDE probably also isn't doing), because doing so isn't exactly easy. Any running binary could be an "app".
I assume what Gnome is doing internally is:
- Handle flatpaks as apps
- Use app-scopes to identify apps it launched through one of it's interfaces (still doesn't help with stuff started e.g. via a terminal).
You can do similar things on cosmic, as we also set the corresponding app-scopes. (e.g. systemctl --user list-units -t scope | grep -e "app-flatpak" -e "app-cosmic"
)
You would use the systemd dbus interface in the portal to enumerate the scopes, filter for app-cosmic
and app-flatpak
and pull the app_id
from the name (the third component). Afterwards you can lookup the desktop-file, if you need anything more.
Requires the access portal to be enabled or else it does nothing
I based my implementation on the official specs as well as code from GNOME, KDE, Xapp (Xfce), and Pantheon (elementary). KDE's immaculately readable codebase served as this implementation's primary inspiration.
Like KDE, I intend to show a dialog, so the user may choose whether to grant privileges to an application. I will also provide an option to bypass the dialog for greater choice especially considering that GNOME automatically grants permissions.
According to the docs, the Autostart method is deprecated. However, I think I still need to implement it because background requests aren't routed to the COSMIC portal unless it's available.Autostart is implementedCloses: #49