From ac1a5366b11e69199e9810b765a2a3551e00e4c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 13 Oct 2020 17:38:42 +0200 Subject: [PATCH] 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: --- src/backends/meta-remote-desktop-session.c | 166 +++++++++++++++++++++ src/org.gnome.Mutter.RemoteDesktop.xml | 135 +++++++++++++++++ 2 files changed, 301 insertions(+) diff --git a/src/backends/meta-remote-desktop-session.c b/src/backends/meta-remote-desktop-session.c index d01b5e6a8..e7cedb40d 100644 --- a/src/backends/meta-remote-desktop-session.c +++ b/src/backends/meta-remote-desktop-session.c @@ -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 diff --git a/src/org.gnome.Mutter.RemoteDesktop.xml b/src/org.gnome.Mutter.RemoteDesktop.xml index d93413f6d..0b79f70a6 100644 --- a/src/org.gnome.Mutter.RemoteDesktop.xml +++ b/src/org.gnome.Mutter.RemoteDesktop.xml @@ -195,6 +195,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +