screen-cast: Add 'is-recording' option to record methods

This can be used by the Shell to change the UI to be the same as the
current built in screen recording.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1377
This commit is contained in:
Jonas Ådahl 2020-04-21 16:56:39 +02:00
parent 14cd78a016
commit 153357cd36
4 changed files with 29 additions and 1 deletions

View File

@ -310,6 +310,7 @@ handle_record_monitor (MetaDBusScreenCastSession *skeleton,
meta_backend_get_monitor_manager (backend);
MetaMonitor *monitor;
MetaScreenCastCursorMode cursor_mode;
gboolean is_recording;
MetaScreenCastFlag flags;
ClutterStage *stage;
GError *error = NULL;
@ -357,9 +358,14 @@ handle_record_monitor (MetaDBusScreenCastSession *skeleton,
}
}
if (!g_variant_lookup (properties_variant, "is-recording", "b", &is_recording))
is_recording = FALSE;
stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
flags = META_SCREEN_CAST_FLAG_NONE;
if (is_recording)
flags |= META_SCREEN_CAST_FLAG_IS_RECORDING;
monitor_stream = meta_screen_cast_monitor_stream_new (session,
connection,
@ -402,6 +408,7 @@ handle_record_window (MetaDBusScreenCastSession *skeleton,
GDBusConnection *connection;
MetaWindow *window;
MetaScreenCastCursorMode cursor_mode;
gboolean is_recording;
MetaScreenCastFlag flags;
GError *error = NULL;
MetaDisplay *display;
@ -459,10 +466,15 @@ handle_record_window (MetaDBusScreenCastSession *skeleton,
}
}
if (!g_variant_lookup (properties_variant, "is-recording", "b", &is_recording))
is_recording = FALSE;
interface_skeleton = G_DBUS_INTERFACE_SKELETON (skeleton);
connection = g_dbus_interface_skeleton_get_connection (interface_skeleton);
flags = META_SCREEN_CAST_FLAG_NONE;
if (is_recording)
flags |= META_SCREEN_CAST_FLAG_IS_RECORDING;
window_stream = meta_screen_cast_window_stream_new (session,
connection,
@ -509,6 +521,7 @@ handle_record_area (MetaDBusScreenCastSession *skeleton,
MetaBackend *backend;
ClutterStage *stage;
MetaScreenCastCursorMode cursor_mode;
gboolean is_recording;
MetaScreenCastFlag flags;
g_autoptr (GError) error = NULL;
MetaRectangle rect;
@ -539,12 +552,17 @@ handle_record_area (MetaDBusScreenCastSession *skeleton,
}
}
if (!g_variant_lookup (properties_variant, "is-recording", "b", &is_recording))
is_recording = FALSE;
interface_skeleton = G_DBUS_INTERFACE_SKELETON (skeleton);
connection = g_dbus_interface_skeleton_get_connection (interface_skeleton);
backend = meta_screen_cast_get_backend (session->screen_cast);
stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
flags = META_SCREEN_CAST_FLAG_NONE;
if (is_recording)
flags |= META_SCREEN_CAST_FLAG_IS_RECORDING;
rect = (MetaRectangle) {
.x = x,

View File

@ -32,7 +32,7 @@
#define META_SCREEN_CAST_DBUS_SERVICE "org.gnome.Mutter.ScreenCast"
#define META_SCREEN_CAST_DBUS_PATH "/org/gnome/Mutter/ScreenCast"
#define META_SCREEN_CAST_API_VERSION 3
#define META_SCREEN_CAST_API_VERSION 4
struct _MetaScreenCast
{

View File

@ -40,6 +40,7 @@ typedef enum _MetaScreenCastCursorMode
typedef enum _MetaScreenCastFlag
{
META_SCREEN_CAST_FLAG_NONE = 0,
META_SCREEN_CAST_FLAG_IS_RECORDING = 1 << 0,
} MetaScreenCastFlag;
#define META_TYPE_SCREEN_CAST (meta_screen_cast_get_type ())

View File

@ -79,6 +79,9 @@
* "cursor-mode" (u): Cursor mode. Default: 'hidden' (see below)
Available since API version 2.
* "is-recording" (b): Whether this is a screen recording. May be
be used for choosing appropriate visual feedback.
Default: false. Available since API version 4.
Available cursor mode values:
@ -105,6 +108,9 @@
* "window-id" (t): Id of the window to record.
* "cursor-mode" (u): Cursor mode. Default: 'hidden' (see RecordMonitor).
* "is-recording" (b): Whether this is a screen recording. May be
be used for choosing panel icon.
Default: false. Available since API version 4.
-->
<method name="RecordWindow">
@ -129,6 +135,9 @@
* "cursor-mode" (u): Cursor mode. Default: 'hidden' (see below)
Available since API version 2.
* "is-recording" (b): Whether this is a screen recording. May be
be used for choosing panel icon.
Default: false. Available since API version 4.
Available cursor mode values: