mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
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:
parent
21f3e2a323
commit
2eda81aadf
@ -352,6 +352,10 @@
|
|||||||
ConnectToEIS:
|
ConnectToEIS:
|
||||||
|
|
||||||
Request a connection to an EIS implementation.
|
Request a connection to an EIS implementation.
|
||||||
|
|
||||||
|
Available @options include:
|
||||||
|
|
||||||
|
* "device-types" u: Bitmask of device types to expose (see SupportedDeviceTypes)
|
||||||
-->
|
-->
|
||||||
<method name="ConnectToEIS">
|
<method name="ConnectToEIS">
|
||||||
<arg type="a{sv}" name="options" direction="in"/>
|
<arg type="a{sv}" name="options" direction="in"/>
|
||||||
|
@ -696,11 +696,19 @@ meta_eis_client_new (MetaEis *eis,
|
|||||||
* of the seat in the process.
|
* of the seat in the process.
|
||||||
*/
|
*/
|
||||||
eis_seat = eis_client_new_seat (eis_client, "mutter default seat");
|
eis_seat = eis_client_new_seat (eis_client, "mutter default seat");
|
||||||
eis_seat_configure_capability (eis_seat, EIS_DEVICE_CAP_KEYBOARD);
|
|
||||||
eis_seat_configure_capability (eis_seat, EIS_DEVICE_CAP_POINTER);
|
if (meta_eis_get_device_types (eis) & META_EIS_DEVICE_TYPE_KEYBOARD)
|
||||||
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_KEYBOARD);
|
||||||
eis_seat_configure_capability (eis_seat, EIS_DEVICE_CAP_SCROLL);
|
}
|
||||||
|
|
||||||
|
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_add (eis_seat);
|
||||||
eis_seat_unref (eis_seat);
|
eis_seat_unref (eis_seat);
|
||||||
|
@ -45,6 +45,8 @@ struct _MetaEis
|
|||||||
struct eis *eis;
|
struct eis *eis;
|
||||||
MetaEventSource *event_source;
|
MetaEventSource *event_source;
|
||||||
|
|
||||||
|
MetaEisDeviceTypes device_types;
|
||||||
|
|
||||||
GHashTable *eis_clients; /* eis_client => MetaEisClient */
|
GHashTable *eis_clients; /* eis_client => MetaEisClient */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -238,13 +240,15 @@ meta_eis_add_client_get_fd (MetaEis *eis)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MetaEis *
|
MetaEis *
|
||||||
meta_eis_new (MetaBackend *backend)
|
meta_eis_new (MetaBackend *backend,
|
||||||
|
MetaEisDeviceTypes device_types)
|
||||||
{
|
{
|
||||||
MetaEis *eis;
|
MetaEis *eis;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
eis = g_object_new (META_TYPE_EIS, NULL);
|
eis = g_object_new (META_TYPE_EIS, NULL);
|
||||||
eis->backend = backend;
|
eis->backend = backend;
|
||||||
|
eis->device_types = device_types;
|
||||||
|
|
||||||
eis->eis = eis_new (eis);
|
eis->eis = eis_new (eis);
|
||||||
eis_log_set_handler (eis->eis, eis_logger);
|
eis_log_set_handler (eis->eis, eis_logger);
|
||||||
@ -284,3 +288,9 @@ meta_eis_class_init (MetaEisClass *klass)
|
|||||||
|
|
||||||
object_class->finalize = meta_eis_finalize;
|
object_class->finalize = meta_eis_finalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaEisDeviceTypes
|
||||||
|
meta_eis_get_device_types (MetaEis *eis)
|
||||||
|
{
|
||||||
|
return eis->device_types;
|
||||||
|
}
|
||||||
|
@ -23,12 +23,22 @@
|
|||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
#include "backends/meta-backend-types.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 ())
|
#define META_TYPE_EIS (meta_eis_get_type ())
|
||||||
G_DECLARE_FINAL_TYPE (MetaEis, meta_eis,
|
G_DECLARE_FINAL_TYPE (MetaEis, meta_eis,
|
||||||
META, EIS, GObject)
|
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);
|
MetaBackend * meta_eis_get_backend (MetaEis *eis);
|
||||||
int meta_eis_add_client_get_fd (MetaEis *eis);
|
int meta_eis_add_client_get_fd (MetaEis *eis);
|
||||||
|
|
||||||
|
MetaEisDeviceTypes meta_eis_get_device_types (MetaEis *eis);
|
||||||
|
@ -1626,6 +1626,21 @@ handle_selection_read (MetaDBusRemoteDesktopSession *skeleton,
|
|||||||
return TRUE;
|
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
|
static gboolean
|
||||||
handle_connect_to_eis (MetaDBusRemoteDesktopSession *skeleton,
|
handle_connect_to_eis (MetaDBusRemoteDesktopSession *skeleton,
|
||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation,
|
||||||
@ -1641,7 +1656,26 @@ handle_connect_to_eis (MetaDBusRemoteDesktopSession *skeleton,
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (!session->eis)
|
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);
|
fd = meta_eis_add_client_get_fd (session->eis);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
@ -40,14 +40,6 @@
|
|||||||
#define META_REMOTE_DESKTOP_DBUS_PATH "/org/gnome/Mutter/RemoteDesktop"
|
#define META_REMOTE_DESKTOP_DBUS_PATH "/org/gnome/Mutter/RemoteDesktop"
|
||||||
#define META_REMOTE_DESKTOP_API_VERSION 1
|
#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
|
struct _MetaRemoteDesktop
|
||||||
{
|
{
|
||||||
MetaDbusSessionManager parent;
|
MetaDbusSessionManager parent;
|
||||||
|
@ -28,6 +28,14 @@
|
|||||||
|
|
||||||
#include "meta-dbus-remote-desktop.h"
|
#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;
|
typedef struct _MetaRemoteDesktopSession MetaRemoteDesktopSession;
|
||||||
|
|
||||||
#define META_TYPE_REMOTE_DESKTOP (meta_remote_desktop_get_type ())
|
#define META_TYPE_REMOTE_DESKTOP (meta_remote_desktop_get_type ())
|
||||||
|
Loading…
Reference in New Issue
Block a user