Blame SOURCES/0008-screen-cast-session-Add-support-for-RecordWindow.patch

776610
From c4e07c78940aa873a0258d45da7f417f483b8873 Mon Sep 17 00:00:00 2001
776610
From: Olivier Fourdan <ofourdan@redhat.com>
776610
Date: Fri, 28 Sep 2018 10:48:31 +0200
776610
Subject: [PATCH 08/12] screen-cast-session: Add support for RecordWindow
776610
776610
Add support for the RecordWindow screencast method, casting the
776610
currently focused window.
776610
776610
https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
776610
(cherry picked from commit ec25f3a6b7923627484c6c1c65f8af0bebe56423)
776610
---
776610
 src/backends/meta-screen-cast-session.c | 52 +++++++++++++++++++++++--
776610
 1 file changed, 48 insertions(+), 4 deletions(-)
776610
776610
diff --git a/src/backends/meta-screen-cast-session.c b/src/backends/meta-screen-cast-session.c
776610
index e1b6393..3ee02c5 100644
776610
--- a/src/backends/meta-screen-cast-session.c
776610
+++ b/src/backends/meta-screen-cast-session.c
776610
@@ -26,9 +26,11 @@
776610
 
776610
 #include "backends/meta-backend-private.h"
776610
 #include "backends/meta-dbus-session-watcher.h"
776610
+#include "backends/meta-remote-access-controller-private.h"
776610
 #include "backends/meta-screen-cast-monitor-stream.h"
776610
 #include "backends/meta-screen-cast-stream.h"
776610
-#include "backends/meta-remote-access-controller-private.h"
776610
+#include "backends/meta-screen-cast-window-stream.h"
776610
+#include "core/display-private.h"
776610
 
776610
 #define META_SCREEN_CAST_SESSION_DBUS_PATH "/org/gnome/Mutter/ScreenCast/Session"
776610
 
776610
@@ -333,6 +335,14 @@ handle_record_window (MetaDBusScreenCastSession *skeleton,
776610
                       GVariant                  *properties_variant)
776610
 {
776610
   MetaScreenCastSession *session = META_SCREEN_CAST_SESSION (skeleton);
776610
+  GDBusInterfaceSkeleton *interface_skeleton;
776610
+  GDBusConnection *connection;
776610
+  MetaWindow *window;
776610
+  GError *error = NULL;
776610
+  MetaDisplay *display;
776610
+  MetaScreenCastWindowStream *window_stream;
776610
+  MetaScreenCastStream *stream;
776610
+  char *stream_path;
776610
 
776610
   if (!check_permission (session, invocation))
776610
     {
776610
@@ -342,9 +352,43 @@ handle_record_window (MetaDBusScreenCastSession *skeleton,
776610
       return TRUE;
776610
     }
776610
 
776610
-  g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
776610
-                                         G_DBUS_ERROR_FAILED,
776610
-                                         "Recording a window not yet supported");
776610
+  display = meta_get_display ();
776610
+  window = meta_display_get_focus_window (display);
776610
+  if (!window)
776610
+    {
776610
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
776610
+                                             G_DBUS_ERROR_FAILED,
776610
+                                             "Window not found");
776610
+      return TRUE;
776610
+    }
776610
+
776610
+  interface_skeleton = G_DBUS_INTERFACE_SKELETON (skeleton);
776610
+  connection = g_dbus_interface_skeleton_get_connection (interface_skeleton);
776610
+
776610
+  window_stream = meta_screen_cast_window_stream_new (connection,
776610
+                                                      window,
776610
+                                                      &error);
776610
+  if (!window_stream)
776610
+    {
776610
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
776610
+                                             G_DBUS_ERROR_FAILED,
776610
+                                             "Failed to record window: %s",
776610
+                                             error->message);
776610
+      g_error_free (error);
776610
+      return TRUE;
776610
+    }
776610
+
776610
+  stream = META_SCREEN_CAST_STREAM (window_stream);
776610
+  stream_path = meta_screen_cast_stream_get_object_path (stream);
776610
+
776610
+  session->streams = g_list_append (session->streams, stream);
776610
+
776610
+  g_signal_connect (stream, "closed", G_CALLBACK (on_stream_closed), session);
776610
+
776610
+  meta_dbus_screen_cast_session_complete_record_window (skeleton,
776610
+                                                        invocation,
776610
+                                                        stream_path);
776610
+
776610
   return TRUE;
776610
 }
776610
 
776610
-- 
776610
2.19.2
776610