|
|
776610 |
From fab59c0866bd13b944f0e9a3a251ba1a70ca31d4 Mon Sep 17 00:00:00 2001
|
|
|
776610 |
From: Olivier Fourdan <ofourdan@redhat.com>
|
|
|
776610 |
Date: Tue, 9 Oct 2018 15:35:14 +0200
|
|
|
776610 |
Subject: [PATCH 07/12] screen-cast-session: Add screen-cast window mode
|
|
|
776610 |
|
|
|
776610 |
Window mode will cast the content of a single window using the
|
|
|
776610 |
`MetaScreenCastWindow` interface.
|
|
|
776610 |
|
|
|
776610 |
https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
|
|
|
776610 |
(cherry picked from commit dbe7279c7fe6fb793292cd6740c900e6f0c21975)
|
|
|
776610 |
---
|
|
|
776610 |
src/Makefile.am | 4 +
|
|
|
776610 |
.../meta-screen-cast-window-stream-src.c | 245 ++++++++++++++++
|
|
|
776610 |
.../meta-screen-cast-window-stream-src.h | 37 +++
|
|
|
776610 |
src/backends/meta-screen-cast-window-stream.c | 270 ++++++++++++++++++
|
|
|
776610 |
src/backends/meta-screen-cast-window-stream.h | 43 +++
|
|
|
776610 |
5 files changed, 599 insertions(+)
|
|
|
776610 |
create mode 100644 src/backends/meta-screen-cast-window-stream-src.c
|
|
|
776610 |
create mode 100644 src/backends/meta-screen-cast-window-stream-src.h
|
|
|
776610 |
create mode 100644 src/backends/meta-screen-cast-window-stream.c
|
|
|
776610 |
create mode 100644 src/backends/meta-screen-cast-window-stream.h
|
|
|
776610 |
|
|
|
776610 |
diff --git a/src/Makefile.am b/src/Makefile.am
|
|
|
776610 |
index 93586a2..0606efa 100644
|
|
|
776610 |
--- a/src/Makefile.am
|
|
|
776610 |
+++ b/src/Makefile.am
|
|
|
776610 |
@@ -372,6 +372,10 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES += \
|
|
|
776610 |
backends/meta-screen-cast-monitor-stream.h \
|
|
|
776610 |
backends/meta-screen-cast-monitor-stream-src.c \
|
|
|
776610 |
backends/meta-screen-cast-monitor-stream-src.h \
|
|
|
776610 |
+ backends/meta-screen-cast-window-stream-src.c \
|
|
|
776610 |
+ backends/meta-screen-cast-window-stream-src.h \
|
|
|
776610 |
+ backends/meta-screen-cast-window-stream.c \
|
|
|
776610 |
+ backends/meta-screen-cast-window-stream.h \
|
|
|
776610 |
backends/meta-screen-cast-session.c \
|
|
|
776610 |
backends/meta-screen-cast-session.h \
|
|
|
776610 |
backends/meta-screen-cast-stream.c \
|
|
|
776610 |
diff --git a/src/backends/meta-screen-cast-window-stream-src.c b/src/backends/meta-screen-cast-window-stream-src.c
|
|
|
776610 |
new file mode 100644
|
|
|
776610 |
index 0000000..c3f9cf5
|
|
|
776610 |
--- /dev/null
|
|
|
776610 |
+++ b/src/backends/meta-screen-cast-window-stream-src.c
|
|
|
776610 |
@@ -0,0 +1,245 @@
|
|
|
776610 |
+/*
|
|
|
776610 |
+ * Copyright (C) 2018 Red Hat Inc.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * This program is free software; you can redistribute it and/or
|
|
|
776610 |
+ * modify it under the terms of the GNU General Public License as
|
|
|
776610 |
+ * published by the Free Software Foundation; either version 2 of the
|
|
|
776610 |
+ * License, or (at your option) any later version.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * This program is distributed in the hope that it will be useful, but
|
|
|
776610 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
776610 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
776610 |
+ * General Public License for more details.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * You should have received a copy of the GNU General Public License
|
|
|
776610 |
+ * along with this program; if not, write to the Free Software
|
|
|
776610 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
776610 |
+ * 02111-1307, USA.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ */
|
|
|
776610 |
+
|
|
|
776610 |
+#include "config.h"
|
|
|
776610 |
+
|
|
|
776610 |
+#include "backends/meta-screen-cast-window-stream-src.h"
|
|
|
776610 |
+
|
|
|
776610 |
+#include "backends/meta-backend-private.h"
|
|
|
776610 |
+#include "backends/meta-screen-cast-window.h"
|
|
|
776610 |
+#include "backends/meta-screen-cast-window-stream.h"
|
|
|
776610 |
+#include "compositor/meta-window-actor-private.h"
|
|
|
776610 |
+
|
|
|
776610 |
+struct _MetaScreenCastWindowStreamSrc
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastStreamSrc parent;
|
|
|
776610 |
+
|
|
|
776610 |
+ MetaWindowActor *window_actor;
|
|
|
776610 |
+
|
|
|
776610 |
+ unsigned long actor_painted_handler_id;
|
|
|
776610 |
+ unsigned long actor_destroyed_handler_id;
|
|
|
776610 |
+};
|
|
|
776610 |
+
|
|
|
776610 |
+G_DEFINE_TYPE (MetaScreenCastWindowStreamSrc,
|
|
|
776610 |
+ meta_screen_cast_window_stream_src,
|
|
|
776610 |
+ META_TYPE_SCREEN_CAST_STREAM_SRC)
|
|
|
776610 |
+
|
|
|
776610 |
+static MetaScreenCastWindowStream *
|
|
|
776610 |
+get_window_stream (MetaScreenCastWindowStreamSrc *window_src)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastStreamSrc *src;
|
|
|
776610 |
+ MetaScreenCastStream *stream;
|
|
|
776610 |
+
|
|
|
776610 |
+ src = META_SCREEN_CAST_STREAM_SRC (window_src);
|
|
|
776610 |
+ stream = meta_screen_cast_stream_src_get_stream (src);
|
|
|
776610 |
+
|
|
|
776610 |
+ return META_SCREEN_CAST_WINDOW_STREAM (stream);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static MetaWindow *
|
|
|
776610 |
+get_window (MetaScreenCastWindowStreamSrc *window_src)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStream *window_stream;
|
|
|
776610 |
+
|
|
|
776610 |
+ window_stream = get_window_stream (window_src);
|
|
|
776610 |
+
|
|
|
776610 |
+ return meta_screen_cast_window_stream_get_window (window_stream);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static int
|
|
|
776610 |
+get_stream_width (MetaScreenCastWindowStreamSrc *window_src)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStream *window_stream;
|
|
|
776610 |
+
|
|
|
776610 |
+ window_stream = get_window_stream (window_src);
|
|
|
776610 |
+
|
|
|
776610 |
+ return meta_screen_cast_window_stream_get_width (window_stream);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static int
|
|
|
776610 |
+get_stream_height (MetaScreenCastWindowStreamSrc *window_src)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStream *window_stream;
|
|
|
776610 |
+
|
|
|
776610 |
+ window_stream = get_window_stream (window_src);
|
|
|
776610 |
+
|
|
|
776610 |
+ return meta_screen_cast_window_stream_get_height (window_stream);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static gboolean
|
|
|
776610 |
+capture_into (MetaScreenCastWindowStreamSrc *window_src,
|
|
|
776610 |
+ uint8_t *data)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaRectangle stream_rect;
|
|
|
776610 |
+ MetaScreenCastWindow *screen_cast_window;
|
|
|
776610 |
+
|
|
|
776610 |
+ stream_rect.x = 0;
|
|
|
776610 |
+ stream_rect.y = 0;
|
|
|
776610 |
+ stream_rect.width = get_stream_width (window_src);
|
|
|
776610 |
+ stream_rect.height = get_stream_height (window_src);
|
|
|
776610 |
+
|
|
|
776610 |
+ screen_cast_window = META_SCREEN_CAST_WINDOW (window_src->window_actor);
|
|
|
776610 |
+ meta_screen_cast_window_capture_into (screen_cast_window, &stream_rect, data);
|
|
|
776610 |
+
|
|
|
776610 |
+ return TRUE;
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
|
|
776610 |
+ int *width,
|
|
|
776610 |
+ int *height,
|
|
|
776610 |
+ float *frame_rate)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStreamSrc *window_src =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM_SRC (src);
|
|
|
776610 |
+
|
|
|
776610 |
+ *width = get_stream_width (window_src);
|
|
|
776610 |
+ *height = get_stream_height (window_src);
|
|
|
776610 |
+ *frame_rate = 60.0f;
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static gboolean
|
|
|
776610 |
+meta_screen_cast_window_stream_src_get_videocrop (MetaScreenCastStreamSrc *src,
|
|
|
776610 |
+ MetaRectangle *crop_rect)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStreamSrc *window_src =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM_SRC (src);
|
|
|
776610 |
+ MetaScreenCastWindow *screen_cast_window;
|
|
|
776610 |
+ MetaRectangle stream_rect;
|
|
|
776610 |
+
|
|
|
776610 |
+ screen_cast_window = META_SCREEN_CAST_WINDOW (window_src->window_actor);
|
|
|
776610 |
+ meta_screen_cast_window_get_frame_bounds (screen_cast_window, crop_rect);
|
|
|
776610 |
+
|
|
|
776610 |
+ stream_rect.x = 0;
|
|
|
776610 |
+ stream_rect.y = 0;
|
|
|
776610 |
+ stream_rect.width = get_stream_width (window_src);
|
|
|
776610 |
+ stream_rect.height = get_stream_height (window_src);
|
|
|
776610 |
+
|
|
|
776610 |
+ meta_rectangle_intersect (crop_rect, &stream_rect, crop_rect);
|
|
|
776610 |
+
|
|
|
776610 |
+ return TRUE;
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_src_stop (MetaScreenCastWindowStreamSrc *window_src)
|
|
|
776610 |
+
|
|
|
776610 |
+{
|
|
|
776610 |
+ if (!window_src->window_actor)
|
|
|
776610 |
+ return;
|
|
|
776610 |
+
|
|
|
776610 |
+ if (window_src->actor_painted_handler_id)
|
|
|
776610 |
+ g_signal_handler_disconnect (window_src->window_actor,
|
|
|
776610 |
+ window_src->actor_painted_handler_id);
|
|
|
776610 |
+ window_src->actor_painted_handler_id = 0;
|
|
|
776610 |
+
|
|
|
776610 |
+ if (window_src->actor_destroyed_handler_id)
|
|
|
776610 |
+ g_signal_handler_disconnect (window_src->window_actor,
|
|
|
776610 |
+ window_src->actor_destroyed_handler_id);
|
|
|
776610 |
+ window_src->actor_destroyed_handler_id = 0;
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+window_actor_painted (MetaWindowActor *actor,
|
|
|
776610 |
+ MetaScreenCastWindowStreamSrc *window_src)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (window_src);
|
|
|
776610 |
+
|
|
|
776610 |
+ meta_screen_cast_stream_src_maybe_record_frame (src);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+window_actor_destroyed (MetaWindowActor *actor,
|
|
|
776610 |
+ MetaScreenCastWindowStreamSrc *window_src)
|
|
|
776610 |
+{
|
|
|
776610 |
+ meta_screen_cast_window_stream_src_stop (window_src);
|
|
|
776610 |
+ window_src->window_actor = NULL;
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_src_enable (MetaScreenCastStreamSrc *src)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStreamSrc *window_src =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM_SRC (src);
|
|
|
776610 |
+ MetaWindowActor *window_actor;
|
|
|
776610 |
+
|
|
|
776610 |
+ window_actor = meta_window_actor_from_window (get_window (window_src));
|
|
|
776610 |
+ if (!window_actor)
|
|
|
776610 |
+ return;
|
|
|
776610 |
+
|
|
|
776610 |
+ window_src->window_actor = window_actor;
|
|
|
776610 |
+
|
|
|
776610 |
+ window_src->actor_painted_handler_id =
|
|
|
776610 |
+ g_signal_connect_after (window_src->window_actor,
|
|
|
776610 |
+ "paint",
|
|
|
776610 |
+ G_CALLBACK (window_actor_painted),
|
|
|
776610 |
+ window_src);
|
|
|
776610 |
+
|
|
|
776610 |
+ window_src->actor_destroyed_handler_id =
|
|
|
776610 |
+ g_signal_connect (window_src->window_actor,
|
|
|
776610 |
+ "destroy",
|
|
|
776610 |
+ G_CALLBACK (window_actor_destroyed),
|
|
|
776610 |
+ window_src);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_src_disable (MetaScreenCastStreamSrc *src)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStreamSrc *window_src =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM_SRC (src);
|
|
|
776610 |
+
|
|
|
776610 |
+ meta_screen_cast_window_stream_src_stop (window_src);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_src_record_frame (MetaScreenCastStreamSrc *src,
|
|
|
776610 |
+ uint8_t *data)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStreamSrc *window_src =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM_SRC (src);
|
|
|
776610 |
+
|
|
|
776610 |
+ capture_into (window_src, data);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+MetaScreenCastWindowStreamSrc *
|
|
|
776610 |
+meta_screen_cast_window_stream_src_new (MetaScreenCastWindowStream *window_stream,
|
|
|
776610 |
+ GError **error)
|
|
|
776610 |
+{
|
|
|
776610 |
+ return g_initable_new (META_TYPE_SCREEN_CAST_WINDOW_STREAM_SRC, NULL, error,
|
|
|
776610 |
+ "stream", window_stream,
|
|
|
776610 |
+ NULL);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_src_init (MetaScreenCastWindowStreamSrc *window_src)
|
|
|
776610 |
+{
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_src_class_init (MetaScreenCastWindowStreamSrcClass *klass)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastStreamSrcClass *src_class =
|
|
|
776610 |
+ META_SCREEN_CAST_STREAM_SRC_CLASS (klass);
|
|
|
776610 |
+
|
|
|
776610 |
+ src_class->get_specs = meta_screen_cast_window_stream_src_get_specs;
|
|
|
776610 |
+ src_class->enable = meta_screen_cast_window_stream_src_enable;
|
|
|
776610 |
+ src_class->disable = meta_screen_cast_window_stream_src_disable;
|
|
|
776610 |
+ src_class->record_frame = meta_screen_cast_window_stream_src_record_frame;
|
|
|
776610 |
+ src_class->get_videocrop = meta_screen_cast_window_stream_src_get_videocrop;
|
|
|
776610 |
+}
|
|
|
776610 |
diff --git a/src/backends/meta-screen-cast-window-stream-src.h b/src/backends/meta-screen-cast-window-stream-src.h
|
|
|
776610 |
new file mode 100644
|
|
|
776610 |
index 0000000..37f7869
|
|
|
776610 |
--- /dev/null
|
|
|
776610 |
+++ b/src/backends/meta-screen-cast-window-stream-src.h
|
|
|
776610 |
@@ -0,0 +1,37 @@
|
|
|
776610 |
+/*
|
|
|
776610 |
+ * Copyright (C) 2018 Red Hat Inc.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * This program is free software; you can redistribute it and/or
|
|
|
776610 |
+ * modify it under the terms of the GNU General Public License as
|
|
|
776610 |
+ * published by the Free Software Foundation; either version 2 of the
|
|
|
776610 |
+ * License, or (at your option) any later version.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * This program is distributed in the hope that it will be useful, but
|
|
|
776610 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
776610 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
776610 |
+ * General Public License for more details.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * You should have received a copy of the GNU General Public License
|
|
|
776610 |
+ * along with this program; if not, write to the Free Software
|
|
|
776610 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
776610 |
+ * 02111-1307, USA.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ */
|
|
|
776610 |
+
|
|
|
776610 |
+#ifndef META_SCREEN_CAST_WINDOW_STREAM_SRC_H
|
|
|
776610 |
+#define META_SCREEN_CAST_WINDOW_STREAM_SRC_H
|
|
|
776610 |
+
|
|
|
776610 |
+#include "backends/meta-screen-cast-stream-src.h"
|
|
|
776610 |
+
|
|
|
776610 |
+typedef struct _MetaScreenCastWindowStream MetaScreenCastWindowStream;
|
|
|
776610 |
+
|
|
|
776610 |
+#define META_TYPE_SCREEN_CAST_WINDOW_STREAM_SRC (meta_screen_cast_window_stream_src_get_type ())
|
|
|
776610 |
+G_DECLARE_FINAL_TYPE (MetaScreenCastWindowStreamSrc,
|
|
|
776610 |
+ meta_screen_cast_window_stream_src,
|
|
|
776610 |
+ META, SCREEN_CAST_WINDOW_STREAM_SRC,
|
|
|
776610 |
+ MetaScreenCastStreamSrc)
|
|
|
776610 |
+
|
|
|
776610 |
+MetaScreenCastWindowStreamSrc * meta_screen_cast_window_stream_src_new (MetaScreenCastWindowStream *window_stream,
|
|
|
776610 |
+ GError **error);
|
|
|
776610 |
+
|
|
|
776610 |
+#endif /* META_SCREEN_CAST_WINDOW_STREAM_SRC_H */
|
|
|
776610 |
diff --git a/src/backends/meta-screen-cast-window-stream.c b/src/backends/meta-screen-cast-window-stream.c
|
|
|
776610 |
new file mode 100644
|
|
|
776610 |
index 0000000..1200a39
|
|
|
776610 |
--- /dev/null
|
|
|
776610 |
+++ b/src/backends/meta-screen-cast-window-stream.c
|
|
|
776610 |
@@ -0,0 +1,270 @@
|
|
|
776610 |
+/*
|
|
|
776610 |
+ * Copyright (C) 2018 Red Hat Inc.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * This program is free software; you can redistribute it and/or
|
|
|
776610 |
+ * modify it under the terms of the GNU General Public License as
|
|
|
776610 |
+ * published by the Free Software Foundation; either version 2 of the
|
|
|
776610 |
+ * License, or (at your option) any later version.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * This program is distributed in the hope that it will be useful, but
|
|
|
776610 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
776610 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
776610 |
+ * General Public License for more details.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * You should have received a copy of the GNU General Public License
|
|
|
776610 |
+ * along with this program; if not, write to the Free Software
|
|
|
776610 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
776610 |
+ * 02111-1307, USA.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ */
|
|
|
776610 |
+
|
|
|
776610 |
+#include "config.h"
|
|
|
776610 |
+
|
|
|
776610 |
+#include "backends/meta-screen-cast-window-stream.h"
|
|
|
776610 |
+
|
|
|
776610 |
+#include "backends/meta-logical-monitor.h"
|
|
|
776610 |
+#include "backends/meta-monitor-manager-private.h"
|
|
|
776610 |
+#include "backends/meta-screen-cast-window.h"
|
|
|
776610 |
+#include "backends/meta-screen-cast-window-stream-src.h"
|
|
|
776610 |
+#include "compositor/meta-window-actor-private.h"
|
|
|
776610 |
+#include "core/window-private.h"
|
|
|
776610 |
+
|
|
|
776610 |
+enum
|
|
|
776610 |
+{
|
|
|
776610 |
+ PROP_0,
|
|
|
776610 |
+
|
|
|
776610 |
+ PROP_WINDOW,
|
|
|
776610 |
+};
|
|
|
776610 |
+
|
|
|
776610 |
+struct _MetaScreenCastWindowStream
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastStream parent;
|
|
|
776610 |
+
|
|
|
776610 |
+ MetaWindow *window;
|
|
|
776610 |
+
|
|
|
776610 |
+ int stream_width;
|
|
|
776610 |
+ int stream_height;
|
|
|
776610 |
+
|
|
|
776610 |
+ unsigned long window_unmanaged_handler_id;
|
|
|
776610 |
+};
|
|
|
776610 |
+
|
|
|
776610 |
+G_DEFINE_TYPE (MetaScreenCastWindowStream,
|
|
|
776610 |
+ meta_screen_cast_window_stream,
|
|
|
776610 |
+ META_TYPE_SCREEN_CAST_STREAM)
|
|
|
776610 |
+
|
|
|
776610 |
+MetaWindow *
|
|
|
776610 |
+meta_screen_cast_window_stream_get_window (MetaScreenCastWindowStream *window_stream)
|
|
|
776610 |
+{
|
|
|
776610 |
+ return window_stream->window;
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+int
|
|
|
776610 |
+meta_screen_cast_window_stream_get_width (MetaScreenCastWindowStream *window_stream)
|
|
|
776610 |
+{
|
|
|
776610 |
+ return window_stream->stream_width;
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+int
|
|
|
776610 |
+meta_screen_cast_window_stream_get_height (MetaScreenCastWindowStream *window_stream)
|
|
|
776610 |
+{
|
|
|
776610 |
+ return window_stream->stream_height;
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+MetaScreenCastWindowStream *
|
|
|
776610 |
+meta_screen_cast_window_stream_new (GDBusConnection *connection,
|
|
|
776610 |
+ MetaWindow *window,
|
|
|
776610 |
+ GError **error)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStream *window_stream;
|
|
|
776610 |
+ MetaLogicalMonitor *logical_monitor;
|
|
|
776610 |
+ int scale;
|
|
|
776610 |
+
|
|
|
776610 |
+ logical_monitor = meta_window_get_main_logical_monitor (window);
|
|
|
776610 |
+ if (!logical_monitor)
|
|
|
776610 |
+ {
|
|
|
776610 |
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
776610 |
+ "Main logical monitor not found");
|
|
|
776610 |
+ return NULL;
|
|
|
776610 |
+ }
|
|
|
776610 |
+
|
|
|
776610 |
+ window_stream = g_initable_new (META_TYPE_SCREEN_CAST_WINDOW_STREAM,
|
|
|
776610 |
+ NULL,
|
|
|
776610 |
+ error,
|
|
|
776610 |
+ "connection", connection,
|
|
|
776610 |
+ "window", window,
|
|
|
776610 |
+ NULL);
|
|
|
776610 |
+ if (!window_stream)
|
|
|
776610 |
+ return NULL;
|
|
|
776610 |
+
|
|
|
776610 |
+ window_stream->window = window;
|
|
|
776610 |
+ /* We cannot set the stream size to the exact size of the window, because
|
|
|
776610 |
+ * windows can be resized, whereas streams cannot.
|
|
|
776610 |
+ * So we set a size equals to the size of the logical monitor for the window.
|
|
|
776610 |
+ */
|
|
|
776610 |
+ scale = (int) ceil (meta_logical_monitor_get_scale (logical_monitor));
|
|
|
776610 |
+ window_stream->stream_width = logical_monitor->rect.width * scale;
|
|
|
776610 |
+ window_stream->stream_height = logical_monitor->rect.height * scale;
|
|
|
776610 |
+
|
|
|
776610 |
+ return window_stream;
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static MetaScreenCastStreamSrc *
|
|
|
776610 |
+meta_screen_cast_window_stream_create_src (MetaScreenCastStream *stream,
|
|
|
776610 |
+ GError **error)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStream *window_stream =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM (stream);
|
|
|
776610 |
+ MetaScreenCastWindowStreamSrc *window_stream_src;
|
|
|
776610 |
+
|
|
|
776610 |
+ window_stream_src = meta_screen_cast_window_stream_src_new (window_stream,
|
|
|
776610 |
+ error);
|
|
|
776610 |
+ if (!window_stream_src)
|
|
|
776610 |
+ return NULL;
|
|
|
776610 |
+
|
|
|
776610 |
+ return META_SCREEN_CAST_STREAM_SRC (window_stream_src);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_set_parameters (MetaScreenCastStream *stream,
|
|
|
776610 |
+ GVariantBuilder *parameters_builder)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStream *window_stream =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM (stream);
|
|
|
776610 |
+ MetaScreenCastWindow *screen_cast_window =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW (meta_window_actor_from_window (window_stream->window));
|
|
|
776610 |
+ MetaRectangle bounds;
|
|
|
776610 |
+
|
|
|
776610 |
+ meta_screen_cast_window_get_buffer_bounds (screen_cast_window, &bounds);
|
|
|
776610 |
+
|
|
|
776610 |
+ g_variant_builder_add (parameters_builder, "{sv}",
|
|
|
776610 |
+ "position",
|
|
|
776610 |
+ g_variant_new ("(ii)",
|
|
|
776610 |
+ bounds.x, bounds.y));
|
|
|
776610 |
+
|
|
|
776610 |
+ g_variant_builder_add (parameters_builder, "{sv}",
|
|
|
776610 |
+ "size",
|
|
|
776610 |
+ g_variant_new ("(ii)",
|
|
|
776610 |
+ bounds.width,
|
|
|
776610 |
+ bounds.height));
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_transform_position (MetaScreenCastStream *stream,
|
|
|
776610 |
+ double stream_x,
|
|
|
776610 |
+ double stream_y,
|
|
|
776610 |
+ double *x,
|
|
|
776610 |
+ double *y)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStream *window_stream =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM (stream);
|
|
|
776610 |
+ MetaScreenCastWindow *screen_cast_window =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW (meta_window_actor_from_window (window_stream->window));
|
|
|
776610 |
+
|
|
|
776610 |
+ meta_screen_cast_window_transform_relative_position (screen_cast_window,
|
|
|
776610 |
+ stream_x,
|
|
|
776610 |
+ stream_y,
|
|
|
776610 |
+ x,
|
|
|
776610 |
+ y);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+on_window_unmanaged (MetaScreenCastWindowStream *window_stream)
|
|
|
776610 |
+{
|
|
|
776610 |
+ meta_screen_cast_stream_close (META_SCREEN_CAST_STREAM (window_stream));
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_constructed (GObject *object)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStream *window_stream =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM (object);
|
|
|
776610 |
+
|
|
|
776610 |
+ window_stream->window_unmanaged_handler_id =
|
|
|
776610 |
+ g_signal_connect_swapped (window_stream->window, "unmanaged",
|
|
|
776610 |
+ G_CALLBACK (on_window_unmanaged),
|
|
|
776610 |
+ window_stream);
|
|
|
776610 |
+
|
|
|
776610 |
+ G_OBJECT_CLASS (meta_screen_cast_window_stream_parent_class)->constructed (object);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_set_property (GObject *object,
|
|
|
776610 |
+ guint prop_id,
|
|
|
776610 |
+ const GValue *value,
|
|
|
776610 |
+ GParamSpec *pspec)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStream *window_stream =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM (object);
|
|
|
776610 |
+
|
|
|
776610 |
+ switch (prop_id)
|
|
|
776610 |
+ {
|
|
|
776610 |
+ case PROP_WINDOW:
|
|
|
776610 |
+ window_stream->window = g_value_get_object (value);
|
|
|
776610 |
+ break;
|
|
|
776610 |
+ default:
|
|
|
776610 |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
776610 |
+ }
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_get_property (GObject *object,
|
|
|
776610 |
+ guint prop_id,
|
|
|
776610 |
+ GValue *value,
|
|
|
776610 |
+ GParamSpec *pspec)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStream *window_stream =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM (object);
|
|
|
776610 |
+
|
|
|
776610 |
+ switch (prop_id)
|
|
|
776610 |
+ {
|
|
|
776610 |
+ case PROP_WINDOW:
|
|
|
776610 |
+ g_value_set_object (value, window_stream->window);
|
|
|
776610 |
+ break;
|
|
|
776610 |
+ default:
|
|
|
776610 |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
776610 |
+ }
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_finalize (GObject *object)
|
|
|
776610 |
+{
|
|
|
776610 |
+ MetaScreenCastWindowStream *window_stream =
|
|
|
776610 |
+ META_SCREEN_CAST_WINDOW_STREAM (object);
|
|
|
776610 |
+
|
|
|
776610 |
+ g_signal_handler_disconnect (window_stream->window,
|
|
|
776610 |
+ window_stream->window_unmanaged_handler_id);
|
|
|
776610 |
+
|
|
|
776610 |
+ G_OBJECT_CLASS (meta_screen_cast_window_stream_parent_class)->finalize (object);
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_init (MetaScreenCastWindowStream *window_stream)
|
|
|
776610 |
+{
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+static void
|
|
|
776610 |
+meta_screen_cast_window_stream_class_init (MetaScreenCastWindowStreamClass *klass)
|
|
|
776610 |
+{
|
|
|
776610 |
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
776610 |
+ MetaScreenCastStreamClass *stream_class =
|
|
|
776610 |
+ META_SCREEN_CAST_STREAM_CLASS (klass);
|
|
|
776610 |
+
|
|
|
776610 |
+ object_class->constructed = meta_screen_cast_window_stream_constructed;
|
|
|
776610 |
+ object_class->set_property = meta_screen_cast_window_stream_set_property;
|
|
|
776610 |
+ object_class->get_property = meta_screen_cast_window_stream_get_property;
|
|
|
776610 |
+ object_class->finalize = meta_screen_cast_window_stream_finalize;
|
|
|
776610 |
+
|
|
|
776610 |
+ stream_class->create_src = meta_screen_cast_window_stream_create_src;
|
|
|
776610 |
+ stream_class->set_parameters = meta_screen_cast_window_stream_set_parameters;
|
|
|
776610 |
+ stream_class->transform_position = meta_screen_cast_window_stream_transform_position;
|
|
|
776610 |
+
|
|
|
776610 |
+ g_object_class_install_property (object_class,
|
|
|
776610 |
+ PROP_WINDOW,
|
|
|
776610 |
+ g_param_spec_object ("window",
|
|
|
776610 |
+ "window",
|
|
|
776610 |
+ "MetaWindow",
|
|
|
776610 |
+ META_TYPE_WINDOW,
|
|
|
776610 |
+ G_PARAM_READWRITE |
|
|
|
776610 |
+ G_PARAM_CONSTRUCT_ONLY |
|
|
|
776610 |
+ G_PARAM_STATIC_STRINGS));
|
|
|
776610 |
+}
|
|
|
776610 |
diff --git a/src/backends/meta-screen-cast-window-stream.h b/src/backends/meta-screen-cast-window-stream.h
|
|
|
776610 |
new file mode 100644
|
|
|
776610 |
index 0000000..6726ef8
|
|
|
776610 |
--- /dev/null
|
|
|
776610 |
+++ b/src/backends/meta-screen-cast-window-stream.h
|
|
|
776610 |
@@ -0,0 +1,43 @@
|
|
|
776610 |
+/*
|
|
|
776610 |
+ * Copyright (C) 2018 Red Hat Inc.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * This program is free software; you can redistribute it and/or
|
|
|
776610 |
+ * modify it under the terms of the GNU General Public License as
|
|
|
776610 |
+ * published by the Free Software Foundation; either version 2 of the
|
|
|
776610 |
+ * License, or (at your option) any later version.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * This program is distributed in the hope that it will be useful, but
|
|
|
776610 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
776610 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
776610 |
+ * General Public License for more details.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * You should have received a copy of the GNU General Public License
|
|
|
776610 |
+ * along with this program; if not, write to the Free Software
|
|
|
776610 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
776610 |
+ * 02111-1307, USA.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ */
|
|
|
776610 |
+
|
|
|
776610 |
+#ifndef META_SCREEN_CAST_WINDOW_STREAM_H
|
|
|
776610 |
+#define META_SCREEN_CAST_WINDOW_STREAM_H
|
|
|
776610 |
+
|
|
|
776610 |
+#include <glib-object.h>
|
|
|
776610 |
+
|
|
|
776610 |
+#include "backends/meta-screen-cast-stream.h"
|
|
|
776610 |
+#include "meta/window.h"
|
|
|
776610 |
+
|
|
|
776610 |
+#define META_TYPE_SCREEN_CAST_WINDOW_STREAM (meta_screen_cast_window_stream_get_type ())
|
|
|
776610 |
+G_DECLARE_FINAL_TYPE (MetaScreenCastWindowStream,
|
|
|
776610 |
+ meta_screen_cast_window_stream,
|
|
|
776610 |
+ META, SCREEN_CAST_WINDOW_STREAM,
|
|
|
776610 |
+ MetaScreenCastStream)
|
|
|
776610 |
+
|
|
|
776610 |
+MetaScreenCastWindowStream * meta_screen_cast_window_stream_new (GDBusConnection *connection,
|
|
|
776610 |
+ MetaWindow *window,
|
|
|
776610 |
+ GError **error);
|
|
|
776610 |
+
|
|
|
776610 |
+MetaWindow * meta_screen_cast_window_stream_get_window (MetaScreenCastWindowStream *window_stream);
|
|
|
776610 |
+int meta_screen_cast_window_stream_get_width (MetaScreenCastWindowStream *window_stream);
|
|
|
776610 |
+int meta_screen_cast_window_stream_get_height (MetaScreenCastWindowStream *window_stream);
|
|
|
776610 |
+
|
|
|
776610 |
+#endif /* META_SCREEN_CAST_WINDOW_STREAM_H */
|
|
|
776610 |
--
|
|
|
776610 |
2.19.2
|
|
|
776610 |
|