backend: Make the getter use the cached ui scale

The cached ui scale is kept up to date, so don't recalculate it
everytime meta_backend_get_ui_scaling() is called.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl 2017-04-10 17:33:45 +08:00
parent 183f4b0c13
commit 43cdf81f6b

View File

@ -114,6 +114,9 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (MetaBackend, meta_backend, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
initable_iface_init)); initable_iface_init));
static int
meta_backend_calculate_ui_scaling_factor (MetaBackend *backend);
static void static void
meta_backend_finalize (GObject *object) meta_backend_finalize (GObject *object)
{ {
@ -163,7 +166,7 @@ meta_backend_update_ui_scaling_factor (MetaBackend *backend)
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend); MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
int ui_scaling_factor; int ui_scaling_factor;
ui_scaling_factor = meta_backend_get_ui_scaling_factor (backend); ui_scaling_factor = meta_backend_calculate_ui_scaling_factor (backend);
if (ui_scaling_factor != priv->ui_scaling_factor) if (ui_scaling_factor != priv->ui_scaling_factor)
{ {
@ -1156,8 +1159,8 @@ calculate_ui_scaling_factor (MetaBackend *backend)
return max_scale; return max_scale;
} }
int static int
meta_backend_get_ui_scaling_factor (MetaBackend *backend) meta_backend_calculate_ui_scaling_factor (MetaBackend *backend)
{ {
if (meta_is_stage_views_scaled ()) if (meta_is_stage_views_scaled ())
{ {
@ -1172,6 +1175,14 @@ meta_backend_get_ui_scaling_factor (MetaBackend *backend)
} }
} }
int
meta_backend_get_ui_scaling_factor (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
return priv->ui_scaling_factor;
}
void void
meta_backend_notify_ui_scaling_factor_changed (MetaBackend *backend) meta_backend_notify_ui_scaling_factor_changed (MetaBackend *backend)
{ {