screen-cast: Add screen cast flag to streams

Intended to be used to pass state from screen cast clients down the
line. The first use case will be a boolean whether a screen cast is a
plain recording or not, e.g. letting the Shell decide whether to use a
red dot as the icon, or the generic "sharing" symbol.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1377
This commit is contained in:
Jonas Ådahl 2020-04-21 16:54:54 +02:00
parent 109fbdbac9
commit 14cd78a016
15 changed files with 137 additions and 0 deletions

View File

@ -87,6 +87,7 @@ meta_screen_cast_area_stream_new (MetaScreenCastSession *session,
MetaRectangle *area,
ClutterStage *stage,
MetaScreenCastCursorMode cursor_mode,
MetaScreenCastFlag flags,
GError **error)
{
MetaScreenCastAreaStream *area_stream;
@ -105,6 +106,7 @@ meta_screen_cast_area_stream_new (MetaScreenCastSession *session,
"session", session,
"connection", connection,
"cursor-mode", cursor_mode,
"flags", flags,
NULL);
if (!area_stream)
return NULL;

View File

@ -37,6 +37,7 @@ MetaScreenCastAreaStream * meta_screen_cast_area_stream_new (MetaScreenCastSessi
MetaRectangle *area,
ClutterStage *stage,
MetaScreenCastCursorMode cursor_mode,
MetaScreenCastFlag flags,
GError **error);
ClutterStage * meta_screen_cast_area_stream_get_stage (MetaScreenCastAreaStream *area_stream);

View File

@ -110,6 +110,7 @@ meta_screen_cast_monitor_stream_new (MetaScreenCastSession *session,
MetaMonitor *monitor,
ClutterStage *stage,
MetaScreenCastCursorMode cursor_mode,
MetaScreenCastFlag flags,
GError **error)
{
MetaGpu *gpu = meta_monitor_get_gpu (monitor);
@ -130,6 +131,7 @@ meta_screen_cast_monitor_stream_new (MetaScreenCastSession *session,
"session", session,
"connection", connection,
"cursor-mode", cursor_mode,
"flags", flags,
"monitor", monitor,
NULL);
if (!monitor_stream)

View File

@ -40,6 +40,7 @@ MetaScreenCastMonitorStream * meta_screen_cast_monitor_stream_new (MetaScreenCas
MetaMonitor *monitor,
ClutterStage *stage,
MetaScreenCastCursorMode cursor_mode,
MetaScreenCastFlag flags,
GError **error);
ClutterStage * meta_screen_cast_monitor_stream_get_stage (MetaScreenCastMonitorStream *monitor_stream);

View File

@ -310,6 +310,7 @@ handle_record_monitor (MetaDBusScreenCastSession *skeleton,
meta_backend_get_monitor_manager (backend);
MetaMonitor *monitor;
MetaScreenCastCursorMode cursor_mode;
MetaScreenCastFlag flags;
ClutterStage *stage;
GError *error = NULL;
MetaScreenCastMonitorStream *monitor_stream;
@ -358,11 +359,14 @@ handle_record_monitor (MetaDBusScreenCastSession *skeleton,
stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
flags = META_SCREEN_CAST_FLAG_NONE;
monitor_stream = meta_screen_cast_monitor_stream_new (session,
connection,
monitor,
stage,
cursor_mode,
flags,
&error);
if (!monitor_stream)
{
@ -398,6 +402,7 @@ handle_record_window (MetaDBusScreenCastSession *skeleton,
GDBusConnection *connection;
MetaWindow *window;
MetaScreenCastCursorMode cursor_mode;
MetaScreenCastFlag flags;
GError *error = NULL;
MetaDisplay *display;
GVariant *window_id_variant = NULL;
@ -457,10 +462,13 @@ handle_record_window (MetaDBusScreenCastSession *skeleton,
interface_skeleton = G_DBUS_INTERFACE_SKELETON (skeleton);
connection = g_dbus_interface_skeleton_get_connection (interface_skeleton);
flags = META_SCREEN_CAST_FLAG_NONE;
window_stream = meta_screen_cast_window_stream_new (session,
connection,
window,
cursor_mode,
flags,
&error);
if (!window_stream)
{
@ -501,6 +509,7 @@ handle_record_area (MetaDBusScreenCastSession *skeleton,
MetaBackend *backend;
ClutterStage *stage;
MetaScreenCastCursorMode cursor_mode;
MetaScreenCastFlag flags;
g_autoptr (GError) error = NULL;
MetaRectangle rect;
MetaScreenCastAreaStream *area_stream;
@ -535,6 +544,8 @@ handle_record_area (MetaDBusScreenCastSession *skeleton,
backend = meta_screen_cast_get_backend (session->screen_cast);
stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
flags = META_SCREEN_CAST_FLAG_NONE;
rect = (MetaRectangle) {
.x = x,
.y = y,
@ -546,6 +557,7 @@ handle_record_area (MetaDBusScreenCastSession *skeleton,
&rect,
stage,
cursor_mode,
flags,
&error);
if (!area_stream)
{

View File

@ -26,6 +26,8 @@
#include "backends/meta-screen-cast-session.h"
#include "meta-private-enum-types.h"
#define META_SCREEN_CAST_STREAM_DBUS_IFACE "org.gnome.Mutter.ScreenCast.Stream"
#define META_SCREEN_CAST_STREAM_DBUS_PATH "/org/gnome/Mutter/ScreenCast/Stream"
@ -36,6 +38,7 @@ enum
PROP_SESSION,
PROP_CONNECTION,
PROP_CURSOR_MODE,
PROP_FLAGS,
};
enum
@ -55,6 +58,7 @@ typedef struct _MetaScreenCastStreamPrivate
char *object_path;
MetaScreenCastCursorMode cursor_mode;
MetaScreenCastFlag flags;
MetaScreenCastStreamSrc *src;
} MetaScreenCastStreamPrivate;
@ -187,6 +191,15 @@ meta_screen_cast_stream_get_cursor_mode (MetaScreenCastStream *stream)
return priv->cursor_mode;
}
MetaScreenCastFlag
meta_screen_cast_stream_get_flags (MetaScreenCastStream *stream)
{
MetaScreenCastStreamPrivate *priv =
meta_screen_cast_stream_get_instance_private (stream);
return priv->flags;
}
static void
meta_screen_cast_stream_set_property (GObject *object,
guint prop_id,
@ -208,6 +221,9 @@ meta_screen_cast_stream_set_property (GObject *object,
case PROP_CURSOR_MODE:
priv->cursor_mode = g_value_get_uint (value);
break;
case PROP_FLAGS:
priv->flags = g_value_get_flags (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@ -234,6 +250,9 @@ meta_screen_cast_stream_get_property (GObject *object,
case PROP_CURSOR_MODE:
g_value_set_uint (value, priv->cursor_mode);
break;
case PROP_FLAGS:
g_value_set_flags (value, priv->flags);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@ -337,6 +356,17 @@ meta_screen_cast_stream_class_init (MetaScreenCastStreamClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_FLAGS,
g_param_spec_flags ("flags",
"flags",
"Screen cast flags",
META_TYPE_SCREEN_CAST_FLAG,
META_SCREEN_CAST_FLAG_NONE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
signals[CLOSED] = g_signal_new ("closed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,

View File

@ -67,4 +67,6 @@ void meta_screen_cast_stream_transform_position (MetaScreenCastStream *stream,
MetaScreenCastCursorMode meta_screen_cast_stream_get_cursor_mode (MetaScreenCastStream *stream);
MetaScreenCastFlag meta_screen_cast_stream_get_flags (MetaScreenCastStream *stream);
#endif /* META_SCREEN_CAST_STREAM_H */

View File

@ -84,6 +84,7 @@ meta_screen_cast_window_stream_new (MetaScreenCastSession *session,
GDBusConnection *connection,
MetaWindow *window,
MetaScreenCastCursorMode cursor_mode,
MetaScreenCastFlag flags,
GError **error)
{
return g_initable_new (META_TYPE_SCREEN_CAST_WINDOW_STREAM,
@ -92,6 +93,7 @@ meta_screen_cast_window_stream_new (MetaScreenCastSession *session,
"session", session,
"connection", connection,
"cursor-mode", cursor_mode,
"flags", flags,
"window", window,
NULL);
}

View File

@ -36,6 +36,7 @@ MetaScreenCastWindowStream * meta_screen_cast_window_stream_new (MetaScreenCastS
GDBusConnection *connection,
MetaWindow *window,
MetaScreenCastCursorMode cursor_mode,
MetaScreenCastFlag flags,
GError **error);
MetaWindow * meta_screen_cast_window_stream_get_window (MetaScreenCastWindowStream *window_stream);

View File

@ -37,6 +37,11 @@ typedef enum _MetaScreenCastCursorMode
META_SCREEN_CAST_CURSOR_MODE_METADATA = 2,
} MetaScreenCastCursorMode;
typedef enum _MetaScreenCastFlag
{
META_SCREEN_CAST_FLAG_NONE = 0,
} MetaScreenCastFlag;
#define META_TYPE_SCREEN_CAST (meta_screen_cast_get_type ())
G_DECLARE_FINAL_TYPE (MetaScreenCast, meta_screen_cast,
META, SCREEN_CAST,

View File

@ -719,6 +719,18 @@ endif
mutter_built_sources = []
if have_remote_desktop
mutter_private_enum_types = gnome.mkenums('meta-private-enum-types',
sources: [
'backends/meta-screen-cast.h',
],
c_template: 'meta-private-enum-types.c.in',
h_template: 'meta-private-enum-types.h.in',
)
mutter_built_sources += mutter_private_enum_types
endif
dbus_display_config_built_sources = gnome.gdbus_codegen('meta-dbus-display-config',
'org.gnome.Mutter.DisplayConfig.xml',
interface_prefix: 'org.gnome.Mutter.',

View File

@ -0,0 +1,40 @@
/*** BEGIN file-header ***/
#include "meta-private-enum-types.h"
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
#include "@filename@"
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
@enum_name@_get_type (void)
{
static volatile gsize g_enum_type_id__volatile = 0;
if (g_once_init_enter (&g_enum_type_id__volatile))
{
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType g_enum_type_id;
g_enum_type_id =
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_once_init_leave (&g_enum_type_id__volatile, g_enum_type_id);
}
return g_enum_type_id__volatile;
}
/*** END value-tail ***/

View File

@ -0,0 +1,25 @@
/*** BEGIN file-header ***/
#ifndef META_PRIVATE_ENUM_TYPES_H
#define META_PRIVATE_ENUM_TYPES_H
#include <glib-object.h>
G_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@basename@" */
/*** END file-production ***/
/*** BEGIN file-tail ***/
G_END_DECLS
#endif /* !__MUTTER_ENUM_TYPES_H__ */
/*** END file-tail ***/
/*** BEGIN value-header ***/
GType @enum_name@_get_type (void) G_GNUC_CONST;
#define META_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
/*** END value-header ***/

View File

@ -1,6 +1,7 @@
clutter_tests_conform_c_args = [
'-DG_LOG_DOMAIN="Clutter-Conform"',
'-DCOGL_DISABLE_DEPRECATION_WARNINGS',
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
]
clutter_tests_conform_c_args += clutter_debug_c_args

View File

@ -7,6 +7,7 @@ clutter_tests_interactive_c_args = [
'-DGLIB_DISABLE_DEPRECATION_WARNINGS',
'-DCOGL_DISABLE_DEPRECATION_WARNINGS',
'-DCLUTTER_DISABLE_DEPRECATION_WARNINGS',
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
]
clutter_tests_interactive_c_args += clutter_debug_c_args