1
- ![ Portals] ( doc/website/assets/readme.png )
1
+ [ ![ Portals] ( doc/website/assets/readme.png )] ( https://flatpak.github.io/xdg-desktop-portal/ )
2
2
3
- # XDG Desktop Portal
3
+ # [ XDG Desktop Portal] ( https://flatpak.github.io/xdg-desktop-portal/ )
4
4
5
5
A portal frontend service for [ Flatpak] ( http://www.flatpak.org ) and other
6
6
desktop containment frameworks.
@@ -12,143 +12,8 @@ path (`/org/freedesktop/portal/desktop`).
12
12
The portal interfaces include APIs for file access, opening URIs, printing
13
13
and others.
14
14
15
- Documentation for the available D-Bus interfaces can be found
15
+ Documentation about the Common Conventions, as well as documentation for
16
+ App Developers, Desktop Developers and Contributors can be found
16
17
[ here] ( https://flatpak.github.io/xdg-desktop-portal/docs/ ) .
17
18
18
- ## Version Numbering
19
19
20
- xdg-desktop-portal uses even minor version numbers for stable versions, and odd
21
- minor version numbers for unstable versions. During an unstable version cycle,
22
- portal APIs can make backward incompatible changes, meaning that applications
23
- should only depend on APIs defined in stable xdg-desktop-portal versions in
24
- production.
25
-
26
- ## Building xdg-desktop-portal
27
-
28
- xdg-desktop-portal depends on GLib and Flatpak.
29
- To build the documentation, you will need xmlto and the docbook stylesheets.
30
- For more instructions, please read [ the contribution guidelines] ( https://flatpak.github.io/xdg-desktop-portal/docs/for-contributors.html ) .
31
-
32
- ## Using Portals
33
-
34
- Flatpak grants sandboxed applications _ talk_ access to names in the
35
- org.freedesktop.portal.\* prefix. One possible way to use the portal APIs
36
- is thus just to make D-Bus calls. For many of the portals, toolkits (e.g.
37
- GTK) are expected to support portals transparently if you use suitable
38
- high-level APIs.
39
-
40
- To implement most portals, xdg-desktop-portal relies on a backend
41
- that provides implementations of the org.freedesktop.impl.portal.\* interfaces.
42
-
43
- Here are some examples of available backends:
44
-
45
- - GTK [ xdg-desktop-portal-gtk] ( http://github.com/flatpak/xdg-desktop-portal-gtk )
46
- - GNOME [ xdg-desktop-portal-gnome] ( https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/ )
47
- - KDE [ xdg-desktop-portal-kde] ( https://invent.kde.org/plasma/xdg-desktop-portal-kde )
48
- - LXQt [ xdg-desktop-portal-lxqt] ( https://github.com/lxqt/xdg-desktop-portal-lxqt )
49
- - Pantheon (elementary OS) [ xdg-desktop-portal-pantheon] ( https://github.com/elementary/portals )
50
- - wlroots [ xdg-desktop-portal-wlr] ( https://github.com/emersion/xdg-desktop-portal-wlr )
51
- - Deepin [ xdg-desktop-portal-dde] ( https://github.com/linuxdeepin/xdg-desktop-portal-dde )
52
- - Xapp (Cinnamon, MATE, Xfce) [ xdg-desktop-portal-xapp] ( https://github.com/linuxmint/xdg-desktop-portal-xapp )
53
-
54
- ## Design Considerations
55
-
56
- There are several reasons for the frontend/backend separation of the portal
57
- code:
58
-
59
- - We want to have _ native_ portal dialogs that match the session desktop (i.e.
60
- GTK dialogs for GNOME, Qt dialogs for KDE)
61
- - One of the limitations of the D-Bus proxying in flatpak is that allowing a
62
- sandboxed app to talk to a name implicitly also allows it to talk to any other
63
- name owned by the same unique name. Therefore, sandbox-facing D-Bus APIs
64
- should generally be hosted on a dedicated bus connection. For portals, the
65
- frontend takes care of this for us.
66
- - The frontend can handle all the interaction with _ portal infrastructure_ , such
67
- as the permission store and the document store, freeing the backends to focus
68
- on just providing a user interface.
69
- - The frontend can also handle argument validation, and be strict about only
70
- letting valid requests through to the backend.
71
-
72
- The portal apis are all following the pattern of an initial method call, whose
73
- response returns an object handle for an _ org.freedesktop.portal.Request_ object
74
- that represents the portal interaction. The end of the interaction is done via a
75
- _ Response_ signal that gets emitted on that object. This pattern was chosen over
76
- a simple method call with return, since portal APIs are expected to show dialogs
77
- and interact with the user, which may well take longer than the maximum method
78
- call timeout of D-Bus. Another advantage is that the caller can cancel an
79
- ongoing interaction by calling the _ Cancel_ method on the request object.
80
-
81
- One consideration for deciding the shape of portal APIs is that we want them to
82
- 'hide' behind existing library APIs where possible, to make it as easy as
83
- possible to have apps use them _ transparently_ . For example, the OpenFile portal
84
- is working well as a backend for the GtkFileChooserNative API.
85
-
86
- When it comes to files, we need to be careful to not let portal APIs subvert the
87
- limited filesystem view that apps have in their sandbox. Therefore, files should
88
- only be passed into portal APIs in one of two forms:
89
-
90
- - As a document ID referring to a file that has been exported in the document
91
- portal
92
- - As an open fd. The portal can work its way back to a file path from the fd,
93
- and passing an fd proves that the app inside the sandbox has access to the
94
- file to open it.
95
-
96
- When it comes to processes, passing PIDs around is not useful in a sandboxed
97
- world where apps are likely in their own PID namespace. And passing PIDs from
98
- inside the sandbox is problematic, since the app can just lie.
99
-
100
- ## System Integration
101
-
102
- ### D-Bus Activation Environment
103
-
104
- xdg-desktop-portal and its portal backends are activatable D-Bus services.
105
- This means that they inherit environment variables from the
106
- "activation environment" maintained by either ` systemd --user `
107
- (on systems that use systemd) or ` dbus-daemon ` (on systems that do not).
108
- They do not inherit environment variables from the GUI environment or
109
- from the shell, unless some component of the overall system takes
110
- responsibility for taking the necessary environment variables from the
111
- GUI environment and sending them to ` systemd ` or ` dbus-daemon ` to be
112
- added to the activation environment.
113
-
114
- In integrated desktop environments such as GNOME and KDE Plasma, and in
115
- OS distributions with a high level of integration, this should be done
116
- automatically by desktop environment or OS infrastructure.
117
-
118
- Variables that might need to be propagated in this way include, but are
119
- not limited to:
120
-
121
- - ` DISPLAY `
122
- - ` PATH `
123
- - ` WAYLAND_DISPLAY `
124
- - ` XAUTHORITY `
125
- - ` XDG_CURRENT_DESKTOP `
126
- - ` XDG_DATA_DIRS `
127
-
128
- In environments that are assembled out of individual components by
129
- the user, it is the user's responsibility to ensure that this system
130
- integration has been done, for example by using
131
- [ dbus-update-activation-environment(1)] [ dbus-update-activation-environment ]
132
- or [ ` systemctl --user import-environment VAR… ` ] [ systemctl ] .
133
-
134
- ### Desktop Environment Requirements
135
-
136
- The display manager or GUI environment is responsible for setting
137
- ` XDG_CURRENT_DESKTOP ` to an appropriate value.
138
-
139
- The GUI environment should provide a
140
- [ portal configuration file] [ portals.conf ] with a name based on its
141
- ` XDG_CURRENT_DESKTOP ` , to select appropriate portal backends.
142
-
143
- The GUI environment should arrange for its required portal backend or
144
- backends to be installed as dependencies (possibly as optional
145
- dependencies, if it is packaged in a loosely-coupled operating system).
146
-
147
- In environments that are assembled out of individual components by
148
- the user, it is the user's responsibility to ensure that this system
149
- integration has been done.
150
-
151
- [ contributing ] : https://github.com/flatpak/xdg-desktop-portal/blob/main/CONTRIBUTING.md
152
- [ dbus-update-activation-environment ] : https://dbus.freedesktop.org/doc/dbus-update-activation-environment.1.html
153
- [ portals.conf ] : https://flatpak.github.io/xdg-desktop-portal/docs/portals.conf.html
154
- [ systemctl ] : https://www.freedesktop.org/software/systemd/man/latest/systemctl.html
0 commit comments