1
0
Fork 0

remote-desktop/session: Limit device type access when using libei

The portal could limit access to certain device types, but this was not
forwarded to the EIS context. Add a way to do this, and make use of it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
This commit is contained in:
Jonas Ådahl 2023-08-28 17:21:35 +02:00 committed by Marge Bot
parent 21f3e2a323
commit 2eda81aadf
7 changed files with 83 additions and 17 deletions

View file

@ -352,6 +352,10 @@
ConnectToEIS:
Request a connection to an EIS implementation.
Available @options include:
* "device-types" u: Bitmask of device types to expose (see SupportedDeviceTypes)
-->
<method name="ConnectToEIS">
<arg type="a{sv}" name="options" direction="in"/>

View file

@ -696,11 +696,19 @@ meta_eis_client_new (MetaEis *eis,
* of the seat in the process.
*/
eis_seat = eis_client_new_seat (eis_client, "mutter default seat");
if (meta_eis_get_device_types (eis) & META_EIS_DEVICE_TYPE_KEYBOARD)
{
eis_seat_configure_capability (eis_seat, EIS_DEVICE_CAP_KEYBOARD);
}
if (meta_eis_get_device_types (eis) & META_EIS_DEVICE_TYPE_POINTER)
{
eis_seat_configure_capability (eis_seat, EIS_DEVICE_CAP_POINTER);
eis_seat_configure_capability (eis_seat, EIS_DEVICE_CAP_POINTER_ABSOLUTE);
eis_seat_configure_capability (eis_seat, EIS_DEVICE_CAP_BUTTON);
eis_seat_configure_capability (eis_seat, EIS_DEVICE_CAP_SCROLL);
}
eis_seat_add (eis_seat);
eis_seat_unref (eis_seat);

View file

@ -45,6 +45,8 @@ struct _MetaEis
struct eis *eis;
MetaEventSource *event_source;
MetaEisDeviceTypes device_types;
GHashTable *eis_clients; /* eis_client => MetaEisClient */
};
@ -238,13 +240,15 @@ meta_eis_add_client_get_fd (MetaEis *eis)
}
MetaEis *
meta_eis_new (MetaBackend *backend)
meta_eis_new (MetaBackend *backend,
MetaEisDeviceTypes device_types)
{
MetaEis *eis;
int fd;
eis = g_object_new (META_TYPE_EIS, NULL);
eis->backend = backend;
eis->device_types = device_types;
eis->eis = eis_new (eis);
eis_log_set_handler (eis->eis, eis_logger);
@ -284,3 +288,9 @@ meta_eis_class_init (MetaEisClass *klass)
object_class->finalize = meta_eis_finalize;
}
MetaEisDeviceTypes
meta_eis_get_device_types (MetaEis *eis)
{
return eis->device_types;
}

View file

@ -23,12 +23,22 @@
#include <glib-object.h>
#include "backends/meta-backend-types.h"
#include "backends/meta-viewport-info.h"
typedef enum _MetaEisDeviceTypes
{
META_EIS_DEVICE_TYPE_NONE = 0,
META_EIS_DEVICE_TYPE_KEYBOARD = 1 << 0,
META_EIS_DEVICE_TYPE_POINTER = 1 << 1,
META_EIS_DEVICE_TYPE_TOUCHSCREEN = 1 << 2,
} MetaEisDeviceTypes;
#define META_TYPE_EIS (meta_eis_get_type ())
G_DECLARE_FINAL_TYPE (MetaEis, meta_eis,
META, EIS, GObject)
MetaEis * meta_eis_new (MetaBackend *backend);
MetaEis * meta_eis_new (MetaBackend *backend,
MetaEisDeviceTypes device_types);
MetaBackend * meta_eis_get_backend (MetaEis *eis);
int meta_eis_add_client_get_fd (MetaEis *eis);
MetaEisDeviceTypes meta_eis_get_device_types (MetaEis *eis);

View file

@ -1626,6 +1626,21 @@ handle_selection_read (MetaDBusRemoteDesktopSession *skeleton,
return TRUE;
}
static MetaEisDeviceTypes
device_types_to_eis_device_types (MetaRemoteDesktopDeviceTypes device_types)
{
MetaEisDeviceTypes eis_device_types = META_EIS_DEVICE_TYPE_NONE;
if (device_types & META_REMOTE_DESKTOP_DEVICE_TYPE_KEYBOARD)
eis_device_types |= META_EIS_DEVICE_TYPE_KEYBOARD;
if (device_types & META_REMOTE_DESKTOP_DEVICE_TYPE_POINTER)
eis_device_types |= META_EIS_DEVICE_TYPE_POINTER;
if (device_types & META_REMOTE_DESKTOP_DEVICE_TYPE_TOUCHSCREEN)
eis_device_types |= META_EIS_DEVICE_TYPE_TOUCHSCREEN;
return eis_device_types;
}
static gboolean
handle_connect_to_eis (MetaDBusRemoteDesktopSession *skeleton,
GDBusMethodInvocation *invocation,
@ -1641,7 +1656,26 @@ handle_connect_to_eis (MetaDBusRemoteDesktopSession *skeleton,
int fd;
if (!session->eis)
session->eis = meta_eis_new (backend);
{
uint32_t device_types_bitmask;
MetaRemoteDesktopDeviceTypes device_types;
MetaEisDeviceTypes eis_device_types;
if (g_variant_lookup (arg_options, "device-types", "u",
&device_types_bitmask))
{
device_types = device_types_bitmask;
}
else
{
device_types = (META_REMOTE_DESKTOP_DEVICE_TYPE_KEYBOARD |
META_REMOTE_DESKTOP_DEVICE_TYPE_POINTER |
META_REMOTE_DESKTOP_DEVICE_TYPE_TOUCHSCREEN);
}
eis_device_types = device_types_to_eis_device_types (device_types);
session->eis = meta_eis_new (backend, eis_device_types);
}
fd = meta_eis_add_client_get_fd (session->eis);
if (fd < 0)

View file

@ -40,14 +40,6 @@
#define META_REMOTE_DESKTOP_DBUS_PATH "/org/gnome/Mutter/RemoteDesktop"
#define META_REMOTE_DESKTOP_API_VERSION 1
typedef enum _MetaRemoteDesktopDeviceTypes
{
META_REMOTE_DESKTOP_DEVICE_TYPE_NONE = 0,
META_REMOTE_DESKTOP_DEVICE_TYPE_KEYBOARD = 1 << 0,
META_REMOTE_DESKTOP_DEVICE_TYPE_POINTER = 1 << 1,
META_REMOTE_DESKTOP_DEVICE_TYPE_TOUCHSCREEN = 1 << 2,
} MetaRemoteDesktopDeviceTypes;
struct _MetaRemoteDesktop
{
MetaDbusSessionManager parent;

View file

@ -28,6 +28,14 @@
#include "meta-dbus-remote-desktop.h"
typedef enum _MetaRemoteDesktopDeviceTypes
{
META_REMOTE_DESKTOP_DEVICE_TYPE_NONE = 0,
META_REMOTE_DESKTOP_DEVICE_TYPE_KEYBOARD = 1 << 0,
META_REMOTE_DESKTOP_DEVICE_TYPE_POINTER = 1 << 1,
META_REMOTE_DESKTOP_DEVICE_TYPE_TOUCHSCREEN = 1 << 2,
} MetaRemoteDesktopDeviceTypes;
typedef struct _MetaRemoteDesktopSession MetaRemoteDesktopSession;
#define META_TYPE_REMOTE_DESKTOP (meta_remote_desktop_get_type ())