mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
surface-actor-wayland: Add API to pick a primary stage view
Add a simple heuristic how to choose the primary stage view to drive events like frame callbacks for a given surface actor. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1468>
This commit is contained in:
parent
9db09e327c
commit
ff94ed0ebf
@ -81,6 +81,54 @@ meta_surface_actor_wayland_try_acquire_scanout (MetaSurfaceActorWayland *self,
|
||||
return scanout;
|
||||
}
|
||||
|
||||
#define UNOBSCURED_TRESHOLD 0.1
|
||||
|
||||
ClutterStageView *
|
||||
meta_surface_actor_wayland_get_current_primary_view (MetaSurfaceActor *actor,
|
||||
ClutterStage *stage)
|
||||
{
|
||||
ClutterStageView *current_primary_view = NULL;
|
||||
float highest_refresh_rate = 0;
|
||||
float biggest_unobscurred_fraction = 0;
|
||||
GList *l;
|
||||
|
||||
for (l = clutter_stage_peek_stage_views (stage); l; l = l->next)
|
||||
{
|
||||
ClutterStageView *stage_view = l->data;
|
||||
float refresh_rate;
|
||||
float unobscurred_fraction = 1.0;
|
||||
|
||||
if (clutter_actor_has_mapped_clones (CLUTTER_ACTOR (actor)))
|
||||
{
|
||||
if (!clutter_actor_is_effectively_on_stage_view (CLUTTER_ACTOR (actor),
|
||||
stage_view))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (meta_surface_actor_is_obscured_on_stage_view (actor,
|
||||
stage_view,
|
||||
&unobscurred_fraction))
|
||||
continue;
|
||||
}
|
||||
|
||||
refresh_rate = clutter_stage_view_get_refresh_rate (stage_view);
|
||||
|
||||
if ((refresh_rate > highest_refresh_rate &&
|
||||
(unobscurred_fraction > UNOBSCURED_TRESHOLD ||
|
||||
biggest_unobscurred_fraction < UNOBSCURED_TRESHOLD)) ||
|
||||
(biggest_unobscurred_fraction < UNOBSCURED_TRESHOLD &&
|
||||
unobscurred_fraction > UNOBSCURED_TRESHOLD))
|
||||
{
|
||||
current_primary_view = stage_view;
|
||||
highest_refresh_rate = refresh_rate;
|
||||
biggest_unobscurred_fraction = unobscurred_fraction;
|
||||
}
|
||||
}
|
||||
|
||||
return current_primary_view;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_surface_actor_wayland_dispose (GObject *object)
|
||||
{
|
||||
|
@ -55,6 +55,9 @@ void meta_surface_actor_wayland_add_frame_callbacks (MetaSurfaceActorWayland *se
|
||||
CoglScanout * meta_surface_actor_wayland_try_acquire_scanout (MetaSurfaceActorWayland *self,
|
||||
CoglOnscreen *onscreen);
|
||||
|
||||
ClutterStageView * meta_surface_actor_wayland_get_current_primary_view (MetaSurfaceActor *actor,
|
||||
ClutterStage *stage);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __META_SURFACE_ACTOR_WAYLAND_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user