2017-06-21 02:23:44 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "backends/meta-screen-cast-monitor-stream-src.h"
|
|
|
|
|
2018-12-14 11:47:57 -05:00
|
|
|
#include <spa/buffer/meta.h>
|
|
|
|
|
2017-06-21 02:23:44 -04:00
|
|
|
#include "backends/meta-backend-private.h"
|
2018-12-14 11:47:57 -05:00
|
|
|
#include "backends/meta-cursor-tracker-private.h"
|
2017-06-21 02:23:44 -04:00
|
|
|
#include "backends/meta-logical-monitor.h"
|
|
|
|
#include "backends/meta-monitor.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/meta-screen-cast-monitor-stream.h"
|
2018-12-14 11:47:57 -05:00
|
|
|
#include "backends/meta-screen-cast-session.h"
|
2019-06-17 20:49:45 -04:00
|
|
|
#include "backends/meta-stage-private.h"
|
2017-06-21 02:23:44 -04:00
|
|
|
#include "clutter/clutter.h"
|
|
|
|
#include "clutter/clutter-mutter.h"
|
2018-12-14 11:47:57 -05:00
|
|
|
#include "core/boxes-private.h"
|
2017-06-21 02:23:44 -04:00
|
|
|
|
|
|
|
struct _MetaScreenCastMonitorStreamSrc
|
|
|
|
{
|
|
|
|
MetaScreenCastStreamSrc parent;
|
|
|
|
|
2019-01-03 10:51:08 -05:00
|
|
|
gboolean cursor_bitmap_invalid;
|
2020-01-17 15:08:02 -05:00
|
|
|
gboolean hw_cursor_inhibited;
|
2019-01-03 10:51:08 -05:00
|
|
|
|
2020-01-17 15:08:02 -05:00
|
|
|
GList *watches;
|
2019-06-17 20:49:45 -04:00
|
|
|
|
2020-07-13 08:09:44 -04:00
|
|
|
gulong position_invalidated_handler_id;
|
2018-12-14 11:47:57 -05:00
|
|
|
gulong cursor_changed_handler_id;
|
2022-04-29 10:05:50 -04:00
|
|
|
gulong stage_prepare_frame_handler_id;
|
2021-06-25 12:33:28 -04:00
|
|
|
|
|
|
|
guint maybe_record_idle_id;
|
2017-06-21 02:23:44 -04:00
|
|
|
};
|
|
|
|
|
2018-12-14 11:47:57 -05:00
|
|
|
static void
|
|
|
|
hw_cursor_inhibitor_iface_init (MetaHwCursorInhibitorInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (MetaScreenCastMonitorStreamSrc,
|
|
|
|
meta_screen_cast_monitor_stream_src,
|
|
|
|
META_TYPE_SCREEN_CAST_STREAM_SRC,
|
|
|
|
G_IMPLEMENT_INTERFACE (META_TYPE_HW_CURSOR_INHIBITOR,
|
|
|
|
hw_cursor_inhibitor_iface_init))
|
2017-06-21 02:23:44 -04:00
|
|
|
|
|
|
|
static ClutterStage *
|
|
|
|
get_stage (MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
|
|
|
MetaScreenCastStreamSrc *src;
|
|
|
|
MetaScreenCastStream *stream;
|
|
|
|
MetaScreenCastMonitorStream *monitor_stream;
|
|
|
|
|
|
|
|
src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
|
|
|
|
stream = meta_screen_cast_stream_src_get_stream (src);
|
|
|
|
monitor_stream = META_SCREEN_CAST_MONITOR_STREAM (stream);
|
|
|
|
|
|
|
|
return meta_screen_cast_monitor_stream_get_stage (monitor_stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
static MetaMonitor *
|
|
|
|
get_monitor (MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
|
|
|
MetaScreenCastStreamSrc *src;
|
|
|
|
MetaScreenCastStream *stream;
|
|
|
|
MetaScreenCastMonitorStream *monitor_stream;
|
|
|
|
|
|
|
|
src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
|
|
|
|
stream = meta_screen_cast_stream_src_get_stream (src);
|
|
|
|
monitor_stream = META_SCREEN_CAST_MONITOR_STREAM (stream);
|
|
|
|
|
|
|
|
return meta_screen_cast_monitor_stream_get_monitor (monitor_stream);
|
|
|
|
}
|
|
|
|
|
2021-02-01 04:41:57 -05:00
|
|
|
static gboolean
|
2017-06-21 02:23:44 -04:00
|
|
|
meta_screen_cast_monitor_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
|
|
|
int *width,
|
|
|
|
int *height,
|
|
|
|
float *frame_rate)
|
|
|
|
{
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src =
|
|
|
|
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
|
|
|
|
MetaMonitor *monitor;
|
|
|
|
MetaLogicalMonitor *logical_monitor;
|
|
|
|
float scale;
|
|
|
|
MetaMonitorMode *mode;
|
|
|
|
|
|
|
|
monitor = get_monitor (monitor_src);
|
|
|
|
logical_monitor = meta_monitor_get_logical_monitor (monitor);
|
|
|
|
mode = meta_monitor_get_current_mode (monitor);
|
|
|
|
|
2019-01-25 16:06:39 -05:00
|
|
|
if (meta_is_stage_views_scaled ())
|
|
|
|
scale = logical_monitor->scale;
|
|
|
|
else
|
|
|
|
scale = 1.0;
|
|
|
|
|
2017-06-21 02:23:44 -04:00
|
|
|
*width = (int) roundf (logical_monitor->rect.width * scale);
|
|
|
|
*height = (int) roundf (logical_monitor->rect.height * scale);
|
|
|
|
*frame_rate = meta_monitor_mode_get_refresh_rate (mode);
|
2021-02-01 04:41:57 -05:00
|
|
|
|
|
|
|
return TRUE;
|
2017-06-21 02:23:44 -04:00
|
|
|
}
|
|
|
|
|
2021-06-25 12:33:28 -04:00
|
|
|
static gboolean
|
|
|
|
maybe_record_frame_on_idle (gpointer user_data)
|
|
|
|
{
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src =
|
|
|
|
META_SCREEN_CAST_MONITOR_STREAM_SRC (user_data);
|
|
|
|
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
|
|
|
|
MetaScreenCastRecordFlag flags;
|
|
|
|
|
|
|
|
monitor_src->maybe_record_idle_id = 0;
|
|
|
|
|
|
|
|
flags = META_SCREEN_CAST_RECORD_FLAG_NONE;
|
|
|
|
meta_screen_cast_stream_src_maybe_record_frame (src, flags);
|
|
|
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
2017-06-21 02:23:44 -04:00
|
|
|
static void
|
2020-04-20 16:24:55 -04:00
|
|
|
stage_painted (MetaStage *stage,
|
|
|
|
ClutterStageView *view,
|
|
|
|
ClutterPaintContext *paint_context,
|
|
|
|
gpointer user_data)
|
2017-06-21 02:23:44 -04:00
|
|
|
{
|
2021-06-25 12:33:28 -04:00
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src =
|
|
|
|
META_SCREEN_CAST_MONITOR_STREAM_SRC (user_data);
|
|
|
|
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
|
2017-06-21 02:23:44 -04:00
|
|
|
|
2021-06-25 12:33:28 -04:00
|
|
|
if (monitor_src->maybe_record_idle_id)
|
|
|
|
return;
|
|
|
|
|
|
|
|
monitor_src->maybe_record_idle_id = g_idle_add (maybe_record_frame_on_idle,
|
|
|
|
src);
|
|
|
|
g_source_set_name_by_id (monitor_src->maybe_record_idle_id,
|
|
|
|
"[mutter] maybe_record_frame_on_idle [monitor-src]");
|
2017-06-21 02:23:44 -04:00
|
|
|
}
|
|
|
|
|
2020-08-29 14:41:57 -04:00
|
|
|
static void
|
|
|
|
before_stage_painted (MetaStage *stage,
|
|
|
|
ClutterStageView *view,
|
|
|
|
ClutterPaintContext *paint_context,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2021-06-25 12:33:28 -04:00
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src =
|
|
|
|
META_SCREEN_CAST_MONITOR_STREAM_SRC (user_data);
|
|
|
|
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
|
screen-cast/monitor-stream: Immediately record scanout frames
When the before-paint function is executed, it's only purpose
is to check if there's any scanout queue, and immediately
record it if any.
However, since [1], we regressed in this specific case with the
introduction of an idle callback in the before-paint function.
The regression only happens when the PipeWire stream is using
DMA-BUF buffers, and it would operate as follows:
1. In before-paint, when there's a scanout available, we queue
an idle callback to capture the monitor. The idle callback
(almost always) executes after the scanout is pulled from
the stage view
2. meta_screen_cast_stream_src_maybe_record_frame() is called
by the idle callback. In the DMA-BUF case, it then runs
meta_screen_cast_monitor_stream_src_record_to_framebuffer()
3. In meta_screen_cast_monitor_stream_src_record_to_framebuffer(),
because the stage view doesn't have a scanout anymore, it
ends up calling cogl_blit_framebuffer() with the stage view
framebuffer. This is the regression bug.
This regression presents itself in the form of the screencast
stream showing the desktop when there's an unredirected fullscreen
application window running.
Revert before-paint - and only that - back to immediately capturing
any available scanout. Only record these frames when the target
buffer is a DMA-BUF handle. Nothing is captured on before-paint if
the stream is not using DMA-BUF, since the regular paint routine
will handle these frames regularly post-paint.
[1] https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2186>
2021-12-27 13:32:27 -05:00
|
|
|
MetaScreenCastRecordFlag flags;
|
2020-08-29 14:41:57 -04:00
|
|
|
|
2021-06-25 12:33:28 -04:00
|
|
|
if (monitor_src->maybe_record_idle_id)
|
|
|
|
return;
|
2020-08-29 14:41:57 -04:00
|
|
|
|
2021-06-25 12:33:28 -04:00
|
|
|
if (!clutter_stage_view_peek_scanout (view))
|
|
|
|
return;
|
|
|
|
|
screen-cast/monitor-stream: Immediately record scanout frames
When the before-paint function is executed, it's only purpose
is to check if there's any scanout queue, and immediately
record it if any.
However, since [1], we regressed in this specific case with the
introduction of an idle callback in the before-paint function.
The regression only happens when the PipeWire stream is using
DMA-BUF buffers, and it would operate as follows:
1. In before-paint, when there's a scanout available, we queue
an idle callback to capture the monitor. The idle callback
(almost always) executes after the scanout is pulled from
the stage view
2. meta_screen_cast_stream_src_maybe_record_frame() is called
by the idle callback. In the DMA-BUF case, it then runs
meta_screen_cast_monitor_stream_src_record_to_framebuffer()
3. In meta_screen_cast_monitor_stream_src_record_to_framebuffer(),
because the stage view doesn't have a scanout anymore, it
ends up calling cogl_blit_framebuffer() with the stage view
framebuffer. This is the regression bug.
This regression presents itself in the form of the screencast
stream showing the desktop when there's an unredirected fullscreen
application window running.
Revert before-paint - and only that - back to immediately capturing
any available scanout. Only record these frames when the target
buffer is a DMA-BUF handle. Nothing is captured on before-paint if
the stream is not using DMA-BUF, since the regular paint routine
will handle these frames regularly post-paint.
[1] https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2186>
2021-12-27 13:32:27 -05:00
|
|
|
flags = META_SCREEN_CAST_RECORD_FLAG_DMABUF_ONLY;
|
|
|
|
meta_screen_cast_stream_src_maybe_record_frame (src, flags);
|
2020-08-29 14:41:57 -04:00
|
|
|
}
|
|
|
|
|
2018-12-14 11:47:57 -05:00
|
|
|
static MetaBackend *
|
|
|
|
get_backend (MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
|
|
|
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
|
|
|
|
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
|
|
|
|
MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream);
|
|
|
|
MetaScreenCast *screen_cast =
|
|
|
|
meta_screen_cast_session_get_screen_cast (session);
|
|
|
|
|
|
|
|
return meta_screen_cast_get_backend (screen_cast);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
is_cursor_in_stream (MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = get_backend (monitor_src);
|
|
|
|
MetaCursorRenderer *cursor_renderer =
|
|
|
|
meta_backend_get_cursor_renderer (backend);
|
|
|
|
MetaMonitor *monitor;
|
|
|
|
MetaLogicalMonitor *logical_monitor;
|
|
|
|
MetaRectangle logical_monitor_layout;
|
2019-02-20 10:23:04 -05:00
|
|
|
graphene_rect_t logical_monitor_rect;
|
2018-12-14 11:47:57 -05:00
|
|
|
MetaCursorSprite *cursor_sprite;
|
|
|
|
|
|
|
|
monitor = get_monitor (monitor_src);
|
|
|
|
logical_monitor = meta_monitor_get_logical_monitor (monitor);
|
|
|
|
logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
|
|
|
|
logical_monitor_rect =
|
2019-02-20 10:23:04 -05:00
|
|
|
meta_rectangle_to_graphene_rect (&logical_monitor_layout);
|
2018-12-14 11:47:57 -05:00
|
|
|
|
|
|
|
cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer);
|
|
|
|
if (cursor_sprite)
|
|
|
|
{
|
2019-02-20 10:23:04 -05:00
|
|
|
graphene_rect_t cursor_rect;
|
2018-12-14 11:47:57 -05:00
|
|
|
|
|
|
|
cursor_rect = meta_cursor_renderer_calculate_rect (cursor_renderer,
|
|
|
|
cursor_sprite);
|
2019-02-20 10:23:04 -05:00
|
|
|
return graphene_rect_intersection (&cursor_rect,
|
|
|
|
&logical_monitor_rect,
|
|
|
|
NULL);
|
2018-12-14 11:47:57 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-13 06:28:46 -04:00
|
|
|
MetaCursorTracker *cursor_tracker =
|
|
|
|
meta_backend_get_cursor_tracker (backend);
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_t cursor_position;
|
2018-12-14 11:47:57 -05:00
|
|
|
|
2020-07-13 06:28:46 -04:00
|
|
|
meta_cursor_tracker_get_pointer (cursor_tracker, &cursor_position, NULL);
|
2019-02-20 10:23:04 -05:00
|
|
|
return graphene_rect_contains_point (&logical_monitor_rect,
|
|
|
|
&cursor_position);
|
2018-12-14 11:47:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-01 05:06:13 -04:00
|
|
|
static gboolean
|
|
|
|
is_redraw_queued (MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = get_backend (monitor_src);
|
|
|
|
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
|
|
|
ClutterStage *stage = get_stage (monitor_src);
|
|
|
|
MetaMonitor *monitor = get_monitor (monitor_src);
|
|
|
|
g_autoptr (GList) views = NULL;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
views = meta_renderer_get_views_for_monitor (renderer, monitor);
|
|
|
|
for (l = views; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaRendererView *view = l->data;
|
|
|
|
|
|
|
|
if (clutter_stage_is_redraw_queued_on_view (stage, CLUTTER_STAGE_VIEW (view)))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-12-14 11:47:57 -05:00
|
|
|
static void
|
|
|
|
sync_cursor_state (MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
|
|
|
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
|
2020-07-03 10:48:52 -04:00
|
|
|
MetaScreenCastRecordFlag flags;
|
2018-12-14 11:47:57 -05:00
|
|
|
|
2020-04-01 05:06:13 -04:00
|
|
|
if (is_redraw_queued (monitor_src))
|
2018-12-14 11:47:57 -05:00
|
|
|
return;
|
|
|
|
|
2020-07-03 17:57:31 -04:00
|
|
|
if (meta_screen_cast_stream_src_pending_follow_up_frame (src))
|
|
|
|
return;
|
|
|
|
|
2020-07-03 10:52:43 -04:00
|
|
|
flags = META_SCREEN_CAST_RECORD_FLAG_CURSOR_ONLY;
|
2020-07-03 10:48:52 -04:00
|
|
|
meta_screen_cast_stream_src_maybe_record_frame (src, flags);
|
2018-12-14 11:47:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-07-13 08:09:44 -04:00
|
|
|
pointer_position_invalidated (MetaCursorTracker *cursor_tracker,
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src)
|
2018-12-14 11:47:57 -05:00
|
|
|
{
|
2022-04-29 10:05:50 -04:00
|
|
|
ClutterStage *stage = get_stage (monitor_src);
|
|
|
|
|
|
|
|
clutter_stage_schedule_update (stage);
|
2018-12-14 11:47:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cursor_changed (MetaCursorTracker *cursor_tracker,
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
2019-01-03 10:51:08 -05:00
|
|
|
monitor_src->cursor_bitmap_invalid = TRUE;
|
2018-12-14 11:47:57 -05:00
|
|
|
sync_cursor_state (monitor_src);
|
|
|
|
}
|
|
|
|
|
2022-04-29 10:05:50 -04:00
|
|
|
static void
|
|
|
|
on_prepare_frame (ClutterStage *stage,
|
|
|
|
ClutterStageView *stage_view,
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
|
|
|
sync_cursor_state (monitor_src);
|
|
|
|
}
|
|
|
|
|
2018-12-14 11:47:57 -05:00
|
|
|
static void
|
|
|
|
inhibit_hw_cursor (MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
|
|
|
MetaHwCursorInhibitor *inhibitor;
|
2020-07-13 11:45:41 -04:00
|
|
|
MetaBackend *backend;
|
2018-12-14 11:47:57 -05:00
|
|
|
|
2020-01-17 15:08:02 -05:00
|
|
|
g_return_if_fail (!monitor_src->hw_cursor_inhibited);
|
|
|
|
|
2020-07-13 11:45:41 -04:00
|
|
|
backend = get_backend (monitor_src);
|
2018-12-14 11:47:57 -05:00
|
|
|
inhibitor = META_HW_CURSOR_INHIBITOR (monitor_src);
|
2020-07-13 11:45:41 -04:00
|
|
|
meta_backend_add_hw_cursor_inhibitor (backend, inhibitor);
|
2020-01-17 15:08:02 -05:00
|
|
|
|
|
|
|
monitor_src->hw_cursor_inhibited = TRUE;
|
2018-12-14 11:47:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
uninhibit_hw_cursor (MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
|
|
|
MetaHwCursorInhibitor *inhibitor;
|
2020-07-13 11:45:41 -04:00
|
|
|
MetaBackend *backend;
|
2018-12-14 11:47:57 -05:00
|
|
|
|
2020-01-17 15:08:02 -05:00
|
|
|
g_return_if_fail (monitor_src->hw_cursor_inhibited);
|
|
|
|
|
2020-07-13 11:45:41 -04:00
|
|
|
backend = get_backend (monitor_src);
|
2018-12-14 11:47:57 -05:00
|
|
|
inhibitor = META_HW_CURSOR_INHIBITOR (monitor_src);
|
2020-07-13 11:45:41 -04:00
|
|
|
meta_backend_remove_hw_cursor_inhibitor (backend, inhibitor);
|
2020-01-17 15:08:02 -05:00
|
|
|
|
|
|
|
monitor_src->hw_cursor_inhibited = FALSE;
|
2018-12-14 11:47:57 -05:00
|
|
|
}
|
|
|
|
|
2017-06-21 02:23:44 -04:00
|
|
|
static void
|
2020-08-29 14:37:38 -04:00
|
|
|
add_view_watches (MetaScreenCastMonitorStreamSrc *monitor_src,
|
|
|
|
MetaStageWatchPhase watch_phase,
|
|
|
|
MetaStageWatchFunc callback)
|
2017-06-21 02:23:44 -04:00
|
|
|
{
|
2018-12-14 11:47:57 -05:00
|
|
|
MetaBackend *backend = get_backend (monitor_src);
|
2019-06-17 20:49:45 -04:00
|
|
|
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
2020-01-17 15:08:02 -05:00
|
|
|
ClutterStage *stage;
|
|
|
|
MetaStage *meta_stage;
|
2019-06-17 20:49:45 -04:00
|
|
|
MetaMonitor *monitor;
|
|
|
|
MetaLogicalMonitor *logical_monitor;
|
2020-01-17 15:08:02 -05:00
|
|
|
MetaRectangle logical_monitor_layout;
|
|
|
|
GList *l;
|
2017-06-21 02:23:44 -04:00
|
|
|
|
|
|
|
stage = get_stage (monitor_src);
|
2019-06-17 20:49:45 -04:00
|
|
|
meta_stage = META_STAGE (stage);
|
|
|
|
monitor = get_monitor (monitor_src);
|
|
|
|
logical_monitor = meta_monitor_get_logical_monitor (monitor);
|
2020-01-17 15:08:02 -05:00
|
|
|
logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
|
2019-06-17 20:49:45 -04:00
|
|
|
|
2020-01-17 15:08:02 -05:00
|
|
|
for (l = meta_renderer_get_views (renderer); l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaRendererView *view = l->data;
|
|
|
|
MetaRectangle view_layout;
|
|
|
|
|
|
|
|
clutter_stage_view_get_layout (CLUTTER_STAGE_VIEW (view), &view_layout);
|
|
|
|
if (meta_rectangle_overlap (&logical_monitor_layout, &view_layout))
|
|
|
|
{
|
|
|
|
MetaStageWatch *watch;
|
|
|
|
|
|
|
|
watch = meta_stage_watch_view (meta_stage,
|
|
|
|
CLUTTER_STAGE_VIEW (view),
|
|
|
|
watch_phase,
|
2020-08-29 14:37:38 -04:00
|
|
|
callback,
|
2020-01-17 15:08:02 -05:00
|
|
|
monitor_src);
|
|
|
|
|
|
|
|
monitor_src->watches = g_list_prepend (monitor_src->watches, watch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-27 17:25:51 -05:00
|
|
|
static void
|
|
|
|
reattach_watches (MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
|
|
|
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
|
|
|
|
MetaScreenCastStream *stream;
|
|
|
|
ClutterStage *stage;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
stream = meta_screen_cast_stream_src_get_stream (src);
|
|
|
|
stage = get_stage (monitor_src);
|
|
|
|
|
|
|
|
for (l = monitor_src->watches; l; l = l->next)
|
|
|
|
meta_stage_remove_watch (META_STAGE (stage), l->data);
|
|
|
|
g_clear_pointer (&monitor_src->watches, g_list_free);
|
|
|
|
|
2021-06-25 12:29:06 -04:00
|
|
|
add_view_watches (monitor_src,
|
|
|
|
META_STAGE_WATCH_BEFORE_PAINT,
|
|
|
|
before_stage_painted);
|
|
|
|
|
2021-01-27 17:25:51 -05:00
|
|
|
switch (meta_screen_cast_stream_get_cursor_mode (stream))
|
|
|
|
{
|
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_METADATA:
|
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_HIDDEN:
|
|
|
|
add_view_watches (monitor_src,
|
|
|
|
META_STAGE_WATCH_AFTER_ACTOR_PAINT,
|
|
|
|
stage_painted);
|
|
|
|
break;
|
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_EMBEDDED:
|
|
|
|
add_view_watches (monitor_src,
|
|
|
|
META_STAGE_WATCH_AFTER_PAINT,
|
|
|
|
stage_painted);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_monitors_changed (MetaMonitorManager *monitor_manager,
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
|
|
|
reattach_watches (monitor_src);
|
|
|
|
}
|
|
|
|
|
2020-01-17 15:08:02 -05:00
|
|
|
static void
|
|
|
|
meta_screen_cast_monitor_stream_src_enable (MetaScreenCastStreamSrc *src)
|
|
|
|
{
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src =
|
|
|
|
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
|
|
|
|
MetaBackend *backend = get_backend (monitor_src);
|
2021-01-27 17:25:51 -05:00
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
2020-01-17 15:08:02 -05:00
|
|
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
2022-04-29 10:05:50 -04:00
|
|
|
ClutterStage *stage = get_stage (monitor_src);
|
2020-01-17 15:08:02 -05:00
|
|
|
MetaScreenCastStream *stream;
|
|
|
|
|
|
|
|
stream = meta_screen_cast_stream_src_get_stream (src);
|
2018-12-14 11:47:57 -05:00
|
|
|
|
|
|
|
switch (meta_screen_cast_stream_get_cursor_mode (stream))
|
|
|
|
{
|
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_METADATA:
|
2020-07-13 08:09:44 -04:00
|
|
|
monitor_src->position_invalidated_handler_id =
|
|
|
|
g_signal_connect_after (cursor_tracker, "position-invalidated",
|
|
|
|
G_CALLBACK (pointer_position_invalidated),
|
2018-12-14 11:47:57 -05:00
|
|
|
monitor_src);
|
|
|
|
monitor_src->cursor_changed_handler_id =
|
|
|
|
g_signal_connect_after (cursor_tracker, "cursor-changed",
|
|
|
|
G_CALLBACK (cursor_changed),
|
|
|
|
monitor_src);
|
2022-04-29 10:05:50 -04:00
|
|
|
monitor_src->stage_prepare_frame_handler_id =
|
|
|
|
g_signal_connect_after (stage, "prepare-frame",
|
|
|
|
G_CALLBACK (on_prepare_frame),
|
|
|
|
monitor_src);
|
2020-07-29 05:43:44 -04:00
|
|
|
meta_cursor_tracker_track_position (cursor_tracker);
|
2021-01-27 17:25:51 -05:00
|
|
|
break;
|
2018-12-14 11:47:57 -05:00
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_HIDDEN:
|
|
|
|
break;
|
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_EMBEDDED:
|
|
|
|
inhibit_hw_cursor (monitor_src);
|
2020-07-29 05:43:44 -04:00
|
|
|
meta_cursor_tracker_track_position (cursor_tracker);
|
2018-12-14 11:47:57 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-01-27 17:25:51 -05:00
|
|
|
reattach_watches (monitor_src);
|
|
|
|
g_signal_connect_object (monitor_manager, "monitors-changed-internal",
|
|
|
|
G_CALLBACK (on_monitors_changed),
|
|
|
|
monitor_src, 0);
|
|
|
|
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (get_stage (monitor_src)));
|
2017-06-21 02:23:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-06-26 00:55:48 -04:00
|
|
|
meta_screen_cast_monitor_stream_src_disable (MetaScreenCastStreamSrc *src)
|
2017-06-21 02:23:44 -04:00
|
|
|
{
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src =
|
2017-06-26 00:55:48 -04:00
|
|
|
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
|
2020-07-29 05:43:44 -04:00
|
|
|
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
|
2018-12-14 11:47:57 -05:00
|
|
|
MetaBackend *backend = get_backend (monitor_src);
|
|
|
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
2017-06-21 02:23:44 -04:00
|
|
|
ClutterStage *stage;
|
2019-06-17 20:49:45 -04:00
|
|
|
MetaStage *meta_stage;
|
2020-01-17 15:08:02 -05:00
|
|
|
GList *l;
|
2017-06-21 02:23:44 -04:00
|
|
|
|
|
|
|
stage = get_stage (monitor_src);
|
2019-06-17 20:49:45 -04:00
|
|
|
meta_stage = META_STAGE (stage);
|
2018-12-14 11:47:57 -05:00
|
|
|
|
2020-01-17 15:08:02 -05:00
|
|
|
for (l = monitor_src->watches; l; l = l->next)
|
2018-12-14 11:47:57 -05:00
|
|
|
{
|
2020-01-17 15:08:02 -05:00
|
|
|
MetaStageWatch *watch = l->data;
|
2018-12-14 11:47:57 -05:00
|
|
|
|
2020-01-17 15:08:02 -05:00
|
|
|
meta_stage_remove_watch (meta_stage, watch);
|
2018-12-14 11:47:57 -05:00
|
|
|
}
|
2020-01-17 15:08:02 -05:00
|
|
|
g_clear_pointer (&monitor_src->watches, g_list_free);
|
|
|
|
|
|
|
|
if (monitor_src->hw_cursor_inhibited)
|
|
|
|
uninhibit_hw_cursor (monitor_src);
|
2018-12-14 11:47:57 -05:00
|
|
|
|
2020-07-13 08:09:44 -04:00
|
|
|
g_clear_signal_handler (&monitor_src->position_invalidated_handler_id,
|
2019-11-15 19:25:52 -05:00
|
|
|
cursor_tracker);
|
|
|
|
g_clear_signal_handler (&monitor_src->cursor_changed_handler_id,
|
|
|
|
cursor_tracker);
|
2022-04-29 10:05:50 -04:00
|
|
|
g_clear_signal_handler (&monitor_src->stage_prepare_frame_handler_id,
|
|
|
|
stage);
|
2020-07-29 05:43:44 -04:00
|
|
|
|
2021-06-25 12:33:28 -04:00
|
|
|
g_clear_handle_id (&monitor_src->maybe_record_idle_id, g_source_remove);
|
|
|
|
|
2020-07-29 05:43:44 -04:00
|
|
|
switch (meta_screen_cast_stream_get_cursor_mode (stream))
|
|
|
|
{
|
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_METADATA:
|
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_EMBEDDED:
|
|
|
|
meta_cursor_tracker_untrack_position (cursor_tracker);
|
|
|
|
break;
|
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_HIDDEN:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-14 11:47:57 -05:00
|
|
|
static gboolean
|
2020-07-03 10:57:01 -04:00
|
|
|
meta_screen_cast_monitor_stream_src_record_to_buffer (MetaScreenCastStreamSrc *src,
|
2021-02-01 03:17:15 -05:00
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int stride,
|
2020-07-03 10:57:01 -04:00
|
|
|
uint8_t *data,
|
|
|
|
GError **error)
|
2017-06-26 00:55:48 -04:00
|
|
|
{
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src =
|
|
|
|
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
|
2020-07-29 05:43:44 -04:00
|
|
|
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
|
2017-06-26 00:55:48 -04:00
|
|
|
ClutterStage *stage;
|
|
|
|
MetaMonitor *monitor;
|
|
|
|
MetaLogicalMonitor *logical_monitor;
|
2021-05-08 07:22:27 -04:00
|
|
|
float scale;
|
2021-06-25 12:33:28 -04:00
|
|
|
ClutterPaintFlag paint_flags = CLUTTER_PAINT_FLAG_CLEAR;
|
2017-06-26 00:55:48 -04:00
|
|
|
|
|
|
|
monitor = get_monitor (monitor_src);
|
|
|
|
logical_monitor = meta_monitor_get_logical_monitor (monitor);
|
2020-04-01 05:06:13 -04:00
|
|
|
stage = get_stage (monitor_src);
|
2021-05-08 07:22:27 -04:00
|
|
|
|
|
|
|
if (meta_is_stage_views_scaled ())
|
|
|
|
scale = meta_logical_monitor_get_scale (logical_monitor);
|
|
|
|
else
|
|
|
|
scale = 1.0;
|
|
|
|
|
2020-07-29 05:43:44 -04:00
|
|
|
switch (meta_screen_cast_stream_get_cursor_mode (stream))
|
|
|
|
{
|
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_METADATA:
|
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_HIDDEN:
|
2021-06-25 12:33:28 -04:00
|
|
|
paint_flags |= CLUTTER_PAINT_FLAG_NO_CURSORS;
|
|
|
|
break;
|
|
|
|
case META_SCREEN_CAST_CURSOR_MODE_EMBEDDED:
|
|
|
|
paint_flags |= CLUTTER_PAINT_FLAG_FORCE_CURSORS;
|
2020-07-29 05:43:44 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-06-25 12:33:28 -04:00
|
|
|
if (!clutter_stage_paint_to_buffer (stage, &logical_monitor->rect, scale,
|
|
|
|
data,
|
|
|
|
stride,
|
|
|
|
CLUTTER_CAIRO_FORMAT_ARGB32,
|
|
|
|
paint_flags,
|
|
|
|
error))
|
|
|
|
return FALSE;
|
|
|
|
|
2018-12-14 11:47:57 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-12-09 08:11:51 -05:00
|
|
|
static gboolean
|
2020-07-03 10:57:01 -04:00
|
|
|
meta_screen_cast_monitor_stream_src_record_to_framebuffer (MetaScreenCastStreamSrc *src,
|
|
|
|
CoglFramebuffer *framebuffer,
|
|
|
|
GError **error)
|
2019-12-09 08:11:51 -05:00
|
|
|
{
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src =
|
|
|
|
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
|
|
|
|
MetaBackend *backend = get_backend (monitor_src);
|
|
|
|
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
|
|
|
MetaMonitor *monitor;
|
|
|
|
MetaLogicalMonitor *logical_monitor;
|
|
|
|
MetaRectangle logical_monitor_layout;
|
|
|
|
GList *l;
|
|
|
|
float view_scale;
|
|
|
|
|
|
|
|
monitor = get_monitor (monitor_src);
|
|
|
|
logical_monitor = meta_monitor_get_logical_monitor (monitor);
|
|
|
|
logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
|
|
|
|
|
|
|
|
if (meta_is_stage_views_scaled ())
|
|
|
|
view_scale = meta_logical_monitor_get_scale (logical_monitor);
|
|
|
|
else
|
|
|
|
view_scale = 1.0;
|
|
|
|
|
|
|
|
for (l = meta_renderer_get_views (renderer); l; l = l->next)
|
|
|
|
{
|
|
|
|
ClutterStageView *view = CLUTTER_STAGE_VIEW (l->data);
|
|
|
|
CoglFramebuffer *view_framebuffer;
|
2020-08-28 22:01:11 -04:00
|
|
|
CoglScanout *scanout;
|
2019-12-09 08:11:51 -05:00
|
|
|
MetaRectangle view_layout;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
clutter_stage_view_get_layout (view, &view_layout);
|
|
|
|
|
|
|
|
if (!meta_rectangle_overlap (&logical_monitor_layout, &view_layout))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
x = (int) roundf ((view_layout.x - logical_monitor_layout.x) * view_scale);
|
|
|
|
y = (int) roundf ((view_layout.y - logical_monitor_layout.y) * view_scale);
|
|
|
|
|
2020-08-28 22:01:11 -04:00
|
|
|
scanout = clutter_stage_view_peek_scanout (view);
|
|
|
|
if (scanout)
|
|
|
|
{
|
|
|
|
if (!cogl_scanout_blit_to_framebuffer (scanout,
|
|
|
|
framebuffer,
|
|
|
|
x, y,
|
|
|
|
error))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
view_framebuffer = clutter_stage_view_get_framebuffer (view);
|
|
|
|
if (!cogl_blit_framebuffer (view_framebuffer,
|
|
|
|
framebuffer,
|
|
|
|
0, 0,
|
|
|
|
x, y,
|
|
|
|
cogl_framebuffer_get_width (view_framebuffer),
|
|
|
|
cogl_framebuffer_get_height (view_framebuffer),
|
|
|
|
error))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-12-09 08:11:51 -05:00
|
|
|
}
|
|
|
|
|
2021-01-27 06:50:46 -05:00
|
|
|
cogl_framebuffer_flush (framebuffer);
|
2019-12-09 08:11:51 -05:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-07-03 17:57:31 -04:00
|
|
|
static void
|
|
|
|
meta_screen_cast_monitor_stream_record_follow_up (MetaScreenCastStreamSrc *src)
|
|
|
|
{
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src =
|
|
|
|
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
|
|
|
|
MetaBackend *backend = get_backend (monitor_src);
|
|
|
|
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
|
|
|
ClutterStage *stage = get_stage (monitor_src);
|
|
|
|
MetaMonitor *monitor;
|
|
|
|
MetaLogicalMonitor *logical_monitor;
|
|
|
|
MetaRectangle logical_monitor_layout;
|
|
|
|
GList *l;
|
|
|
|
|
2021-06-25 12:33:28 -04:00
|
|
|
g_clear_handle_id (&monitor_src->maybe_record_idle_id, g_source_remove);
|
|
|
|
|
2020-07-03 17:57:31 -04:00
|
|
|
monitor = get_monitor (monitor_src);
|
|
|
|
logical_monitor = meta_monitor_get_logical_monitor (monitor);
|
|
|
|
logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
|
|
|
|
|
|
|
|
for (l = meta_renderer_get_views (renderer); l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaRendererView *view = l->data;
|
|
|
|
MetaRectangle view_layout;
|
|
|
|
MetaRectangle damage;
|
|
|
|
|
|
|
|
clutter_stage_view_get_layout (CLUTTER_STAGE_VIEW (view), &view_layout);
|
|
|
|
|
|
|
|
if (!meta_rectangle_overlap (&logical_monitor_layout, &view_layout))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
damage = (cairo_rectangle_int_t) {
|
|
|
|
.x = view_layout.x,
|
|
|
|
.y = view_layout.y,
|
|
|
|
.width = 1,
|
|
|
|
.height = 1,
|
|
|
|
};
|
|
|
|
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stage), &damage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-14 11:47:57 -05:00
|
|
|
static void
|
|
|
|
meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc *src,
|
|
|
|
struct spa_meta_cursor *spa_meta_cursor)
|
|
|
|
{
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src =
|
|
|
|
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
|
|
|
|
MetaBackend *backend = get_backend (monitor_src);
|
|
|
|
MetaCursorRenderer *cursor_renderer =
|
|
|
|
meta_backend_get_cursor_renderer (backend);
|
2020-09-01 09:25:02 -04:00
|
|
|
MetaCursorTracker *cursor_tracker =
|
|
|
|
meta_backend_get_cursor_tracker (backend);
|
2018-12-14 11:47:57 -05:00
|
|
|
MetaCursorSprite *cursor_sprite;
|
|
|
|
MetaMonitor *monitor;
|
|
|
|
MetaLogicalMonitor *logical_monitor;
|
|
|
|
MetaRectangle logical_monitor_layout;
|
2019-02-20 10:23:04 -05:00
|
|
|
graphene_rect_t logical_monitor_rect;
|
2018-12-14 11:47:57 -05:00
|
|
|
float view_scale;
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_t cursor_position;
|
2019-01-21 08:32:05 -05:00
|
|
|
int x, y;
|
2018-12-14 11:47:57 -05:00
|
|
|
|
|
|
|
cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer);
|
|
|
|
|
2020-09-01 09:25:02 -04:00
|
|
|
if (!meta_cursor_tracker_get_pointer_visible (cursor_tracker) ||
|
|
|
|
!is_cursor_in_stream (monitor_src))
|
2018-12-14 11:47:57 -05:00
|
|
|
{
|
2019-01-21 08:32:05 -05:00
|
|
|
meta_screen_cast_stream_src_unset_cursor_metadata (src,
|
|
|
|
spa_meta_cursor);
|
2018-12-14 11:47:57 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
monitor = get_monitor (monitor_src);
|
|
|
|
logical_monitor = meta_monitor_get_logical_monitor (monitor);
|
|
|
|
logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
|
|
|
|
logical_monitor_rect =
|
2019-02-20 10:23:04 -05:00
|
|
|
meta_rectangle_to_graphene_rect (&logical_monitor_layout);
|
2018-12-14 11:47:57 -05:00
|
|
|
|
2020-01-17 15:08:02 -05:00
|
|
|
if (meta_is_stage_views_scaled ())
|
|
|
|
view_scale = meta_logical_monitor_get_scale (logical_monitor);
|
2018-12-14 11:47:57 -05:00
|
|
|
else
|
|
|
|
view_scale = 1.0;
|
|
|
|
|
2020-07-13 06:28:46 -04:00
|
|
|
meta_cursor_tracker_get_pointer (cursor_tracker, &cursor_position, NULL);
|
2018-12-14 11:47:57 -05:00
|
|
|
cursor_position.x -= logical_monitor_rect.origin.x;
|
|
|
|
cursor_position.y -= logical_monitor_rect.origin.y;
|
|
|
|
cursor_position.x *= view_scale;
|
|
|
|
cursor_position.y *= view_scale;
|
|
|
|
|
2019-01-21 08:32:05 -05:00
|
|
|
x = (int) roundf (cursor_position.x);
|
|
|
|
y = (int) roundf (cursor_position.y);
|
2019-01-03 10:51:08 -05:00
|
|
|
|
2019-01-21 08:32:05 -05:00
|
|
|
if (monitor_src->cursor_bitmap_invalid)
|
2019-01-03 10:51:08 -05:00
|
|
|
{
|
2019-01-21 08:32:05 -05:00
|
|
|
if (cursor_sprite)
|
2018-12-14 11:47:57 -05:00
|
|
|
{
|
2019-01-21 08:32:05 -05:00
|
|
|
float cursor_scale;
|
|
|
|
float scale;
|
|
|
|
|
|
|
|
cursor_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
|
|
|
|
scale = view_scale * cursor_scale;
|
|
|
|
meta_screen_cast_stream_src_set_cursor_sprite_metadata (src,
|
|
|
|
spa_meta_cursor,
|
|
|
|
cursor_sprite,
|
|
|
|
x, y,
|
|
|
|
scale);
|
2018-12-14 11:47:57 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-21 08:32:05 -05:00
|
|
|
meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (src,
|
|
|
|
spa_meta_cursor,
|
|
|
|
x, y);
|
2018-12-14 11:47:57 -05:00
|
|
|
}
|
2019-01-21 08:32:05 -05:00
|
|
|
|
|
|
|
monitor_src->cursor_bitmap_invalid = FALSE;
|
2018-12-14 11:47:57 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-21 08:32:05 -05:00
|
|
|
meta_screen_cast_stream_src_set_cursor_position_metadata (src,
|
|
|
|
spa_meta_cursor,
|
|
|
|
x, y);
|
2018-12-14 11:47:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2020-07-13 11:29:51 -04:00
|
|
|
meta_screen_cast_monitor_stream_src_is_cursor_inhibited (MetaHwCursorInhibitor *inhibitor)
|
2018-12-14 11:47:57 -05:00
|
|
|
{
|
|
|
|
MetaScreenCastMonitorStreamSrc *monitor_src =
|
|
|
|
META_SCREEN_CAST_MONITOR_STREAM_SRC (inhibitor);
|
|
|
|
|
|
|
|
return is_cursor_in_stream (monitor_src);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
hw_cursor_inhibitor_iface_init (MetaHwCursorInhibitorInterface *iface)
|
|
|
|
{
|
2020-07-13 11:29:51 -04:00
|
|
|
iface->is_cursor_inhibited =
|
|
|
|
meta_screen_cast_monitor_stream_src_is_cursor_inhibited;
|
2017-06-26 00:55:48 -04:00
|
|
|
}
|
2017-06-21 02:23:44 -04:00
|
|
|
|
2017-06-26 00:55:48 -04:00
|
|
|
MetaScreenCastMonitorStreamSrc *
|
|
|
|
meta_screen_cast_monitor_stream_src_new (MetaScreenCastMonitorStream *monitor_stream,
|
|
|
|
GError **error)
|
|
|
|
{
|
2017-06-28 03:17:32 -04:00
|
|
|
return g_initable_new (META_TYPE_SCREEN_CAST_MONITOR_STREAM_SRC, NULL, error,
|
2017-06-26 00:55:48 -04:00
|
|
|
"stream", monitor_stream,
|
|
|
|
NULL);
|
2017-06-21 02:23:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_screen_cast_monitor_stream_src_init (MetaScreenCastMonitorStreamSrc *monitor_src)
|
|
|
|
{
|
2019-01-03 10:51:08 -05:00
|
|
|
monitor_src->cursor_bitmap_invalid = TRUE;
|
2017-06-21 02:23:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_screen_cast_monitor_stream_src_class_init (MetaScreenCastMonitorStreamSrcClass *klass)
|
|
|
|
{
|
|
|
|
MetaScreenCastStreamSrcClass *src_class =
|
|
|
|
META_SCREEN_CAST_STREAM_SRC_CLASS (klass);
|
|
|
|
|
|
|
|
src_class->get_specs = meta_screen_cast_monitor_stream_src_get_specs;
|
2017-06-26 00:55:48 -04:00
|
|
|
src_class->enable = meta_screen_cast_monitor_stream_src_enable;
|
|
|
|
src_class->disable = meta_screen_cast_monitor_stream_src_disable;
|
2020-07-03 10:42:45 -04:00
|
|
|
src_class->record_to_buffer =
|
|
|
|
meta_screen_cast_monitor_stream_src_record_to_buffer;
|
|
|
|
src_class->record_to_framebuffer =
|
|
|
|
meta_screen_cast_monitor_stream_src_record_to_framebuffer;
|
2020-07-03 17:57:31 -04:00
|
|
|
src_class->record_follow_up =
|
|
|
|
meta_screen_cast_monitor_stream_record_follow_up;
|
2018-12-14 11:47:57 -05:00
|
|
|
src_class->set_cursor_metadata =
|
|
|
|
meta_screen_cast_monitor_stream_src_set_cursor_metadata;
|
2017-06-21 02:23:44 -04:00
|
|
|
}
|