clutter/backend: Introduce a fallback scale set to primary monitor scale

Add private API to ClutterBackend to set a fallback resource scale
available to Clutter. This API will be used for "guessing" the
resource-scale of ClutterActors in case the actor is not attached to a
stage or not properly positioned yet.

We set this value from inside mutters MetaRenderer while creating new
stage-views for each logical monitor. This makes it possible to set the
fallback scale to the scale of the primary monitor, which is the monitor
where most ClutterActors are going to be positioned.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1276
This commit is contained in:
Jonas Dreßler 2020-06-06 22:58:10 +02:00 committed by Jonas Ådahl
parent 162aec7802
commit 802b24a640
3 changed files with 34 additions and 0 deletions

View File

@ -53,6 +53,8 @@ struct _ClutterBackend
gfloat units_per_em;
gint32 units_serial;
float fallback_resource_scale;
ClutterStageWindow *stage_window;
ClutterInputMethod *input_method;
@ -134,6 +136,12 @@ void clutter_set_allowed_drivers (const c
CLUTTER_EXPORT
ClutterStageWindow * clutter_backend_get_stage_window (ClutterBackend *backend);
CLUTTER_EXPORT
void clutter_backend_set_fallback_resource_scale (ClutterBackend *backend,
float fallback_resource_scale);
float clutter_backend_get_fallback_resource_scale (ClutterBackend *backend);
G_END_DECLS
#endif /* __CLUTTER_BACKEND_PRIVATE_H__ */

View File

@ -1031,3 +1031,16 @@ clutter_backend_get_default_seat (ClutterBackend *backend)
return CLUTTER_BACKEND_GET_CLASS (backend)->get_default_seat (backend);
}
void
clutter_backend_set_fallback_resource_scale (ClutterBackend *backend,
float fallback_resource_scale)
{
backend->fallback_resource_scale = fallback_resource_scale;
}
float
clutter_backend_get_fallback_resource_scale (ClutterBackend *backend)
{
return backend->fallback_resource_scale;
}

View File

@ -153,6 +153,19 @@ meta_renderer_real_rebuild_views (MetaRenderer *renderer)
{
MetaLogicalMonitor *logical_monitor = l->data;
if (meta_logical_monitor_is_primary (logical_monitor))
{
ClutterBackend *clutter_backend;
float scale;
clutter_backend = meta_backend_get_clutter_backend (backend);
scale = meta_is_stage_views_scaled ()
? meta_logical_monitor_get_scale (logical_monitor)
: 1.f;
clutter_backend_set_fallback_resource_scale (clutter_backend, scale);
}
meta_logical_monitor_foreach_crtc (logical_monitor,
create_crtc_view,
renderer);