Skip to content
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

Add Clipboard support for RemoteDesktop via org.freedesktop.portal.Clipboard #852

Merged
merged 3 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ portal_sources = files(
'org.freedesktop.portal.Account.xml',
maxhbooth marked this conversation as resolved.
Show resolved Hide resolved
'org.freedesktop.portal.Background.xml',
'org.freedesktop.portal.Camera.xml',
'org.freedesktop.portal.Clipboard.xml',
'org.freedesktop.portal.Device.xml',
'org.freedesktop.portal.Documents.xml',
'org.freedesktop.portal.DynamicLauncher.xml',
Expand Down Expand Up @@ -42,6 +43,7 @@ portal_impl_sources = files(
'org.freedesktop.impl.portal.Account.xml',
'org.freedesktop.impl.portal.AppChooser.xml',
'org.freedesktop.impl.portal.Background.xml',
'org.freedesktop.impl.portal.Clipboard.xml',
'org.freedesktop.impl.portal.DynamicLauncher.xml',
'org.freedesktop.impl.portal.Email.xml',
'org.freedesktop.impl.portal.FileChooser.xml',
Expand Down
180 changes: 180 additions & 0 deletions data/org.freedesktop.impl.portal.Clipboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<?xml version="1.0"?>
<!--
Copyright 2022 Google LLC

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
-->

<node name="/"
xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
<!--
org.freedesktop.impl.portal.Clipboard
@short_description: Clipboard portal backend interface

The Clipboard portal allows sessions to access the clipboard.
-->
<interface name="org.freedesktop.impl.portal.Clipboard">
<!--
RequestClipboard:
@session_handle: Object path for the #org.freedesktop.portal.Session object
@options: Vardict with optional further information

Requests clipboard access for the given portal session. This request
must be made before the session starts.

This portal does NOT create it's own session. Instead, it offers existing sessions
created from other portals the option to integrate with the clipboard. For whether
this interface is supported for a given session, refer to that portal's documentation.
See #org.freedesktop.portal.RemoteDesktop to integrate clipboard with the
remote desktop session.
-->
<method name="RequestClipboard">
<arg type="o" name="session_handle" direction="in"/>
maxhbooth marked this conversation as resolved.
Show resolved Hide resolved
<arg type="a{sv}" name="options" direction="in"/>
</method>
<!--
SetSelection:
@session_handle: Object path for the #org.freedesktop.portal.Session object
@options: Vardict with optional further information

Sets the owner of the clipboard formats in 'mime_types' in @options to
the session, i.e. this session has data for the advertised clipboard formats.

See #org.freedesktop.portal.FileTransfer to transfer files using the
'application/vnd.portal.filetransfer' mimetype.

May only be called if clipboard access was given after starting the session.

Supported keys in the @options vardict include:
<variablelist>
<varlistentry>
<term>mime_types as</term>
<listitem><para>
A list of mime types that the session has clipboard content for.
</para></listitem>
</varlistentry>
</variablelist>
-->
<method name="SetSelection">
<arg type="o" name="session_handle" direction="in"/>
<arg type="a{sv}" name="options" direction="in"/>
</method>
<!--
SelectionWrite:
@session_handle: Object path for the #org.freedesktop.portal.Session object
@serial: The serial of the request where this answer is directed towards
@fd: A UnixFD handle to the contents of the selection being written to

Answer to 'SelectionTransfer' signal. Transfers the clipboard content for
the given serial to the method callee via a file descriptor.
It is the Callee that creates the file descriptor.

May only be called if clipboard access was given after starting the session.
-->
<method name="SelectionWrite">
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="o" name="session_handle" direction="in"/>
<arg type="u" name="serial" direction="in"/>
<arg type="h" name="fd" direction="out"/>
</method>
<!--
SelectionWriteDone:
@session_handle: Object path for the #org.freedesktop.portal.Session object
@serial: The serial of the request where this answer is directed to
@success: A boolean which indicates whether the transfer of the clipboard
data was successful ('true') or not ('false')

Notifies that the transfer of the clipboard data has either completed
successfully, or failed.

May only be called if clipboard access was given after starting the session.
-->
<method name="SelectionWriteDone">
<arg type="o" name="session_handle" direction="in"/>
<arg type="u" name="serial" direction="in"/>
<arg type="b" name="success" direction="in"/>
</method>
<!--
SelectionRead:
@session_handle: Object path for the #org.freedesktop.portal.Session object
@mime_type: The mime-type string of the requested format
@fd: A UnixFD handle to the contents of the selection being read

Transfer the clipboard content given the specified mime type to the
method caller via a file descriptor.
It is the callee that creates the file descriptor.

May only be called if clipboard access was given after starting the session.
-->
<method name="SelectionRead">
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="o" name="session_handle" direction="in"/>
<arg type="s" name="mime_type" direction="in"/>
<arg type="h" name="fd" direction="out"/>
</method>
<!--
SelectionOwnerChanged:
@session_handle: Object path for the #org.freedesktop.portal.Session object
@options: Vardict with optional further information

Notifies the session that the clipboard selection has changed.

Caller will only be notified if clipboard access was given after starting the session.

Supported keys in the @options vardict include:
<variablelist>
<varlistentry>
<term>mime_types as</term>
<listitem><para>
A list of mime types that the the new clipboard selection has content for.
</para></listitem>
</varlistentry>
<varlistentry>
<term>session_is_owner b</term>
<listitem><para>
A boolean for whether the session is the owner of the clipboard selection ('true') or not ('false').
</para></listitem>
</varlistentry>
</variablelist>
-->
<signal name="SelectionOwnerChanged">
<arg type="o" name="session_handle" direction="out"/>
<arg type="a{sv}" name="options" direction="out"/>
</signal>
<!--
SelectionTransfer:
@session_handle: Object path for the #org.freedesktop.portal.Session object
@mime_type: The mime-type string of the requested format
@serial: The serial used to track this transfer, to which the answer of this request must use

Notifies the session of a request for clipboard content of the given mime type. The
callee provides a serial to track the request, which any
org.freedesktop.portal.Clipboard.SelectionWrite() responses must use.

Once the caller is done handling the 'SelectionTransfer' request, they must call
org.freedesktop.portal.Clipboard.SelectionWriteDone() with the corresponding request's serial
and whether the request completed successfully. If the request is not handled, the caller should
respond by setting 'success' to 'false'.

Caller will only be notified if clipboard access was given after starting the session.
-->
<signal name="SelectionTransfer">
<arg type="o" name="session_handle" direction="out"/>
<arg type="s" name="mime_type" direction="out"/>
<arg type="u" name="serial" direction="out"/>
</signal>

<property name="version" type="u" access="read"/>
</interface>
</node>
33 changes: 33 additions & 0 deletions data/org.freedesktop.impl.portal.RemoteDesktop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
@short_description: Remote desktop portal backend interface

The Remote desktop portal allows to create remote desktop sessions.

This documentation describes version 2 of this interface.
-->
<interface name="org.freedesktop.impl.portal.RemoteDesktop">
<!--
Expand Down Expand Up @@ -79,6 +81,37 @@
@response: Numeric response
@results: Vardict with the results of the call

Supported keys in the @options vardict include:
<variablelist>
<varlistentry>
<term>handle_token s</term>
<listitem><para>
A string that will be used as the last element of the @handle. Must be a valid
object path element. See the #org.freedesktop.portal.Request documentation for
more information about the @handle.
</para></listitem>
</varlistentry>
</variablelist>

The following results get returned via the
#org.freedesktop.portal.Request::Response signal:
<variablelist>
<varlistentry>
<term>devices u</term>
<listitem><para>
A bitmask of the devices selected by the user.
</para></listitem>
</varlistentry>
<varlistentry>
<term>clipboard_enabled b</term>
<listitem><para>
A boolean for whether the clipboard was enabled ('true') or not ('false').
See the #org.freedesktop.portal.Clipboard documentation for more information.
Since version 2.
</para></listitem>
</varlistentry>
</variablelist>

Start the remote desktop session.
-->
<method name="Start">
Expand Down
Loading
Loading