remote-access-handle: Add 'is-recording' property

Will be TRUE if it is a screen cast session where all streams have the
'is-recording' set to TRUE. For other screen casts or remote desktop
sessions, it'll be FALSE.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1377
This commit is contained in:
Jonas Ådahl 2020-04-21 17:25:23 +02:00
parent 153357cd36
commit 34579d71cc
2 changed files with 96 additions and 1 deletions

View File

@ -36,6 +36,17 @@ enum
static int handle_signals[N_HANDLE_SIGNALS];
enum
{
PROP_0,
PROP_IS_RECORDING,
N_PROPS
};
static GParamSpec *obj_props[N_PROPS];
enum
{
CONTROLLER_NEW_HANDLE,
@ -50,6 +61,8 @@ typedef struct _MetaRemoteAccessHandlePrivate
gboolean has_stopped;
gboolean disable_animations;
gboolean is_recording;
} MetaRemoteAccessHandlePrivate;
G_DEFINE_TYPE_WITH_PRIVATE (MetaRemoteAccessHandle,
@ -177,6 +190,48 @@ meta_remote_access_controller_new (MetaRemoteDesktop *remote_desktop,
return remote_access_controller;
}
static void
meta_remote_access_handle_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MetaRemoteAccessHandle *handle = META_REMOTE_ACCESS_HANDLE (object);
MetaRemoteAccessHandlePrivate *priv =
meta_remote_access_handle_get_instance_private (handle);
switch (prop_id)
{
case PROP_IS_RECORDING:
g_value_set_boolean (value, priv->is_recording);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_remote_access_handle_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MetaRemoteAccessHandle *handle = META_REMOTE_ACCESS_HANDLE (object);
MetaRemoteAccessHandlePrivate *priv =
meta_remote_access_handle_get_instance_private (handle);
switch (prop_id)
{
case PROP_IS_RECORDING:
priv->is_recording = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_remote_access_handle_init (MetaRemoteAccessHandle *handle)
{
@ -185,6 +240,11 @@ meta_remote_access_handle_init (MetaRemoteAccessHandle *handle)
static void
meta_remote_access_handle_class_init (MetaRemoteAccessHandleClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = meta_remote_access_handle_get_property;
object_class->set_property = meta_remote_access_handle_set_property;
handle_signals[HANDLE_STOPPED] =
g_signal_new ("stopped",
G_TYPE_FROM_CLASS (klass),
@ -192,6 +252,16 @@ meta_remote_access_handle_class_init (MetaRemoteAccessHandleClass *klass)
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
obj_props[PROP_IS_RECORDING] =
g_param_spec_boolean ("is-recording",
"is-recording",
"Is a screen recording",
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, obj_props);
}
static void

View File

@ -677,12 +677,37 @@ meta_screen_cast_session_class_init (MetaScreenCastSessionClass *klass)
object_class->finalize = meta_screen_cast_session_finalize;
}
static gboolean
meta_screen_cast_session_is_recording (MetaScreenCastSession *session)
{
GList *l;
if (!session->streams)
return FALSE;
for (l = session->streams; l; l = l->next)
{
MetaScreenCastStream *stream = l->data;
MetaScreenCastFlag flags;
flags = meta_screen_cast_stream_get_flags (stream);
if (!(flags & META_SCREEN_CAST_FLAG_IS_RECORDING))
return FALSE;
}
return TRUE;
}
static MetaScreenCastSessionHandle *
meta_screen_cast_session_handle_new (MetaScreenCastSession *session)
{
MetaScreenCastSessionHandle *handle;
gboolean is_recording;
handle = g_object_new (META_TYPE_SCREEN_CAST_SESSION_HANDLE, NULL);
is_recording = meta_screen_cast_session_is_recording (session);
handle = g_object_new (META_TYPE_SCREEN_CAST_SESSION_HANDLE,
"is-recording", is_recording,
NULL);
handle->session = session;
return handle;