mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 04:42:14 +00:00
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:
parent
e18ba5dcc6
commit
2d5dd06a50
@ -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);
|
||||
}
|
||||
|
||||
|
@ -99,3 +99,15 @@ meta_screen_cast_window_has_damage (MetaScreenCastWindow *screen_cast_window)
|
||||
|
||||
return iface->has_damage (screen_cast_window);
|
||||
}
|
||||
|
||||
void
|
||||
meta_screen_cast_window_inc_usage (MetaScreenCastWindow *screen_cast_window)
|
||||
{
|
||||
META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->inc_usage (screen_cast_window);
|
||||
}
|
||||
|
||||
void
|
||||
meta_screen_cast_window_dec_usage (MetaScreenCastWindow *screen_cast_window)
|
||||
{
|
||||
META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->dec_usage (screen_cast_window);
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ struct _MetaScreenCastWindowInterface
|
||||
CoglFramebuffer *framebuffer);
|
||||
|
||||
gboolean (*has_damage) (MetaScreenCastWindow *screen_cast_window);
|
||||
|
||||
void (*inc_usage) (MetaScreenCastWindow *screen_cast_window);
|
||||
void (*dec_usage) (MetaScreenCastWindow *screen_cast_window);
|
||||
};
|
||||
|
||||
void meta_screen_cast_window_get_buffer_bounds (MetaScreenCastWindow *screen_cast_window,
|
||||
@ -90,6 +93,9 @@ gboolean meta_screen_cast_window_blit_to_framebuffer (MetaScreenCastWindow *scre
|
||||
|
||||
gboolean meta_screen_cast_window_has_damage (MetaScreenCastWindow *screen_cast_window);
|
||||
|
||||
void meta_screen_cast_window_inc_usage (MetaScreenCastWindow *screen_cast_window);
|
||||
void meta_screen_cast_window_dec_usage (MetaScreenCastWindow *screen_cast_window);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* META_SCREEN_CAST_WINDOW_H */
|
||||
|
@ -101,6 +101,8 @@ void meta_window_actor_set_geometry_scale (MetaWindowActor *window_actor,
|
||||
|
||||
int meta_window_actor_get_geometry_scale (MetaWindowActor *window_actor);
|
||||
|
||||
gboolean meta_window_actor_is_streaming (MetaWindowActor *window_actor);
|
||||
|
||||
void meta_window_actor_notify_damaged (MetaWindowActor *window_actor);
|
||||
|
||||
gboolean meta_window_actor_is_frozen (MetaWindowActor *self);
|
||||
|
@ -69,6 +69,7 @@ typedef struct _MetaWindowActorPrivate
|
||||
gint destroy_in_progress;
|
||||
|
||||
guint freeze_count;
|
||||
guint screen_cast_usage_count;
|
||||
|
||||
guint visible : 1;
|
||||
guint disposed : 1;
|
||||
@ -1357,6 +1358,26 @@ meta_window_actor_has_damage (MetaScreenCastWindow *screen_cast_window)
|
||||
return clutter_actor_has_damage (CLUTTER_ACTOR (screen_cast_window));
|
||||
}
|
||||
|
||||
static void
|
||||
meta_window_actor_inc_screen_cast_usage (MetaScreenCastWindow *screen_cast_window)
|
||||
{
|
||||
MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
|
||||
MetaWindowActorPrivate *priv =
|
||||
meta_window_actor_get_instance_private (window_actor);
|
||||
|
||||
priv->screen_cast_usage_count++;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_window_actor_dec_screen_cast_usage (MetaScreenCastWindow *screen_cast_window)
|
||||
{
|
||||
MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
|
||||
MetaWindowActorPrivate *priv =
|
||||
meta_window_actor_get_instance_private (window_actor);
|
||||
|
||||
priv->screen_cast_usage_count--;
|
||||
}
|
||||
|
||||
static void
|
||||
screen_cast_window_iface_init (MetaScreenCastWindowInterface *iface)
|
||||
{
|
||||
@ -1366,6 +1387,17 @@ screen_cast_window_iface_init (MetaScreenCastWindowInterface *iface)
|
||||
iface->capture_into = meta_window_actor_capture_into;
|
||||
iface->blit_to_framebuffer = meta_window_actor_blit_to_framebuffer;
|
||||
iface->has_damage = meta_window_actor_has_damage;
|
||||
iface->inc_usage = meta_window_actor_inc_screen_cast_usage;
|
||||
iface->dec_usage = meta_window_actor_dec_screen_cast_usage;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_window_actor_is_streaming (MetaWindowActor *window_actor)
|
||||
{
|
||||
MetaWindowActorPrivate *priv =
|
||||
meta_window_actor_get_instance_private (window_actor);
|
||||
|
||||
return priv->screen_cast_usage_count > 0;
|
||||
}
|
||||
|
||||
MetaWindowActor *
|
||||
|
Loading…
Reference in New Issue
Block a user