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

View File

@ -37,6 +37,7 @@ MetaScreenCastAreaStream * meta_screen_cast_area_stream_new (MetaScreenCastSessi
MetaRectangle *area, MetaRectangle *area,
ClutterStage *stage, ClutterStage *stage,
MetaScreenCastCursorMode cursor_mode, MetaScreenCastCursorMode cursor_mode,
MetaScreenCastFlag flags,
GError **error); GError **error);
ClutterStage * meta_screen_cast_area_stream_get_stage (MetaScreenCastAreaStream *area_stream); 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, MetaMonitor *monitor,
ClutterStage *stage, ClutterStage *stage,
MetaScreenCastCursorMode cursor_mode, MetaScreenCastCursorMode cursor_mode,
MetaScreenCastFlag flags,
GError **error) GError **error)
{ {
MetaGpu *gpu = meta_monitor_get_gpu (monitor); MetaGpu *gpu = meta_monitor_get_gpu (monitor);
@ -130,6 +131,7 @@ meta_screen_cast_monitor_stream_new (MetaScreenCastSession *session,
"session", session, "session", session,
"connection", connection, "connection", connection,
"cursor-mode", cursor_mode, "cursor-mode", cursor_mode,
"flags", flags,
"monitor", monitor, "monitor", monitor,
NULL); NULL);
if (!monitor_stream) if (!monitor_stream)

View File

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

View File

@ -26,6 +26,8 @@
#include "backends/meta-screen-cast-session.h" #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_IFACE "org.gnome.Mutter.ScreenCast.Stream"
#define META_SCREEN_CAST_STREAM_DBUS_PATH "/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_SESSION,
PROP_CONNECTION, PROP_CONNECTION,
PROP_CURSOR_MODE, PROP_CURSOR_MODE,
PROP_FLAGS,
}; };
enum enum
@ -55,6 +58,7 @@ typedef struct _MetaScreenCastStreamPrivate
char *object_path; char *object_path;
MetaScreenCastCursorMode cursor_mode; MetaScreenCastCursorMode cursor_mode;
MetaScreenCastFlag flags;
MetaScreenCastStreamSrc *src; MetaScreenCastStreamSrc *src;
} MetaScreenCastStreamPrivate; } MetaScreenCastStreamPrivate;
@ -187,6 +191,15 @@ meta_screen_cast_stream_get_cursor_mode (MetaScreenCastStream *stream)
return priv->cursor_mode; 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 static void
meta_screen_cast_stream_set_property (GObject *object, meta_screen_cast_stream_set_property (GObject *object,
guint prop_id, guint prop_id,
@ -208,6 +221,9 @@ meta_screen_cast_stream_set_property (GObject *object,
case PROP_CURSOR_MODE: case PROP_CURSOR_MODE:
priv->cursor_mode = g_value_get_uint (value); priv->cursor_mode = g_value_get_uint (value);
break; break;
case PROP_FLAGS:
priv->flags = g_value_get_flags (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 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: case PROP_CURSOR_MODE:
g_value_set_uint (value, priv->cursor_mode); g_value_set_uint (value, priv->cursor_mode);
break; break;
case PROP_FLAGS:
g_value_set_flags (value, priv->flags);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 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_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)); 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", signals[CLOSED] = g_signal_new ("closed",
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 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); 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 */ #endif /* META_SCREEN_CAST_STREAM_H */

View File

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

View File

@ -36,6 +36,7 @@ MetaScreenCastWindowStream * meta_screen_cast_window_stream_new (MetaScreenCastS
GDBusConnection *connection, GDBusConnection *connection,
MetaWindow *window, MetaWindow *window,
MetaScreenCastCursorMode cursor_mode, MetaScreenCastCursorMode cursor_mode,
MetaScreenCastFlag flags,
GError **error); GError **error);
MetaWindow * meta_screen_cast_window_stream_get_window (MetaScreenCastWindowStream *window_stream); 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, META_SCREEN_CAST_CURSOR_MODE_METADATA = 2,
} MetaScreenCastCursorMode; } MetaScreenCastCursorMode;
typedef enum _MetaScreenCastFlag
{
META_SCREEN_CAST_FLAG_NONE = 0,
} MetaScreenCastFlag;
#define META_TYPE_SCREEN_CAST (meta_screen_cast_get_type ()) #define META_TYPE_SCREEN_CAST (meta_screen_cast_get_type ())
G_DECLARE_FINAL_TYPE (MetaScreenCast, meta_screen_cast, G_DECLARE_FINAL_TYPE (MetaScreenCast, meta_screen_cast,
META, SCREEN_CAST, META, SCREEN_CAST,

View File

@ -719,6 +719,18 @@ endif
mutter_built_sources = [] 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', dbus_display_config_built_sources = gnome.gdbus_codegen('meta-dbus-display-config',
'org.gnome.Mutter.DisplayConfig.xml', 'org.gnome.Mutter.DisplayConfig.xml',
interface_prefix: 'org.gnome.Mutter.', 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 = [ clutter_tests_conform_c_args = [
'-DG_LOG_DOMAIN="Clutter-Conform"', '-DG_LOG_DOMAIN="Clutter-Conform"',
'-DCOGL_DISABLE_DEPRECATION_WARNINGS', '-DCOGL_DISABLE_DEPRECATION_WARNINGS',
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
] ]
clutter_tests_conform_c_args += clutter_debug_c_args clutter_tests_conform_c_args += clutter_debug_c_args

View File

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