1
0
Fork 0

remote-desktop/eis: Add support for ConnectToEIS.

Remote desktop version 2 added a new method ConnectToEIS .

ConnectToEIS allows clients to requests a file descriptor from the
compositor which can then be used directly from libei.

Once established, the communication between compositor and application
is direct, without the need to go through the portal process(es).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
This commit is contained in:
Olivier Fourdan 2022-09-28 17:54:02 +02:00 committed by Carlos Garnacho
parent 812eeddfde
commit 6d0b682d98
2 changed files with 52 additions and 0 deletions

View file

@ -348,6 +348,17 @@
<property name="CapsLockState" type="b" access="read" /> <property name="CapsLockState" type="b" access="read" />
<property name="NumLockState" type="b" access="read" /> <property name="NumLockState" type="b" access="read" />
<!--
ConnectToEIS:
Request a connection to an EIS implementation.
-->
<method name="ConnectToEIS">
<arg type="a{sv}" name="options" direction="in"/>
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="h" name="fd" direction="out"/>
</method>
</interface> </interface>
</node> </node>

View file

@ -1630,6 +1630,46 @@ handle_selection_read (MetaDBusRemoteDesktopSession *skeleton,
return TRUE; return TRUE;
} }
static gboolean
handle_connect_to_eis (MetaDBusRemoteDesktopSession *skeleton,
GDBusMethodInvocation *invocation,
GUnixFDList *fd_list_in,
GVariant *arg_options)
{
MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
MetaBackend *backend =
meta_dbus_session_manager_get_backend (session->session_manager);
g_autoptr (GUnixFDList) fd_list = NULL;
int fd_idx;
GVariant *fd_variant;
int fd;
MetaEis *meis;
meis = meta_backend_get_eis (backend);
fd = meta_eis_add_client_get_fd (meis);
if (fd < 0)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_FAILED,
"Failed to create socket: %s",
g_strerror (-fd));
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
fd_list = g_unix_fd_list_new ();
fd_idx = g_unix_fd_list_append (fd_list, fd, NULL);
close (fd);
fd_variant = g_variant_new_handle (fd_idx);
meta_dbus_remote_desktop_session_complete_connect_to_eis (skeleton,
invocation,
fd_list,
fd_variant);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
static gboolean static gboolean
meta_remote_desktop_session_initable_init (GInitable *initable, meta_remote_desktop_session_initable_init (GInitable *initable,
GCancellable *cancellable, GCancellable *cancellable,
@ -1691,6 +1731,7 @@ meta_remote_desktop_session_init_iface (MetaDBusRemoteDesktopSessionIface *iface
iface->handle_selection_write = handle_selection_write; iface->handle_selection_write = handle_selection_write;
iface->handle_selection_write_done = handle_selection_write_done; iface->handle_selection_write_done = handle_selection_write_done;
iface->handle_selection_read = handle_selection_read; iface->handle_selection_read = handle_selection_read;
iface->handle_connect_to_eis = handle_connect_to_eis;
} }
static void static void