screen-cast/window: Add API to check if stream-cast is active

Screen-casted windows need to be considered visible in various situations
but existing APIs such as `clutter_actor_is_effectively_on_stage_view()`
don't do so. Add new API that allows checking if a surface belongs to a
screen-casted window for the respective cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2789>
This commit is contained in:
Robert Mader
2023-02-11 07:03:27 +01:00
parent e18ba5dcc6
commit 2d5dd06a50
5 changed files with 66 additions and 0 deletions

View File

@ -198,6 +198,16 @@ meta_screen_cast_window_stream_finalize (GObject *object)
{
MetaScreenCastWindowStream *window_stream =
META_SCREEN_CAST_WINDOW_STREAM (object);
MetaWindowActor *window_actor;
window_actor = meta_window_actor_from_window (window_stream->window);
if (window_actor)
{
MetaScreenCastWindow *screen_cast_window;
screen_cast_window = META_SCREEN_CAST_WINDOW (window_actor);
meta_screen_cast_window_dec_usage (screen_cast_window);
}
g_clear_signal_handler (&window_stream->window_unmanaged_handler_id,
window_stream->window);
@ -218,6 +228,8 @@ meta_screen_cast_window_stream_initable_init (GInitable *initable,
meta_screen_cast_session_get_screen_cast (session);
MetaBackend *backend = meta_screen_cast_get_backend (screen_cast);
MetaWindow *window = window_stream->window;
MetaScreenCastWindow *screen_cast_window =
META_SCREEN_CAST_WINDOW (meta_window_actor_from_window (window));
MetaLogicalMonitor *logical_monitor;
int scale;
@ -248,6 +260,8 @@ meta_screen_cast_window_stream_initable_init (GInitable *initable,
window_stream->stream_width = logical_monitor->rect.width * scale;
window_stream->stream_height = logical_monitor->rect.height * scale;
meta_screen_cast_window_inc_usage (screen_cast_window);
return initable_parent_iface->init (initable, cancellable, error);
}