mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 12:52:14 +00:00
remote-desktop/session: Added boiler plate for clipboard integration
Nothing is hooked up, it only does basic sanity checking i.e. whether the clipboard was enabled when interacting with it. No actual clipboard integration is hooked up yet. This also syncs org.gnome.Mutter.RemoteDesktop.xml from gnome-remote-desktop. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
This commit is contained in:
parent
54b024465e
commit
ac1a5366b1
@ -66,6 +66,8 @@ struct _MetaRemoteDesktopSession
|
||||
ClutterVirtualInputDevice *virtual_touchscreen;
|
||||
|
||||
MetaRemoteDesktopSessionHandle *handle;
|
||||
|
||||
gboolean is_clipboard_enabled;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -791,6 +793,164 @@ handle_notify_touch_up (MetaDBusRemoteDesktopSession *skeleton,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_enable_clipboard (MetaDBusRemoteDesktopSession *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
GVariant *arg_options)
|
||||
{
|
||||
MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
|
||||
|
||||
meta_topic (META_DEBUG_REMOTE_DESKTOP,
|
||||
"Enable clipboard for %s",
|
||||
g_dbus_method_invocation_get_sender (invocation));
|
||||
|
||||
if (session->is_clipboard_enabled)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
|
||||
G_DBUS_ERROR_FAILED,
|
||||
"Already enabled");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
session->is_clipboard_enabled = TRUE;
|
||||
|
||||
meta_dbus_remote_desktop_session_complete_enable_clipboard (skeleton,
|
||||
invocation);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_disable_clipboard (MetaDBusRemoteDesktopSession *skeleton,
|
||||
GDBusMethodInvocation *invocation)
|
||||
{
|
||||
MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
|
||||
|
||||
meta_topic (META_DEBUG_REMOTE_DESKTOP,
|
||||
"Disable clipboard for %s",
|
||||
g_dbus_method_invocation_get_sender (invocation));
|
||||
|
||||
if (!session->is_clipboard_enabled)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
|
||||
G_DBUS_ERROR_FAILED,
|
||||
"Was not enabled");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
meta_dbus_remote_desktop_session_complete_disable_clipboard (skeleton,
|
||||
invocation);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_set_selection (MetaDBusRemoteDesktopSession *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
GVariant *arg_options)
|
||||
{
|
||||
MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
|
||||
|
||||
meta_topic (META_DEBUG_REMOTE_DESKTOP,
|
||||
"Set selection for %s",
|
||||
g_dbus_method_invocation_get_sender (invocation));
|
||||
|
||||
if (!session->is_clipboard_enabled)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
|
||||
G_DBUS_ERROR_FAILED,
|
||||
"Clipboard not enabled");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
meta_dbus_remote_desktop_session_complete_set_selection (skeleton,
|
||||
invocation);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_selection_write (MetaDBusRemoteDesktopSession *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
GUnixFDList *fd_list,
|
||||
unsigned int serial)
|
||||
{
|
||||
MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
|
||||
|
||||
meta_topic (META_DEBUG_REMOTE_DESKTOP,
|
||||
"Write selection for %s",
|
||||
g_dbus_method_invocation_get_sender (invocation));
|
||||
|
||||
if (!session->is_clipboard_enabled)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
|
||||
G_DBUS_ERROR_FAILED,
|
||||
"Clipboard not enabled");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
meta_dbus_remote_desktop_session_complete_selection_write (skeleton,
|
||||
invocation,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_selection_write_done (MetaDBusRemoteDesktopSession *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
unsigned int arg_serial,
|
||||
gboolean arg_success)
|
||||
{
|
||||
MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
|
||||
|
||||
meta_topic (META_DEBUG_REMOTE_DESKTOP,
|
||||
"Write selection done for %s",
|
||||
g_dbus_method_invocation_get_sender (invocation));
|
||||
|
||||
if (!session->is_clipboard_enabled)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
|
||||
G_DBUS_ERROR_FAILED,
|
||||
"Clipboard not enabled");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
meta_dbus_remote_desktop_session_complete_selection_write_done (skeleton,
|
||||
invocation);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_selection_read (MetaDBusRemoteDesktopSession *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
GUnixFDList *fd_list,
|
||||
const char *mime_type)
|
||||
{
|
||||
MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
|
||||
|
||||
meta_topic (META_DEBUG_REMOTE_DESKTOP,
|
||||
"Read selection for %s",
|
||||
g_dbus_method_invocation_get_sender (invocation));
|
||||
|
||||
if (!session->is_clipboard_enabled)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
|
||||
G_DBUS_ERROR_FAILED,
|
||||
"Clipboard not enabled");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
meta_dbus_remote_desktop_session_complete_selection_read (skeleton,
|
||||
invocation,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_remote_desktop_session_init_iface (MetaDBusRemoteDesktopSessionIface *iface)
|
||||
{
|
||||
@ -806,6 +966,12 @@ meta_remote_desktop_session_init_iface (MetaDBusRemoteDesktopSessionIface *iface
|
||||
iface->handle_notify_touch_down = handle_notify_touch_down;
|
||||
iface->handle_notify_touch_motion = handle_notify_touch_motion;
|
||||
iface->handle_notify_touch_up = handle_notify_touch_up;
|
||||
iface->handle_enable_clipboard = handle_enable_clipboard;
|
||||
iface->handle_disable_clipboard = handle_disable_clipboard;
|
||||
iface->handle_set_selection = handle_set_selection;
|
||||
iface->handle_selection_write = handle_selection_write;
|
||||
iface->handle_selection_write_done = handle_selection_write_done;
|
||||
iface->handle_selection_read = handle_selection_read;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -195,6 +195,141 @@
|
||||
<arg name="slot" type="u" direction="in" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
EnableClipboard:
|
||||
@options: Options for the clipboard
|
||||
|
||||
Available @options include:
|
||||
|
||||
* "mime-types" (as): List of mime types, for which the clipboard of the
|
||||
remote desktop client has content.
|
||||
Each mime-type is in string form, e.g. "image/jpeg",
|
||||
"text/plain", etc..
|
||||
If this list is included in @options, then this call
|
||||
is equivalent to calling 'EnableClipboard' and
|
||||
'SetSelection' atomically.
|
||||
|
||||
Enables the clipboard for the remote desktop client which will allow it
|
||||
to call the methods 'SetSelection', 'DisableClipboard', 'SelectionWrite',
|
||||
'SelectionWriteDone', 'SelectionRead'.
|
||||
The 'SelectionOwnerChanged' signal will also be emitted when the
|
||||
selection owner changes to inform the API user of new clipboard mime
|
||||
types, and the 'SelectionTransfer' signal will be emitted to request the
|
||||
advertised clipboard content of a mime type.
|
||||
-->
|
||||
<method name="EnableClipboard">
|
||||
<arg name="options" type="a{sv}" direction="in" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
DisableClipboard:
|
||||
|
||||
Unregisters all clipboard types that were advertised by the
|
||||
remote desktop client.
|
||||
The 'SelectionOwnerChanged' or 'SelectionTransfer' signals will not be
|
||||
emitted any more.
|
||||
Any 'SelectionTransfer' signals that weren't answered yet with a
|
||||
'SelectionWriteDone' call, will be answered with a 'SelectionWriteDone'
|
||||
call where 'success' is 'false'.
|
||||
-->
|
||||
<method name="DisableClipboard" />
|
||||
|
||||
<!--
|
||||
SetSelection:
|
||||
@options: Options for the clipboard selection
|
||||
|
||||
Available @options include:
|
||||
|
||||
* "mime-types" (as): List of mime types, for which the clipboard of the
|
||||
remote desktop client has content.
|
||||
Each mime-type is in string form, e.g. "image/jpeg",
|
||||
"text/plain", etc..
|
||||
|
||||
Sets the owner of the clipboard formats in 'mime-types' in @options to
|
||||
the remote desktop client, i.e. the remote desktop client has data for
|
||||
these advertised clipboard formats.
|
||||
-->
|
||||
<method name="SetSelection">
|
||||
<arg name="options" type="a{sv}" direction="in" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
SelectionWrite:
|
||||
@serial: The serial of the request where this answer is directed to
|
||||
@fd: The file descriptor where the data will be written to
|
||||
|
||||
Answer to 'SelectionTransfer' signal. Contains the fd where the clipboard
|
||||
content will be written to.
|
||||
-->
|
||||
<method name="SelectionWrite">
|
||||
<arg name="serial" type="u" direction="in" />
|
||||
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
|
||||
<arg name="fd" type="h" direction="out" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
SelectionWriteDone:
|
||||
@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.
|
||||
-->
|
||||
<method name="SelectionWriteDone">
|
||||
<arg name="serial" type="u" direction="in" />
|
||||
<arg name="success" type="b" direction="in" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
SelectionRead:
|
||||
@mime_type: The mime-type string of the requested format
|
||||
@fd: The file descriptor where the data will be written to
|
||||
|
||||
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.
|
||||
-->
|
||||
<method name="SelectionRead">
|
||||
<arg name="mime_type" type="s" direction="in" />
|
||||
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
|
||||
<arg name="fd" type="h" direction="out" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
SelectionOwnerChanged:
|
||||
@options: Options for the clipboard selection
|
||||
|
||||
Available @options include:
|
||||
|
||||
* "mime-types" (as): List of mime types, for which the clipboard of the
|
||||
remote desktop client has content.
|
||||
Each mime-type is in string form, e.g. "image/jpeg",
|
||||
"text/plain", etc..
|
||||
* "session-is-owner" (b): 'true', if the remote desktop clients clipboard
|
||||
is already owner of these types, else 'false'.
|
||||
|
||||
Informs the remote desktop client of new clipboard formats that are
|
||||
available.
|
||||
-->
|
||||
<signal name="SelectionOwnerChanged">
|
||||
<arg name="options" type="a{sv}" direction="in" />
|
||||
</signal>
|
||||
|
||||
<!--
|
||||
SelectionTransfer:
|
||||
@mime_type: The mime-type string of the requested format
|
||||
@serial: The serial, that the answer of this particular request, MUST use
|
||||
|
||||
Requests the data for a clipboard format from the remote desktop client.
|
||||
MUST NOT be called when the remote desktop clients clipboard is (already)
|
||||
disabled.
|
||||
-->
|
||||
<signal name="SelectionTransfer">
|
||||
<arg name="mime_type" type="s" direction="in" />
|
||||
<arg name="serial" type="u" direction="in" />
|
||||
</signal>
|
||||
|
||||
</interface>
|
||||
|
||||
</node>
|
||||
|
Loading…
Reference in New Issue
Block a user